Commit graph

6437 commits

Author SHA1 Message Date
Kp 16c86edabc Fix cockpit switch in SDL-only build
The cockpit graphic is not scaled in the SDL build, so it is only
meaningful to show when the game window dimensions match the graphic's
dimensions.  Prior to 4a8d7c7574, this worked, because the
`initial_large_game_screen_mode` was the same as the graphic's
dimensions.  That commit changed `initial_large_game_screen_mode` to
prefer a larger screen resolution for new users.  It should have
retained the original dimensions for this test.  Make that change here.

Fixes: 4a8d7c7574 ("Default to 1024x768 for new users, not 640x480")
2022-11-06 18:18:57 +00:00
Kp 7effca68f0 Use RAII_SDL_Surface to track SDL-only main canvas surface
The Rebirth main screen grd_curscreen borrows the memory allocated by
SDL_CreateRGBSurface to store its data.  Store the pointer to that
surface inside grd_curscreen and make grd_curscreen responsible for
freeing the surface.
2022-11-06 18:18:57 +00:00
Kp ae46a5b3b0 Simplify SDL gr_flip: nullptr implies copy all
Per the header comments, passing nullptr for source or destination
copies the entire region.  Use that instead of explicitly requesting the
entire region.  This should be more efficient, since it bypasses the
source rectangle clipping code that SDL would otherwise run.
2022-11-06 18:18:57 +00:00
Kp 3d5de92058 Fix OS X clang build
OS X still uses clang-14, which lacks sufficient std::ranges support for
recent Rebirth changes.

- Rewrite uses of std::ranges::SYMBOL to ranges::SYMBOL
- Add a stub header that, on gcc, provides for each SYMBOL a statement
  `using std::ranges::SYMBOL;`, to delegate back to the standard library
  implementation.
- On clang, define a minimal implementation of the required symbols,
  without constraint enforcement.  Compile-testing with gcc will catch
  constraint violations.

Once OS X clang ships a standard library with the required features,
this stub header will be removed and the uses changed back to their full
names.
2022-10-31 00:51:32 +00:00
Arne de Bruijn 3567a7bc98
Merge a31519dc08 into 7fc6879555 2022-10-29 18:07:22 +00:00
Arne de Bruijn a31519dc08 Fix score getting mangled after new ship 2022-10-29 20:03:08 +02:00
Kp 7fc6879555 Fix various Win32 build failures due to ambiguous operator[]()
gcc reports:

```
ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second
```

Fix the ambiguity by using an unsigned integer constant.
2022-10-23 23:00:24 +00:00
Kp 8501db1e64 Group Network_message GM_TEAM checks 2022-10-23 23:00:24 +00:00
Kp 862c1f0aab Pass std::span to multi_process_bigdata 2022-10-23 23:00:24 +00:00
Kp 2277d90ccd Pass std::span to net_udp_process_mdata 2022-10-23 23:00:24 +00:00
Kp 21cf4b2eb8 Pass std::span to net_udp_noloss_got_ack 2022-10-23 23:00:24 +00:00
Kp cebc645e21 Pass std::span to net_udp_process_pdata 2022-10-23 23:00:24 +00:00
Kp 641a36b9fa Pass std::span to net_udp_process_pong 2022-10-23 23:00:24 +00:00
Kp 89bcb126ab Pass std::span to net_udp_process_ping 2022-10-23 23:00:24 +00:00
Kp 3fb11cecf1 Move net_udp_process_version_deny up
This allows the lower namespace{} block to change scope without changing
the namespace of net_udp_process_version_deny.
2022-10-23 23:00:24 +00:00
Kp 5bb61f71b5 Pass std::span to UDP_sequence_request_packet::build_from_untrusted 2022-10-23 23:00:24 +00:00
Kp d134645d1f Pass std::span to net_udp_process_dump 2022-10-23 23:00:24 +00:00
Kp c1a151fc8f Pass std::span to net_udp_check_game_info_request 2022-10-23 23:00:24 +00:00
Kp 6dfd405d90 Pass std::span to net_udp_process_version_deny 2022-10-23 23:00:24 +00:00
Kp e98650afb9 Pass std::span to net_udp_process_request 2022-10-23 23:00:24 +00:00
Kp 04af38638c Inline effect of object_rw_swap into multi_object_rw_to_object
Change from rewriting the object in place to byte-swap it, then copying
the byte-swapped values into the long term object to instead copy the
values into the object and perform byte-swapping as needed during the
copy.
2022-10-23 23:00:24 +00:00
Kp 23e75f3a45 Pass std::span to multi_do_fire 2022-10-23 23:00:24 +00:00
Kp 5f1877a4d6 multi_do_kill_*: use player number from network layer
The network layer already has the player number.  Use that instead of
reloading it from the message body.
2022-10-23 23:00:24 +00:00
Kp 22444d5377 multi_do_msgsend_state: use player number from network layer
The network layer already has the player number.  Use that instead of
reloading it from the message body.
2022-10-23 23:00:24 +00:00
Kp 8fd6ff2025 multi_do_escape: use player number from network layer
The network layer already has the player number.  Use that instead of
reloading it from the message body.
2022-10-23 23:00:24 +00:00
Kp 49698fbf86 multi_do_quit: use player number from network layer
The network layer already has the player number.  Use that instead of
reloading it from the message body.
2022-10-23 23:00:24 +00:00
Kp 064e971b28 multi_do_fire: use player number from network layer
The network layer already has the player number.  Use that instead of
reloading it from the message body.
2022-10-23 23:00:24 +00:00
Kp f6c45d0f6f Use enum class for multiplayer_command_t 2022-10-23 23:00:24 +00:00
Kp f47bcb5cbc Fix buffer overread at startup
Commit 5b7fb9c402 incorrectly removed the trailing null from
`g_descent_version`.  Add an explicit null, since list initialization
does not imply a null.

