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.
Since this should never be invoked, simplify the definition. The new
version is slightly less informative in case a logic error causes it to
be called, but is far shorter and easier to understand.
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`.
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.
Commit d2478d0708 made support for C++17 fallthrough mandatory, and
should have deleted this test. Delete it now.
Fixes: d2478d0708 ("Require support for C++17 attribute [[fallthrough]]")
Win32 aliases `size_t` to `unsigned int`, causing
`static_cast<size_t>(V)` to be a useless cast when `V` has type
`unsigned int`. Switch to using direct initialization, which is not a
cast and so does not trigger a warning, but does produce the correct
type. This form disallows narrowing, so inputs that might change in
value as a result of the conversion are an error. Since this is a
sanity checking macro, that is a useful safety measure.
Reported-by: AlumiuN <https://github.com/dxx-rebirth/dxx-rebirth/issues/678#issue-1437577368>
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>
This never worked, but was committed to git in the hope it would be
useful for someone who wanted to finish it. In the 5.5 years since
then, the closest to that has been one user who requested Visual Studio
2019 support[1], but went silent after reporting that unspecified errors
occurred. The error messages were never shared.
Remove these project files, since they are not useful, and have caused
at least one report where the reporter incorrectly attached the stub
Visual Studio 2017 dxxsconf.h, instead of attaching the dxxsconf.h
generated by the build for which the reporter wanted assistance.
[1]: https://github.com/dxx-rebirth/dxx-rebirth/issues/607
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.