Commit graph

6436 commits

Author SHA1 Message Date
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
Kp 5f39ffc2f5 Use enum class for sound_channel 2022-12-17 13:16:28 +00:00
Kp 57a9c384e8 Return color from redraw_messagestream
This avoids requiring it to be in memory.
2022-12-10 18:09:54 +00:00
Kp afb7406127 Pass std::span to callsign_t::copy_lower 2022-12-10 18:09:54 +00:00
Kp 1b92a56648 Use unique_ptr to manage digi_sound allocation 2022-12-10 18:09:54 +00:00
Kp dbab38b8ea Centralize and defer robot gun point setup
Use a std::optional<vms_vector> to store the gun point and a flag of
whether the gun point is valid.  This allows deferring computation of
the gun point until it is needed, and avoids recomputing it once it has
been computed.  This also fixes an obscure case where a robot with its
gun positioned at 0,0,0 would be incorrectly considered too far away.
2022-12-02 04:09:20 +00:00
Kp 39b009744e Remove unnecessary reload of robptr 2022-12-02 04:09:20 +00:00
Kp d1b55a15ac Pass robot_info to move_towards_segment_center 2022-12-02 04:09:20 +00:00
Kp c3eda53fb0 Pass robot_info to move_towards_vector 2022-12-02 04:09:20 +00:00
Arne de Bruijn cce8acf908 Make sure gun point is calculated when firing
Gun point calculation is skipped in do_ai_frame if
dist_to_player >= 200 but a bot might still fire a homing weapon
if it is further away.
Add extra call to calc_gun_point in ai_do_actual_firing_stuff when
a homing weapon is fired without visibility to make sure a valid
gun point is used.

This is an original game bug, shown for example in this video:
https://www.youtube.com/watch?v=2dP51znGh7o
2022-11-28 00:08:43 +01:00
Kp 9086327de1 Fix generate-kconfig-udlr.py for Python3
Python3 does not expose an attribute `message` on `Exception`.  However,
`Exception` can implicitly convert to a string, and produces the
message.  Switch to that.
2022-11-13 21:17:23 +00:00
Kp 211d6167b2 Inline object_create_muzzle_flash into callers
object_create_muzzle_flash delegated to
object_create_explosion_without_damage, adding one parameter that
callers ought to provide instead.  Inline object_create_muzzle_flash into
callers and change them to provide `Vclip`.
2022-11-13 21:17:23 +00:00
Kp 6da1956337 Defer allocating resample output until replicateChannel begins
This allows `stage1` to be freed before `output` is allocated.
2022-11-12 19:31:52 +00:00
Kp 754ecafee5 Use unique_span to provide a span over allocated memory 2022-11-12 19:31:52 +00:00
Kp 5c6cb90b62 Use fill_n in sound resample replicateChannel
Prefer a standard library function over an open-coded loop.
2022-11-12 19:31:52 +00:00
Kp 14e7b2a4ee Make sound resample coefficients constant 2022-11-12 19:31:52 +00:00
Kp 48fd582698 Simplify filter_fir max_idx
Observe that `nn` is at most `signal.size() - 1`, which occurs on the
final pass of the loop.  Therefore, `std::min` will always pick `nn`
instead of `signal.size() - 1`, so simplify out the call.
2022-11-12 19:31:52 +00:00
Kp fcfd237954 Use std::span for sound resample buffers 2022-11-12 19:31:52 +00:00
Kp 10d0bbc4e8 Adjust filter_fir to work with unsigned lengths 2022-11-12 19:31:52 +00:00
Kp 527263d81e Allocate output buffer in filter_fir
Take the length from the caller and allocate it locally, rather than
requiring the caller to provide the buffer.
2022-11-12 19:31:52 +00:00
Kp 7ddc095c9c Fix misspelling in filter_fir comment 2022-11-12 19:31:52 +00:00
Kp f6eb8edd59 Remove unnecessary zero fill in upsample
`std::make_unique` already value-initializes the array.
2022-11-12 19:31:52 +00:00
Kp d21ea16d2b Allocate output buffer in upsample
Take the length from the caller and allocate it locally, rather than
requiring the caller to provide the buffer.
2022-11-12 19:31:52 +00:00
Kp 4eff9d3ffc Merge master into pull/651
Pull #651 predates the switch to C++20.  Pull in master to provide the
C++20 support needed by some tuning commits.
2022-11-12 19:02:17 +00:00
Kp e42cd300af Use auto & for coeffs, since it is never changed 2022-11-12 19:00:21 +00:00
Kp 713b3baf99 Remove unnecessary commented variable 2022-11-12 19:00:21 +00:00
Kp 7a6870d610 Move buffer pointer directly from unique_ptr to RAIIMix_Chunk
Avoid transferring the pointer into a local variable, so that there are
no points where a stack unwind could lose the pointer to the allocated
memory.
2022-11-12 19:00:21 +00:00
Kp fe5dacb759 Move resample code into namespace dcx 2022-11-12 19:00:21 +00:00
Kp 30500cbaa8 Add inttypes.h to bmread.cpp for PRIuFAST32
bmread.cpp uses PRIuFAST32, so it should include inttypes.h to get the
definition of this macro.  Some platforms happened to include inttypes.h
as an implementation detail, but for portability, it needs to be
included explicitly in this file.

