Commit graph

6375 commits

Author SHA1 Message Date
Kp 8538a96451 Remove write-only multi_protocol 2023-01-14 19:05:37 +00:00
Kp 2790c5b14a Use run_blocking_newmenu for newdemo save-as dialog 2023-01-14 19:05:37 +00:00
Kp 43470c09bd Use run_blocking_newmenu for newdemo error dialog 2023-01-14 19:05:37 +00:00
Kp dfce7ed40d Simplify SDL_QUIT handling
Remove the global `Quitting` and instead run the window close loop
immediately upon receiving SDL_QUIT.
2023-01-14 19:05:37 +00:00
Kp 7a087702d0 Remove Mac-specific Command-Q handler
Per SDL documentation, SDL will generate an SDL_QUIT event when
Command-Q is used.  Rebirth already handles SDL_QUIT, so there is no
need to explicitly detect Command-Q.
2023-01-14 19:05:37 +00:00
Kp 820ba19883 Move vclip id validation down into paging_touch_vclip
This avoids repeating the ID in every caller's test, and centralizes the
definition of a valid vclip id.
2023-01-14 19:05:37 +00:00
Kp 3f1aa85ad6 Make partial_range_t inherit from ranges::subrange
Delegate work to the standard library where possible.
2023-01-14 19:05:37 +00:00
Kp 9fd0cc96a5 Use correct coefficient table for 11Khz sounds
The new resampler sets upFactor to either `2` (for 22Khz sounds) or
`4` (for 11Khz sounds).  However, the logic to pick which coefficient
table to use tested for `0` versus non-zero, so it always picked the
coefficient table meant for 22Khz sounds, even when the sample was an
11Khz sound.  This caused a high pitched ringing in sampled sounds.
Switch to use an `enum class` to prevent using zero-vs-nonzero tests
without a cast.  Change the existing test to test for the 22Khz `enum`
value, as originally intended.  In testing, this eliminated the ringing
effect in 11Khz sounds.

Identified-by: Chris <https://forum.zdoom.org/viewtopic.php?p=1234989> (in response to a request by KynikossDragonn)
Fixes: 5165efbc46 ("Use custom fixed-point audio resampler: - Hopefully fixes issues with poor quality resampling when using SDL_AudioCVT - Converts 11025 Hz or 22050 Hz samples to the default 44100 Hz outputs - Uses high order brick wall filter like Sound Blaster 16")
2023-01-08 14:19:52 +00:00
Kp 28a83aa43f Harden D2 loading of D1 texture numbers 2023-01-07 22:17:31 +00:00
Kp 06bb1b74ad Harden bm_read_alias against bad input 2023-01-07 22:17:31 +00:00
Kp 2a4a06aca0 Use enum class for pigfile_size 2023-01-07 22:17:31 +00:00
Kp 91496e1d4a Use enum class for properties_init result 2023-01-07 22:17:31 +00:00
Kp 058ad139e4 Return earlier if no sound data is available
There is no point to retrieving the SDL_mixer output settings if the
sound data is missing, since they are only used when the data is
present.
2023-01-07 22:17:31 +00:00
Kp 704bde86bd Move SysNoHogDir to CGameArg
Move DXX_USE_SHAREPATH definition to apply to common files too, since
common files see CGameArg.
2023-01-07 22:17:31 +00:00
Kp 5ce4d49004 Use enum class for sound_sample_rate 2023-01-07 22:17:31 +00:00
Kp 60adb6ecd8 Hold digi_sample_rate const
In any given run of the program, either the SDL_mixer code will be used,
or it will not be used.  `digi_sample_rate` only needs to vary if a
single run both uses SDL_mixer and avoids it.  Make `digi_sample_rate` a
`static const` with an appropriate value for each path.
2023-01-07 22:17:31 +00:00
Kp d9241c2d69 Add back old SDL_mixer-based resampler
Add the SDL_mixer-based resampler as a compile-time alternative, which
can be chosen by setting `-DDXX_FEATURE_INTERNAL_RESAMPLER=0`.  Keep the
new internal resampler as the default.
2023-01-07 22:17:31 +00:00
Kp 9e3ebdb1f7 Add static asserts that the custom resampler does not truncate input 2023-01-07 22:17:31 +00:00
Kp f002678974 Fix integer overflow in mixer resampler 2023-01-07 22:17:31 +00:00
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 05eea350a0 Move unique_span to d_uspan.h 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 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 ca913240d0 Return ranges::subrange from robot_get_anim_state 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 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 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 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 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 cba14b91e4 Pass std::span to piggy_find_sound 2022-12-17 13:16:28 +00:00
Kp 102d19ec28 Pass std::span to piggy_find_bitmap 2022-12-17 13:16:28 +00:00
Kp 8bd94c4f5c Pass std::span to piggy_register_sound 2022-12-17 13:16:28 +00:00
Kp eefa61e1fb Return bitmap name from get_message_name 2022-12-17 13:16:28 +00:00
Kp 030897e911 Avoid temporary copy when generating abmname
Use printf `%.*s` with an appropriate length, instead of copying the
appropriate number of bytes into a temporary, null terminating it, and
relying on the terminator for printf.
2022-12-17 13:16:28 +00:00