Fixes: 5b7fb9c402 ("Reduce use of quotes for passing vers_id defines")
2022-10-19 01:17:33 +00:00
Kp 7981fd1b17 Revert incorrect logic changes from std::ranges conversion
Commit e385ff1c3b switched various sites to use projection to extract
a value and avoid use of a predicate.  Two of the converted sites need
to use a predicate in order to test for a value being unequal to a
constant, rather than testing for equality as e385ff1c3b did.

Fixes: e385ff1c3b ("Use std::ranges::find_if instead of std::find_if")
2022-10-16 23:20:34 +00:00
Kp cb8303839c Revert incorrect robot collision logic change
Commit 37132ab887 rearranged the special rules around robot-vs-robot
vector intersection based on an obsolete comment from Descent 1.  In
Descent 2, robot-vs-robot collisions are always disabled, so that the
thief bot does not damage itself when flying past other robots.

Reported-by: Glumduk <https://github.com/dxx-rebirth/dxx-rebirth/issues/665>
Fixes: 37132ab887 ("Pass LevelSharedRobotInfoState in fvi_query")
2022-10-09 23:15:21 +00:00
Kp b3a34f424f Pass std::ranges::subrange to drive_letter_menu 2022-10-09 23:15:21 +00:00
Kp efa3f97a00 Pass std::ranges::subrange to briefing_menu 2022-10-09 23:15:21 +00:00
Kp d9c06e25c5 Pass std::ranges::subrange to multi_execute_save_game 2022-10-09 23:15:21 +00:00
Kp 31b2f1399c Pass std::ranges::subrange to find_hli_entry 2022-10-09 23:15:21 +00:00
Kp 515e0abe11 Pass std::ranges::subrange to PHYSFSX_findFiles 2022-10-09 23:15:21 +00:00
Kp 2c7ed3cfce Pass std::ranges::subrange to PHYSFSX_findabsoluteFiles 2022-10-09 23:15:21 +00:00
Kp 052dff6dae Pass std::ranges::subrange to menu selection functions 2022-10-09 23:15:21 +00:00
Kp 57de180a2e Pass std::ranges::subrange to PHYSFSX_checkMatchingExtension 2022-10-09 23:15:21 +00:00
Kp 90d3d82d8e Default disable VR side-by-side for OpenGL ES
VR requires glDrawBuffer, which Mesa OpenGL ES does not offer.  Default
VR to disabled for OpenGL ES users.  Users who want to try it anyway can
still set use_stereo_render=1 in the SCons environment.
2022-10-09 23:15:20 +00:00
Kp dac2fa22d7 Use std::ranges::subrange for choose_drop_segment
The full functionality of partial_range is not necessary.
2022-10-09 23:15:20 +00:00
Kp b16c5f7a7c Use std::ranges::subrange for sort_seg_children
The full functionality of partial_range is not necessary.
2022-10-09 23:15:20 +00:00
Kp 229766e9cb Use enum class for polygon_simpler_model_index
This type is stored with an off-by-one bias from the regular model
index, so use a distinct enum type to avoid implicit conversions.
2022-10-09 23:15:20 +00:00
Kp 22abc6d4d8 Assert size of serialized weapon_info structure
These are read from a packed binary file shipped with the game, so their
size must not change.  If the size does change, later fields will be
loaded from the wrong offset, causing the in-memory values to be
incorrect.
2022-10-09 23:15:20 +00:00
Kp d5d103bc93 Simplify bm_read_weapon last_model_num handling
The existing handling always wrote to slot 0, but did so in a convoluted
way.  The variable names suggest this was not intended, but no one has
ever reported it as broken, and some otherwise valid data files may
depend on this quirk.
2022-10-09 23:15:20 +00:00
Kp 6ecbd6533a Simplify bm_read_robot last_model_num handling
The existing handling always wrote to slot 0, but did so in a convoluted
way.  The variable names suggest this was not intended, but no one has
ever reported it as broken, and some otherwise valid data files may
depend on this quirk.
2022-10-09 23:15:20 +00:00
Kp 43e1c841f0 Pass polymodel& to polymodel_read 2022-10-09 23:15:20 +00:00
Kp acae546a90 Pass polymodel& to draw_model_picture, draw_polygon_model 2022-10-09 23:15:20 +00:00
Kp 910ac7fd4a Use template alias for per-team arrays 2022-10-09 23:15:20 +00:00
Kp f61db8ae7a Make enumerate() default to std::size_t for index_type
Change from `uint_fast32_t` to `std::size_t` for consistency with how
arrays are typically indexed.