Reported-by: AlumiuN <https://github.com/dxx-rebirth/dxx-rebirth/issues/678#issuecomment-1304962448>
2022-11-10 02:04:09 +00:00
Kp cb53ce8c0e Replace strcpy with std::move in multi_message_input_sub
The documentation for `strcpy` states in part:

```
The strings may not overlap
```

However, for this use, the strings do overlap.  Switch to `std::move`,
which is documented to handle this so long as the destination iterator
is outside the source range, which it will be for this use.
2022-11-08 02:55:09 +00:00
Kp 1e093bacae Preserve trailing space in ": " in a long message
Previously, the `strcpy` would preserve the `:`, but overwrite the ` `.
This is probably not what the player wants, since the first `": "` in
the line can direct a message to specific recipients, but a bare `":"`
will not.  As a result, the old system would send the first part
privately, but then mangle the directed-message prefix such that
subsequent parts were sent publicly.  Switch to preserve the trailing
space so that the `": "` retains its special meaning in subsequent
messages.
2022-11-08 02:55:09 +00:00
Kp 1a2ca399b3 Use iterators to examine Network_message 2022-11-08 02:55:08 +00:00
Kp ad8f75b0dd Cache Player_num result in multi_message_input_sub
Save a reference to the appropriate multi_sending_message for reuse
later.
2022-11-08 02:55:08 +00:00
Kp 98cb7bf923 Use size_t for multi_message_index
As an index, it can never be negative.
2022-11-08 02:55:08 +00:00
Kp e2c61f6aee Pass context to init_morphs 2022-11-07 01:59:34 +00:00
Kp 70505e69d0 Use enum class for delta_light_index 2022-11-07 01:59:34 +00:00
Kp e9b4711d87 Inline object_create_explosion into callers
`object_create_explosion` delegated to
`object_create_explosion_without_damage`, adding one parameter that
callers ought to provide instead.  Inline `object_create_explosion` into
callers and change them to provide `Vclip`.
2022-11-07 01:59:34 +00:00
Kp 8d329c0f54 Pass std::span to net_udp_process_game_info_light 2022-11-07 01:59:34 +00:00
Kp b8cc509cbe Fix tracker upid values
Commit 0512ea8d65 changed the value of the tracker_ upid codes when
they were converted from `#define` statements with explicit values to
`enum` members with implicit values.  The tracker program is maintained
separately, and continues to use the old values, so games with this
commit use the wrong numbers when requesting service from the tracker.
Switch the upid codes back to their previous values, and add a warning
comment about the special compatibility concerns for tracker upid
codes, relative to game-to-game codes.

Fixes: 0512ea8d65 ("Use enum class for upid")
2022-11-07 01:59:34 +00:00
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