Commit graph

12471 commits

Author SHA1 Message Date
Kp b5a609868e Remove inline stub for swap_polygon_model_data
All callers are either in `#if DXX_WORDS_BIGENDIAN` or in
`if constexpr (words_bigendian)`, so there are no callers that use the
`static inline` stub.
2023-01-07 22:17:31 +00:00
Kp 08cc393e74 Return DiskSoundHeader from DiskSoundHeader_read
This allows the structure to be const in the caller.
2023-01-07 22:17:31 +00:00
Kp 66d588c624 Use bitmap name in place for non-animated bitmaps 2023-01-07 22:17:31 +00:00
Kp 165b50bcc7 Use mve_audio_spec to track whether audio can play
This is nullptr in all the cases that audio is disabled, and non-nullptr
in all the cases where it is enabled.  Use it instead of a separate flag
variable.
2023-01-07 22:17:31 +00:00
Kp 095b19e450 Use standard new[]/delete[] for movie audio buffer 2023-01-07 22:17:31 +00:00
Kp 7b602efedc Pass std::span to mveaudio_uncompress 2023-01-07 22:17:31 +00:00
Kp 05eea350a0 Move unique_span to d_uspan.h 2023-01-07 22:17:31 +00:00
Kp 5700cc28e7 Pass std::span to decodeFrame16 2023-01-07 22:17:31 +00:00
Kp 870c85ceab Pass std::span to decodeFrame8 2023-01-07 22:17:31 +00:00
Kp 38ff4a7b19 Use std::span for MVE g_pCurMap, g_nMapLength 2023-01-07 22:17:31 +00:00
Kp f9ac799d88 Detect escort goal even for silent powerups 2023-01-07 22:17:31 +00:00
Kp 3a4927ddb1 Switch do_morph_frame to enumerate(zip())
Use structured bindings instead of manual decomposition.  This makes the
code more consistent with other zip sites.
2023-01-07 22:17:31 +00:00
Kp e0478f8111 Use if constexpr to guard calls to align_polygon_model_data
This allows the compiler to see and perform basic checks on the call
even in builds with `DXX_WORDS_NEED_ALIGNMENT == 0`.

Also, fix a missing address-of operator in one invocation of
`align_polygon_model_data`.