Change the decltype() lookup to use a non-template function for the
fallback case.

Move the remove_reference logic into the caller, to allow fewer
instantiations of `array_index_type`.
2022-10-09 23:15:20 +00:00
Kp 9716d42ea0 Use enum class for pig_hamfile_version 2022-10-09 23:15:20 +00:00
Kp e385ff1c3b Use std::ranges::find_if instead of std::find_if
std::ranges::find_if permits use of a sentinel instead of a full
iterator, and supports std::ranges::find as an alternative to certain
simple uses of std::find_if.

Where possible, use the form that takes a range, rather than the form
that takes two iterators.

Add a declared, but not defined, default constructor for
self_return_iterator to satisfy the standard library's concept
`semiregular`, which insists that sentinels be default-constructible,
even for those functions that never need to do so.

Add a defined, but unused, operator++(postfix) for zip_iterator to
satisfy a standard library concept for `forward_iterator`.
2022-10-09 23:15:20 +00:00
Kp f754b2d33a Avoid unnecessarily copying player name for display
If the player's name is presented without decoration, then it can be
rendered directly from the callsign buffer.  It only needs to be copied
to a temporary buffer if it will be decorated to reflect use of automap
or in-game messaging.
2022-10-09 23:15:20 +00:00
Kp 0ebcc64ac5 Test whether change_filename_extension succeeded before using its output 2022-10-09 23:15:20 +00:00
Kp a9142bb65a Use std::span for change_filename_extension arguments 2022-10-09 23:15:20 +00:00
Kp 7c0fb7b12a Use std::span for load_bitmap_replacements argument level_name 2022-10-09 23:15:20 +00:00
Kp 38adcc7729 Simplify change_filename_extension
The called function skipped over a leading dot in the extension.  Remove
that logic and change all callers not to supply a leading dot.
2022-10-09 23:15:20 +00:00
Kp 9c4c49fe5e Return std::unique_ptr from d_strdup 2022-10-09 23:15:20 +00:00
Kp fbc184500d Use explicitly defaulted operator== for vms_vector 2022-10-09 23:15:19 +00:00
Kp 37701cf61f Remove unnecessary explicit definition of weapon_index::operator!= 2022-10-09 23:15:19 +00:00
Kp 428fad33c3 Fix clang-14 operator== ambiguity
clang-14 fails with:

```
similar/main/net_udp.cpp:4381:11: error: use of overloaded operator '!=' is ambiguous (with operand types 'exact_type<dcx::player>' and 'exact_type<const dcx::player>')
            if (&i != &self)
                ~~ ^  ~~~~~
common/include/pack.h:28:17: note: candidate function
    constexpr bool operator==(const T *rhs) const { return p == rhs; }
                   ^
common/include/pack.h:28:17: note: candidate function (with reversed parameter order)
1 error generated.
```

gcc handles the old form without error.
2022-10-09 23:15:19 +00:00
Kp cd3c88f4b6 Avoid copying level filename unnecessarily 2022-10-09 23:15:19 +00:00
Kp fc4157f56f Fix MacOS clang build of similar/2d/font.cpp
clang-14 on OSX, but not clang-14 on x86_64-pc-linux-gnu, fails
class template argument deduction when given:

```
	char *c1 = initializer();
	const char *c2 = c1 + 1;
	std::span{c1, c2};
```

clang correctly refuses to match this to `std::span(pointer, pointer)`,
but fails to find the constructor `std::span(iterator, sentinel)`.

Work around this by changing the type of the sentinel from
`const uint8_t *` to `color_palette_index *` (an alias of `uint8_t *`).

