Commit graph

12324 commits

Author SHA1 Message Date
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 3f65ae0ca3 Replace PHYSFSX_read* macros with a template function object
This produces better error messages on misuse.
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 0c8ab5d70d Remove unnecessary explicit definition of valptridx<T>::ptr::operator!= 2022-12-10 18:09:54 +00:00
Kp 3ef8cb1e14 Let self_return_iterator::operator== use an implicit T::operator== 2022-12-10 18:09:54 +00:00
Kp a00a1ce59a Use mve_audio_spec to detect whether MVE audio has been created 2022-12-10 18:09:54 +00:00
Kp 8decd6ec99 Simplify DXX_ALWAYS_ERROR_FUNCTION
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.
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 d84b362f33 Use uint16_t for newmenu input text length 2022-11-13 21:17:23 +00:00
Kp a193af2e16 Use direct initialization for newmenu::type 2022-11-13 21:17:23 +00: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 ca1e3b1540 Remove unnecessary definition of exact_type<T>::operator!= 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
Kreeblah 6ec1f8a196
Require SDL 2 for macOS builds 2022-11-11 11:23:52 -08:00
Kp 8a36c4c54b Remove obsolete test for gcc bug #82541
The bug is fixed in gcc-8, and the current minimum version is gcc-10.
2022-11-11 02:03:51 +00:00
Kp 1e836729f5 Remove obsolete test for -Wimplicit-fallthrough
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]]")
2022-11-11 02:03:51 +00:00
Kp b2e1345ac9 Remove test for gcc -Wuseless-cast constructor inheritance bug
The bug is fixed in all supported versions of gcc, so there is no need
to test for it anymore.
2022-11-11 02:03:51 +00:00
Kp 1110b110c2 Remove obsolete compiler test
gcc-5 and later produce the desired result by default.  The current
minimum gcc is gcc-10.
2022-11-11 02:03:51 +00:00
Kp 1cb33638c0 Fix -Wuseless-cast on Win32 in PhysFS size checking macro
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>
2022-11-10 02:04:09 +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 562fee9d09 Use #if for DXX_HAVE_CXX_BUILTIN_FILE_LINE 2022-11-10 02:04:09 +00:00
Kp e07c5af1d0 Remove abandoned Visual Studio 2017 support
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
2022-11-09 23:58:22 +00:00