Reported-by: Brunnis <https://github.com/dxx-rebirth/dxx-rebirth/issues/687> (missing address-of operator)
Fixes: 43e1c841f0 ("Pass polymodel& to polymodel_read")
2022-12-31 16:21:47 +00:00
Kp 9ba1c13d9f Flatten type information for zip<> 2022-12-31 16:21:47 +00:00
Kp 1fcb02f100 Inline zip sentinel type resolution 2022-12-31 16:21:47 +00:00
Kp a56ceca502 Use distinct sentinel type on zip<> 2022-12-31 16:21:47 +00:00
Kp 14b222e2a6 Allow distinct sentinel type on enumerated range 2022-12-31 16:21:47 +00:00
Kp 199232b10e Pass ranges::subrange to glitz_menu 2022-12-31 16:21:47 +00:00
Kp 1148aceabd Store ranges::subrange in m3u_bytes 2022-12-31 16:21:47 +00:00
Kp 5eff03dd88 Store ranges::subrange in newmenu_layout 2022-12-31 16:21:47 +00:00
Kp 3bba60d1b7 Pass ranges::subrange to multi_all_players_alive 2022-12-31 16:21:47 +00:00
Kp 86515f6903 Pass ranges::subrange to multi_interactive_deny_save_game 2022-12-31 16:21:47 +00:00
Kp 0decae2328 Pass ranges::subrange to multi_common_deny_save_game 2022-12-31 16:21:47 +00:00
Kp c428fdee0f Pass ranges::subrange to bitmap_index_read_n 2022-12-31 16:21:47 +00:00
Kp 1e45b0b70b Factor out computing object light from color
Use helper functions so that the computed value can be `const`.
2022-12-31 16:21:47 +00:00
Kp f804d98825 Make enumerate inherit ranges::subrange directly
Remove the intermediate layer of partial_range_t.
2022-12-31 16:21:47 +00:00
Kp 41184654e8 Pass ranges::subrange to reactor_read_n 2022-12-31 16:21:47 +00:00
Kp 299c4e6300 Pass ranges::subrange to event_poll_state::process_event_batch 2022-12-31 16:21:47 +00:00
Kp ca913240d0 Return ranges::subrange from robot_get_anim_state 2022-12-31 16:21:47 +00:00
Kp d3ffcb0dab Store range_type, not range_iterator_type, in zip<> signature
This is initial setup to enabling use of zip() on sentinel based ranges.
Store the range's type in the zip signature, and store the types of
std::begin/std::end for the iterators, rather than assuming that
std::begin and std::end return the same type.
2022-12-31 16:21:47 +00:00
Kp 1aab6ace2a Extend zip() to examine multiple end iterators
Allow the caller to pick which sequences can terminate the zip iterator.
For compatibility and performance, default to the historical behavior of
examining only the first sequence.  The zip iteration terminates when
any of the examined sequences reaches its end, even if other sequences
have not reached their respective end.
2022-12-31 16:21:47 +00:00
Kp 0921b88028 Change zip unit tests to use requires()
This usually produces better error messages on failure.
2022-12-31 16:21:47 +00:00
Kp 23551716b3 Add static_assert checks on zip difference_type 2022-12-31 16:21:47 +00:00
Kp 4071cd0cbf Replace range_owns_iterated_storage with ranges::borrowed_range
The standard type imposes some additional requirements that are not
necessary here, but using this concept allows standard containers to be
classified correctly without specific overrides.
2022-12-31 16:21:47 +00:00
Kp e3553586c1 Use enum class for bitmap_index 2022-12-31 16:21:47 +00:00
Kp 147dd52f7d Preserve input type in deleted enumerated_array::operator[]()
Any integer type can convert to match this signature, but the diagnostic
will only report that this deleted function was matched.  Switch to a
template function so that the diagnostic can report the unconverted
integer type.
2022-12-31 16:21:47 +00:00
Kp df8e998721 Remove unnecessary morph_data helper constructors 2022-12-18 23:10:39 +00:00
Kp 01fd4079ba Remove unnecessary enumerate constructor 2022-12-18 23:10:39 +00:00
Kp 0fd5ea2972 Inline PHYSFSX_fseek(..., SEEK_SET)
When using SEEK_SET, the call passed through to PhysFS after truncating
the offset.  Call PhysFS directly in this case, bypassing the wrapper.
2022-12-18 23:10:39 +00:00
Kp e41e72c667 Use #if for DXX_HAVE_CXX_BUILTIN_FILE_LINE 2022-12-18 23:10:39 +00:00
Kp ae4b3b4c87 Make window_send_event a method of window
Switch from using a macro to capture __FILE__,__LINE__ to using
__builtin_FILE(),__builtin_LINE().  Make the event an explicit argument,
instead of assuming it is a variable named `event`.  Move the
implementation out of line.
2022-12-18 23:10:39 +00:00
Kp b4866b8e09 Let self_return_iterator use an implicit operator!= 2022-12-18 18:32:14 +00:00
Kp 64eae78dcc Prefer direct initialization for bitmap_index 2022-12-18 18:32:14 +00:00
Kp 4257391a47 Use enum class for polygon_model_index 2022-12-18 18:32:14 +00:00
Kp e6bba24737 Disable MVE mixer when movie ends
The global variables that control it configure the callback to do
nothing, but SDL_mixer would still call it and still acquire the SDL
mutex that protects the call.  Such calls are a waste, so disable them.
This should also fix
<https://github.com/dxx-rebirth/dxx-rebirth/issues/684>, which appears
to be caused by the MVE mixer callback being run during gameplay, and
the callback not returning immediately.  This is suspected to be because
a race condition between MVE_rmEndMovie and the callback caused the
global variables not to be placed in a state that causes the callback to
return immediately.
2022-12-17 13:16:28 +00:00
Kp 8d691aa080 Pass std::span to piggy_is_substitutable_bitmap 2022-12-17 13:16:28 +00:00
Kp eda958280e Return DiskBitmapHeader from DiskBitmapHeader_read
This allows the structure to be const in the caller.
2022-12-17 13:16:28 +00:00
Kp 385277b833 Advise gcc that std::span is not std::dynamic_extent long
When building with -D_GLIBCXX_DEBUG, gcc-11 warns:

```
In file included from /usr/include/string.h:535,
                 from similar/main/net_udp.cpp:14:
In function 'void* memcpy(void*, const void*, size_t)',
    inlined from 'virtual void d2x::multi::udp::dispatch_table::send_data_direct(std::span<const unsigned char>, dcx::playernum_t, int) const' at similar/main/net_udp.cpp:5731:8:
/usr/include/bits/string_fortified.h:29:33: error: 'void* __builtin_memcpy(void*, const void*, long unsigned int)' specified bound 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Werror=stringop-overflow=]
   29 |   return __builtin___memcpy_chk (__dest, __src, __len,
      |          ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
   30 |                  __glibc_objsize0 (__dest));
      |                  ~~~~~~~~~~~~~~~~~~~~~~~~~~
```

The warning is invalid: the destination buffer is not PTRDIFF_MAX bytes
long, and the requested length is not SIZE_MAX bytes.  Both claimed
lengths are the result of excessively cautious value range tracking.

Eliminate the warning by adding a `cf_assert` to assure gcc that
`data.size() != std::dynamic_extent`.
2022-12-17 13:16:28 +00:00
Kp 3f65ae0ca3 Replace PHYSFSX_read* macros with a template function object
This produces better error messages on misuse.
2022-12-17 13:16:28 +00:00
Kp cba14b91e4 Pass std::span to piggy_find_sound 2022-12-17 13:16:28 +00:00