Reported-by: Kreeblah <https://github.com/dxx-rebirth/dxx-rebirth/issues/664>
2022-10-02 19:51:36 +00:00
Kp 5b7fb9c402 Reduce use of quotes for passing vers_id defines
Windows shells interpret quoting differently from Linux shells, causing
some of the generated strings to have ugly escape sequences in them.
Switch to passing the defined values as lists of character codes, so
that no quoting is needed.  This makes the command line uglier, but
produces more readable strings in the generated program.
2022-10-02 19:51:36 +00:00
Kp 90879d0796 Pass std::span to con_scrub_markup 2022-10-02 19:51:36 +00:00
Kp 3379078f04 Pass std::span to PHYSFSX_puts 2022-10-02 19:51:36 +00:00
Kp f3fae646f9 Pass std::span to warning_puts 2022-10-02 19:51:36 +00:00
Kp 53c1550254 Remove special case for 0 argument err_printf
Fix the remaining sites that were redirected by this.  Remove the
redirection macro.
2022-10-02 19:51:36 +00:00
Kp 0409e75278 Pass std::span to err_puts 2022-10-02 19:51:36 +00:00
Kp e0123dead5 Remove special case for 0 argument PHYSFSX_printf
Fix the remaining sites that were redirected by this.  Remove the
redirection macro.
2022-10-02 19:51:36 +00:00
Kp 01c07156bd Remove special case for 0 argument HUD_init_message
Fix the one remaining site that was redirected by this.  Remove the
redirection macro, so that the literal and variadic forms can have
differing types for their string field.
2022-10-02 19:51:36 +00:00
Kp f3d4dff941 Use enum class for clipping_code
Adjust code_window_point to use the same masks as clipping_code.
Previously, it had top and bottom swapped.  However, since its output
was only ever compared for equality to 0, this transposition should not
affect the observable behavior.
2022-10-02 19:51:35 +00:00
Kp 1808b6badd Use enum class for projection_flag 2022-10-02 19:51:35 +00:00
Kp e499dd55f7 Use std::span for piggy_write_pigfile argument filename 2022-10-02 19:51:35 +00:00
Kp aaac0e69fa Use std::span for piggy_new_pigfile argument pigname 2022-10-02 19:51:35 +00:00
Kp 1101b02f84 Use std::span for PlayMovie argument subtitles 2022-10-02 19:51:35 +00:00
Kp 73bcfb6d63 Simplify ogl_ubitblt_i GL array initialization
- Avoid zero-filling arrays that can be directly initialized with real
  values.
- Hold color_array const so it can be stored statically.
2022-10-02 19:51:35 +00:00
Kp eca189e8aa Use enum class for SoundOffset
Change piggy_register_sound to take the sound offset as a parameter,
rather than assuming the caller will set SoundOffset accordingly.

Remove a spurious sound reset in piggy_register_bitmap.  Based on the
duplicated comment, this was probably incorrectly copied from
piggy_register_sound, where it made sense, into piggy_register_bitmap,
where it does not.
2022-10-02 19:51:35 +00:00
Kp 14bf2dc59a Pass std::span to piggy_register_bitmap 2022-10-02 19:51:35 +00:00
Kp f0d118ed42 Use std::span for PHYSFSX_fgets 2022-10-02 19:51:35 +00:00
Kp 8fe9b8322d Check return value of PHYSFSX_fgets 2022-10-02 19:51:35 +00:00
Kp a55579bb8f Flatten net_udp call chain for ntstring::copy_out 2022-10-02 19:51:35 +00:00
Kp 9fe23b7dce Rework loading weapon reorder values
- Document the logic for resetting the values to default
- For D1: load the untrusted values directly into an array, instead of
  loading them to temporaries and then copying the temporaries to the
  array.
- For D2: optimize the read by loading 22 bytes in a single step,
  instead of loading single bytes 22 times.
2022-10-02 19:51:35 +00:00
Kp 4fe8d6dcaf Use std::span for net_udp_prepare_*_game_info 2022-10-02 19:51:35 +00:00
Kp 8c08dcc20f Merge branch 'refs/pull/633/head' into master 2022-10-02 19:50:49 +00:00
Kp 9a8c49ccbf Fix OpenGL ES build on SDL1
The preceding commit breaks OpenGLES + SDL1 support, by referencing
SDL_GL_* constants that are new in SDL2.  Add a preprocessor guard to
skip over the new constants when using SDL1.

