Commit graph

12251 commits

Author SHA1 Message Date
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
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 da779e27b7 Generalize zip get_static_size to use tuple_size
This allows it to work on pairs, tuples, and any types that define a
reasonable overload of tuple_size.

Add unit tests for the known supported types.
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 4610afaa29 Update Gentoo ebuild PYTHON_COMPAT to Python3.10
Python3.9 is no longer used with SConstruct, so drop it from
PYTHON_COMPAT.  It may still work, but is not supported.
2022-11-07 01:59:34 +00:00
Kp 8215044325 Remove PROPERTIES=live from Gentoo ebuild
git-r3.eclass already sets this, so there is no need to set it again.
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 6799aa5bdf Update c++std documentation 2022-11-06 18:18:57 +00:00
Kp 962a37e75e Backport more ranges support for OS X clang
Apple clang is currently version 14, but Apple's libc++ is version 13,
and so lacks even more std::ranges support than previously reported.
Add more stub backports to work around this.
2022-11-06 18:18:57 +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 fc9de58302 Raise clang version in INSTALL.markdown 2022-10-31 00:51:32 +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