Commit Graph

6286 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