Fixes: c90ac3e611 ("Fix OpenGL ES build on SDL2.")
2022-10-02 19:50:32 +00:00
Kp e3faab0899 Use alias template per_player_array for arrays that are MAX_PLAYERS long
This removes the need to repeat MAX_PLAYERS in every usage, and prepares
for a future change to use enumerated_array instead of std::array.
2022-09-24 17:47:53 +00:00
Kp 0ed90715b6 Cache operator[] result in render_compare_context_t 2022-09-24 17:47:53 +00:00
Kp e377ac3caf Pass std::span to convert_pattern_array 2022-09-24 17:47:53 +00:00
Kp 0cb9ab58b0 Pass std::span to print_pattern_array 2022-09-24 17:47:53 +00:00
Kp 6de5587a06 Pass std::span to nd_read_string 2022-09-24 17:47:53 +00:00
Kp f91d0c404c Pass std::span to set_briefing_filename 2022-09-24 17:47:53 +00:00
Kp 9d238eedf8 Pass std::span to callsign_t::copy 2022-09-24 17:47:53 +00:00
Kp 294a78a1aa Pass std::span to powerup_basic_str 2022-09-24 17:47:53 +00:00
Kp ea5d0136dc Pass std::span to msgbox_warning 2022-09-24 17:47:53 +00:00
Kp 6d0a5f5783 Pass std::span to location_value_wrapper::prepare_buffer 2022-09-24 17:47:53 +00:00
Kp 56a68f3c63 Pass std::span to con_force_puts 2022-09-24 17:47:53 +00:00
Kp 27ec8f41ba Pass std::span to con_add_buffer_line 2022-09-24 17:47:52 +00:00
Kp ae5e5c699a Use std::array for console_buffer::line 2022-09-24 17:47:52 +00:00
Kp b1da47a34b Compare d1 extra pig in place
Instead of creating a copy, modifying the copy, and comparing to it, use
std::span to pass down the maximum allowed length for comparison.
2022-09-24 17:47:52 +00:00
Kp c464ddeae1 Sanitize control center triggers on load
Descent 2: Vertigo level 10 has invalid data in its control center
triggers.  Sanitize invalid data at load to avoid problems in
memory-poisoning builds.
2022-09-24 17:47:52 +00:00
Kp ad7057be87 Add hack for case mismatch in Vertigo robot movies
PhysFS 3 is case-sensitive for movie filename lookup.  The consequence
of this was first reported in [1].  In [2], @icculus stated this was a
bug in PhysFS 3 that would be fixed in PhysFS 3.0.2.  However, [3] and
[4] assert that the fix was never included.  The existence of [5] seems
to support this.  The original problem was reported in 2019.  As of
2022, user @AlumiuN, running PhysFS 3.0.2, is affected.  Therefore, this
commit adds code to detect the relevant robot movies and adjust the case
in the Rebirth code.

[1]: https://github.com/dxx-rebirth/dxx-rebirth/issues/379
[2]: https://github.com/dxx-rebirth/dxx-rebirth/issues/379#issuecomment-389400528
[3]: https://github.com/dxx-rebirth/dxx-rebirth/issues/379#issuecomment-462083489
[4]: https://github.com/dxx-rebirth/dxx-rebirth/issues/379#issuecomment-477790175
[5]: https://github.com/dxx-rebirth/dxx-rebirth/issues/644
2022-09-24 17:47:52 +00:00
Kp 9fa97573c4 Move RoboFile to briefing scope 2022-09-24 17:47:52 +00:00
Kp af8efbf830 Clear GameSounds, SoundOffset in bulk 2022-09-24 17:47:52 +00:00
Kp 9cad6c0eaa Use std::span for sound_slot samples 2022-09-24 17:47:52 +00:00
Kp ceef174418 Cache strlen call result 2022-09-24 17:47:52 +00:00
Kp 5eb41816f3 Use std::span for CREDITS_FILE 2022-09-24 17:47:52 +00:00
Kp a79ed84112 Use std::span in location_wrapper 2022-09-24 17:47:52 +00:00
Kp e4e8259253 Reduce scope of callback_handler newpath
If select_file_recursive is not called again, then the handler returns
without reading newpath.  Skip defining it if it will not be read.
2022-09-24 17:47:52 +00:00
Kp a48e6ab56b Pass std::span to _g3_draw_tmap 2022-09-24 17:47:52 +00:00
Kp ad8325b63c Pass std::span to _g3_draw_tmap_2 2022-09-24 17:47:52 +00:00
Kp 491d23e2d9 Pass std::span to _g3_draw_poly 2022-09-24 17:47:52 +00:00
Kp 97f0c5a6d0 Pass std::span to decode_data 2022-09-24 17:47:52 +00:00
Kp 0b91da6d9c Use span methods to construct dxx_sendto input 2022-09-24 17:47:52 +00:00
Kp 9faa3d912d Pass std::span to pcx_encode_line 2022-09-24 17:47:52 +00:00
Kp e69f219539 Pass std::span to g3_validate_polygon_model 2022-09-24 17:47:52 +00:00
Kp 928834fdf8 Pass std::span to g3_init_polygon_model 2022-09-24 17:47:52 +00:00
Kp 76643ed432 Change trace_segs not to recompute children on every pass
`oldsegnum` is `const`, so the address computed from it cannot change.
Lift the computation of `auto &children` out of the loop.

