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")
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")
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")
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.
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.
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.
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.
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`.
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`.
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.
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.
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>
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.
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.
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.
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.
- 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.
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.")
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.
`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.
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.
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.
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.
`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.
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.
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.
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.
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.
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.
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.
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;
| ^~~~~~~~
```
- 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
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.