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.
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`.
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.
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.
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
Python3 does not expose an attribute `message` on `Exception`. However,
`Exception` can implicitly convert to a string, and produces the
message. Switch to that.
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`.
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>
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.
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.
`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`.
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")
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")
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.
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.
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.
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.
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.