Reduce the scope of `biggest_val`, since it does not need to outlive the
loop.
2022-09-24 17:47:52 +00:00
Kp d797072596 Make vector magnitude constant in more cases
Introduce a helper to obtain both the magnitude of a vector and the
corresponding normalized vector.  Use it to capture both values as const
when possible.
2022-09-24 17:47:52 +00:00
Kp f599ad90b4 Make create_omega_blobs::omega_delta_vector const 2022-09-24 17:47:52 +00:00
Kp 781ca0c97d Reorder endlevel exit_side initialization to fix -Wmaybe-uninitialized
gcc-11.3.0 issues a -Wmaybe-uninitialized warning for `exit_side`.
Reorder the code to eliminate this warning.  Also, fix a potential
out-of-bounds read if `matt_find_connect_side` returned `side_none`.
Before, this would lead to a read of `Side_opposite[side_none]` before
the test that `entry_side` is not `side_none`.  Now, if
`matt_find_connect_side` returns `side_none`, the read of
`Side_opposite` is skipped and logic goes directly to finding a proper
exit side.
2022-09-24 17:47:52 +00:00
Kp d1354911fc Reorder nm_string_inputbox to avoid -Wmaybe-uninitialized
gcc-11.3.0 with -Og may issue a -Wmaybe-uninitialized warning for `w1`
because it fails to prove that every path sets the variable.  Reorder
the logic to use a local lambda to ensure that every path assigns a
value.
2022-09-24 17:47:52 +00:00
Kp 2ecad00e90 Pass std::span to load_palette 2022-09-24 17:47:52 +00:00
Kp 805d71de6b Move Shareware_level_names,Registered_level_names to dumpmine.cpp
They are only used in this file, so move them there and make them
static.
2022-09-24 17:47:52 +00:00
Kp 8f1055ca6b Use std::span for poison helper functions 2022-09-24 17:47:51 +00:00
Kp 17a0452001 Use std::span for nm_item_input 2022-09-24 17:47:51 +00:00
Kp e0300e1e30 Pass std::span to dispatch_table::send_data 2022-09-24 17:47:51 +00:00
Kp 2d46e020e0 Return length change from copy_from_ntstring
Switch from passing length by-reference to instead passing it in by
value and returning the change.  This lets callers keep the length in a
register.
2022-09-24 17:47:51 +00:00
Kp 95bb58a2fe Convert PUT_INTEL_* uses to operator[]
Switch away from operator+(uint8_t *, std::size_t), since future work
will use a type that defines operator[] and not operator+.
2022-09-24 17:47:51 +00:00
Kp b8ed30235c Remove Multi_is_guided; handle setup directly
`Multi_is_guided` is only enabled in one place.  One code path set up
Guided_missile[] for the local player, and a different path handled
network players.  Remove `Multi_is_guided` and rearrange such that a
single site handles both local and network players.
2022-09-24 17:47:51 +00:00
JohnnyonFlame c90ac3e611 Fix OpenGL ES build on SDL2. 2022-09-18 21:35:55 -03:00
Kp ad46235b67 Avoid spinning in multiplayer when the game window is hidden
When the host exits the game, guests switch the game window to be
non-visible, and raise a dialog box stating `Host has left the game!`.
Prior to this change, the guests would then busy loop until the dialog
was dismissed.  With this change, the game will sleep for each idle
event, minimizing CPU use during the period waiting for the player to
acknowledge the dialog box.
2022-09-11 17:00:45 +00:00
Kp 45362ac37b Fix guest loading of multiplayer saved games
Using `sav_objnum` caused the player to be restored into the object slot
of the pre-load level, in the object table of the post-load level.  This
was harmless when the slots were the same, and wrong when they were not.
It became noticeably wrong when more player data was moved into the
object.  After those changes, the player's data was stored into the
correct post-load slot, but the ship was assigned to the pre-load slot.

Remove the incorrect slot switch, and add an assert that the object
being overwritten is a player ghost.  With the incorrect switch present,
this assert will catch most (but not all)[1] cases of the incorrect
restore.  With the incorrect switch removed, this assert succeeds.

[1] In the unlikely case that the post-load slot was a player start, but
for a different player, the assert could succeed despite the slot
mismatch bug.  In the common case, the post-load slot would not be a
start of a different player; it would either be the correct player slot,
in which case `sav_objnum` was harmless, or it would be some other
object, such as a robot.
2022-09-11 17:00:45 +00:00
Kp d9f30ba10c Avoid spinning in net_udp_request_poll
If the guest is slow to respond, the host would enter a busy loop
polling for the guests to be ready.  Mitigate the CPU load by sleeping
for 50ms when guests are not yet ready.
2022-09-11 17:00:45 +00:00
Kp 232c648024 Add Windows version resource for Windows build 2022-09-11 17:00:45 +00:00
Kp 11a400ab8f Move upid sizes to constexpr variable 2022-09-11 17:00:45 +00:00
Kp 70fd424599 Split net_udp_process_game_info to light/heavy variants
The two paths had nothing in common, so split them into separate
functions and call the appropriate version from each caller.
2022-09-11 17:00:44 +00:00
Kp 575bfe8a69 Use enum class for tracker_game_id 2022-09-11 17:00:44 +00:00
Kp 8f847c16bb Use std::span for csocket_data_buffer 2022-09-11 17:00:44 +00:00
Kp 763f1d4902 Use std::span for socket_data_buffer 2022-09-11 17:00:44 +00:00
Kp eb8a7d8186 Use std::span for multi::send_data_direct 2022-09-11 17:00:44 +00:00
Kp 53770489d8 Use std::span for net_udp_noloss_add_queue_pkt 2022-09-11 17:00:44 +00:00
Kp 2589ba9c60 Ignore invalid MULTI_START_TRIGGER messages 2022-09-11 17:00:44 +00:00
Kp 0512ea8d65 Use enum class for upid 2022-09-11 17:00:44 +00:00
Kp d32fc7acab Use enum class for kick_player_reason 2022-09-11 17:00:44 +00:00
Kp 4cf1eb328f Use std::array for prepare_kill_name storage 2022-09-11 17:00:44 +00:00
Kp 0a8bf6bfa8 Remove redundant test in multi_do_finish_game
This is only called from the dispatch switch which checked the type.
There is no need to check the type again.
2022-09-11 17:00:44 +00:00
Kp dac7b13f65 Pass optional parameters to multi_do_fire from caller
Remove the multi_do_fire branches that check the message type.  Delegate
those checks to the caller, so that multi_do_fire can work with the
common initial sequence of the three messages.
2022-09-11 17:00:44 +00:00
Kp 366b048879 Merge commit 'refs/pull/657/head' into master 2022-08-23 02:13:01 +00:00
Kp 0a1758f44f Ignore excess hostages during scoring
Descent 2 secret levels allow a player to rescue hostages that are not
counted in `total_hostages`, so a player can exit with more hostages
saved than were in the mine.  Change the scoring logic not to penalize a
player for saving these unaccounted hostages.
2022-08-22 01:24:49 +00:00
Kp cd09a742a0 Initialize aip->CURRENT_GUN in robot setup
In non-memory-poison builds, the zero initialization of the new object
will suffice to cover this.  In memory-poison builds, the new object
will be reset to a poison value, so the member must be given a
reasonable value here.
2022-08-22 01:24:49 +00:00
Kp c64a584bfd Use enum class for robot_gun_number
Validate gun numbers on loading object data.  Factor out and normalize
the logic for advancing to a robot's next gun.
2022-08-22 01:24:49 +00:00
Kp 4e66bff3f6 Fix SDL-only build of game.cpp
Fixes: 8be306efa7 ("Use enum class for cockpit_mode_t")
2022-08-22 01:24:49 +00:00
Kp 1fb55eebc2 Use enum class for robot_animation_state 2022-08-22 01:24:49 +00:00
Kp 3ea0cc7053 Store Pof_addr at local scope
Pass it to called functions as needed.
2022-08-22 01:24:49 +00:00
Kp 6b7ba83a00 Move anim_angs into local scope, since it is copied out later 2022-08-22 01:24:49 +00:00
Kp 99577c4296 Simplify pof_read_string
The resulting string is discarded, so change it to skip without copying.
2022-08-22 01:24:49 +00:00
Kp a41908dece Move Pof_file_end to local scope
Rely on the extent in std::span for called code that needs to know
bounds.
2022-08-22 01:24:49 +00:00
Kp 3e13dcdf19 Use std::span to bound read_model_guns valid bytes 2022-08-22 01:24:49 +00:00
Kp 15e8ceeaa4 Use std::span to bound read_model_file valid bytes 2022-08-22 01:24:49 +00:00
Kp 42caec7e58 Use std::span for pof reading functions 2022-08-22 01:24:49 +00:00
Kp c5c5e8ea39 Simplify pof_read_angs
The caller passes a length of 1, so inline that and simplify the
function.
2022-08-22 01:24:49 +00:00
Kp 69579df368 Simplify pof_read_short
Use the general little-endian helper.
2022-08-22 01:24:49 +00:00
Kp 87c79206e8 Simplify pof_cfread
All callers pass a value of 1 for one of the two length terms, so inline
that and eliminate the multiplication.
2022-08-22 01:24:49 +00:00
Kp bfb7ed7efc Simplify pof_read_vecs
All callers pass a count of 1, so inline that and eliminate the loop.
2022-08-22 01:24:49 +00:00
Tylor 6fee36638d Feat: Pitch unlocker 2022-08-21 16:16:40 -05:00
Kp 0d045ae3da Fix Windows net_udp build
Convert the RAIIsocket to a simple SOCKET before passing it to FD_SET.
Otherwise, the build fails with:

```
similar/main/net_udp.cpp: In function 'int {anonymous}::udp_general_packet_ready(dcx::{anonymous}::RAIIsocket&)':
similar/main/net_udp.cpp:969:2: error: use of deleted function 'bool dcx::{anonymous}::RAIIsocket::operator==(T) const [with T = long long unsigned int]'
  969 |  FD_SET(sock, &set);
      |  ^~~~~~
similar/main/net_udp.cpp:493:29: note: declared here
  493 |  template <typename T> bool operator==(T) const = delete;
      |                             ^~~~~~~~
```
2022-08-16 03:15:04 +00:00
raptor 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
2022-08-09 22:10:13 -06:00
Kp fb75a7900c Pass std::span to multi_do_message 2022-07-30 17:42:59 +00:00
Kp 81ab68e0f6 Pass std::span to multi_do_player_inventory 2022-07-30 17:42:59 +00:00
Kp 31b8d98e22 Pass std::span to multi_do_kill_client 2022-07-30 17:42:59 +00:00
Kp e76cefd846 Pass std::span to multi_do_kill_host 2022-07-30 17:42:59 +00:00
Kp 43c86b94af Split multi_do_kill to multi_do_kill_host+multi_do_kill_client
The kill messages have different lengths and conditional processing
based on whether the message is MULTI_KILL_CLIENT or MULTI_KILL_HOST.
Split the two into separate functions to simplify the implementation of
each.
2022-07-30 17:42:59 +00:00
Kp 127a1f15e6 Pass std::span to multi_do_gmode_update 2022-07-30 17:42:59 +00:00
Kp b24d61cd0a Pass std::span to multi_do_msgsend_state 2022-07-30 17:42:59 +00:00
Kp c5eeaa48cd Pass std::span to multi_do_bounty 2022-07-30 17:42:59 +00:00
Kp da138757e6 Pass std::span to multi_do_kill_goal_counts 2022-07-30 17:42:59 +00:00
Kp 79683690bd Pass std::span to multi_do_heartbeat 2022-07-30 17:42:59 +00:00
Kp 4893196138 Pass std::span to multi_do_restore_game 2022-07-30 17:42:59 +00:00
Kp 4e42dacd23 Pass std::span to multi_do_save_game 2022-07-30 17:42:59 +00:00
Kp 96a260cea0 Pass std::span to multi_do_hostage_door_status 2022-07-30 17:42:59 +00:00
Kp 55bbc5f599 Pass std::span to multi_do_create_robot_powerups 2022-07-30 17:42:59 +00:00
Kp 4ce39a399e Pass std::span to multi_do_boss_create_robot 2022-07-30 17:42:59 +00:00
Kp c575283c5e Pass std::span to multi_do_boss_stop_gate 2022-07-30 17:42:59 +00:00
Kp b820098103 Pass std::span to multi_do_boss_start_gate 2022-07-30 17:42:59 +00:00
Kp 2b4dd444ca Pass std::span to multi_do_boss_cloak 2022-07-30 17:42:59 +00:00
Kp 6ab2068a82 Pass std::span to multi_do_boss_teleport 2022-07-30 17:42:59 +00:00
Kp 202e3309a7 Pass std::span to multi_recv_escort_goal 2022-07-30 17:42:59 +00:00
Kp cab6900f29 Pass std::span to multi_do_flags 2022-07-30 17:42:59 +00:00
Kp 53d5c296ff Pass std::span to multi_do_effect_blowup 2022-07-30 17:42:59 +00:00
Kp 2cb7de84b1 Pass std::span to multi_do_start_trigger 2022-07-30 17:42:59 +00:00
Kp 802b9bd37e Pass std::span to multi_do_trigger 2022-07-30 17:42:59 +00:00
Kp ff8e2090ab Pass std::span to multi_do_score 2022-07-30 17:42:59 +00:00
Kp 980b3080ce Pass std::span to multi_do_robot_fire 2022-07-30 17:42:59 +00:00
Kp fa0f7cef11 Pass std::span to multi_do_release_robot 2022-07-30 17:42:59 +00:00
Kp d4b047bb02 Pass std::span to multi_do_robot_position 2022-07-30 17:42:59 +00:00
Kp 0036b91084 Pass std::span to multi_do_claim_robot 2022-07-30 17:42:59 +00:00
Kp eb5880ac93 Pass std::span to multi_do_ranking 2022-07-30 17:42:59 +00:00
Kp 8cb20bb3ae Pass std::span to multi_do_finish_game 2022-07-30 17:42:59 +00:00
Kp 73361b9ae0 Pass std::span to multi_do_orb_bonus 2022-07-30 17:42:59 +00:00