The minimum supported compiler versions now provide a depth-efficient
implementation of std::make_index_sequence, which removes the last
reason to carry a private implementation. In the case of clang, it
appears to have a special compiler intrinsic used to implement its
std::make_index_sequence.
Switch to the compiler-provided version for both gcc and clang.
When exactly four bytes remain, mvelib will attempt to compute a
past-the-end pointer. Some handlers will dereference this pointer
without rechecking the length. Adjust the header check to require a
non-empty body.
Reported-by: jwrdegoede <https://github.com/dxx-rebirth/dxx-rebirth/issues/413>
The movie code assumes that when the topmost window is closed, that
window must have been the movie window, and that the movie data can now
be freed. However, if the movie is paused, a new topmost window is
created to tell the user that the movie is paused. When that topmost
pause window is deleted, the movie code frees the movie data, even
though the movie is not done. Corruption ensues, ultimately leading to
a crash.
Reported-by: Jayman2000 <https://github.com/dxx-rebirth/dxx-rebirth/issues/410>
This has been broken for more than 5 years and no one reported it.
Perhaps truecolor movies are not used.
Fixes: acb664ae40 ("Use proper type for mve backbuffers")
For each link given as http://, verify that the site is accessible over
https:// and, if so, switch to it. These domains were converted:
* llvm.org
* clang.llvm.org
* en.cppreference.com
* www.dxx-rebirth.com
* www.libsdl.org
* www.scons.org
Commit 07245a0bc2 added the SDL_mixer backend for MVE audio. That
commit set the length of the converted sound equal to the size of the
buffer that SDL requested as a work area. No one ever touched that
logic, until now. In SDL1, that choice worked fine. In SDL2, this
causes garbage to play after the sound, because SDL2 considers the
buffer to be defined only up to the length returned in
`SDL_AudioCVT::cvt_len`. Bytes beyond that length are undefined[1], and
in practice contain garbage. Fix the noise by setting the sound length
equal to the length returned by SDL2, so that the undefined bytes are
not treated as sound. SDL1 also maintains this length value, so no
version-specific logic is required.
[1]: https://wiki.libsdl.org/SDL_ConvertAudio
Reported-by: andrew-strong <https://github.com/dxx-rebirth/dxx-rebirth/issues/398>
lukeman3000 asked how to control the volume of the in-game movies.
Prior to this commit, there was no in-game solution to this. This
change scales movie audio by the SoundFx slider.
Thanks to lukeman3000 for inspiring this change. Thanks to Ryusei117
for explaining what videos needed to be affected, and for testing an
earlier iteration of the change.
Requested-by: lukeman3000 <https://forum.dxx-rebirth.com/showthread.php?tid=986>
Rename symbol USE_SDLMIXER to DXX_USE_SDLMIXER to show that it is a DXX
symbol, not one inherited from a library. Move it to dxxsconf.h to
shorten the command line.
This is a mostly automated transform, but the changes to SConstruct and
inferno.cpp were manual.
git grep -l USE_SDLMIXER -- '*.h' '*.cpp' | xargs sed -i -e 's/^#ifdef \(USE_SDLMIXER\)$/#if DXX_\1/' -e 's/#\(el\)\?if \(.*\)defined(\(USE_SDLMIXER\))/#\1if \2DXX_\3/'
Field width conversion `.*` always takes an `int`.
On Win32, casting `long` to `int` triggers a `-Wuseless-cast` warning.
Omitting the cast works correctly.
On Linux/amd64, casting `long` to `int` works correctly.
Omitting the cast triggers a `-Wformat` warning.
Add a macro that conditionally expands to `static_cast<int>` or to ``,
as necessary for the target platform.
C casts do not require parentheses. C++ casts require grouping around
the target. Prepare for conversion to C++ casts by adding otherwise
unnecessary parentheses around the target of simple C casts.
s/(\s*unsigned\s\+char\s*\(\*\+\)\s*)\s*\([&+-]\?\)\([[:alnum:]_.]\+\s*->\s*\)*\([[:alnum:]_.]\+\)\(\s*\([];+>)*\/^%,|&<>]\)\|$\|\(\s*-\s*[^>]\)\)/(uint8_t \1)(\2\3\4)\5/g
Uses of `(short*)` usually want exactly a 16-bit signed integer. Most
platforms provide that as `short`, but that is not guaranteed.
s/(short \(*\+\)\s*)/(int16_t \1)/g
This pass only targets commonly used standard types.
s/(\(\s*\(\(un\)\?signed\|int\|char\|short\|long\|float\|double\|s\?size_t\|\(u\?int[[:digit:]]\+_t\)\)\)\s*)\s*(/static_cast<\1>(/g
C casts do not require parentheses. C++ casts require grouping around
the target. Prepare for conversion to C++ casts by adding otherwise
unnecessary parentheses around the target of some C casts.
This pass attempts to process expressions that involve parenthesized or
bracketed subexpressions, but only if those subexpressions do not
themselves contain parenthesized or bracketed subexpressions.
(int) f(1); // changed
(int) f(g()); // not changed
perl -p -i -e 's/(\(\s*((?:un)?signed|int|char|short|long|float|double|s?size_t|(?:u?int[[:digit:]]+_t))\s*\**\s*\)\s*)([&+-]?)([[:alnum:]_.]+\s*->\s*)*([[:alnum:]_.]+)((?:\s*(?:\[[^][]*\])*|(?:\([^()]*\))*))(\s*([;+>*\/^%,|&<>])|$|(\s*-\s*[^>]))/\1\(\3\4\5\6\)\7/g'
This pass only targets commonly used standard types.
s/(\(\s*\(\(un\)\?signed\|int\|char\|short\|long\|float\|double\|s\?size_t\|\(u\?int[[:digit:]]\+_t\)\)\)\s*)\s*(/static_cast<\1>(/g
C casts do not require parentheses. C++ casts require grouping around
the target. Prepare for conversion to C++ casts by adding otherwise
unnecessary parentheses around the target of simple C casts.
This pass does not attempt to process expressions that involve
any subexpression that can nest arbitrarily, such as parentheses or
brackets. It also works only on commonly used standard types.
(int) a->b; // changed
(int) a[b]; // not changed
s/\((\s*\(\(un\)\?signed\|int\|char\|short\|long\|float\|double\|s\?size_t\|\(u\?int[[:digit:]]\+_t\)\)\s*\**\s*)\s*\)\([&+-]\?\)\([[:alnum:]_.]\+\s*->\s*\)*\([[:alnum:]_.]\+\)\(\s*\([];+>)*\/^%,|&<>]\)\|$\|\(\s*-\s*[^>]\)\)/\1(\5\6\7)\8/g
Mac OS X defines uint_fast32_t to unsigned int, causing ambiguous
overloads between RAIIdmem::operator[](std::size_t) and
RAIIdmem::operator[](int). Adding a disambiguating overload for OS X
breaks Windows. Remove operator pointer and operator[]. Rely on the
inherited operator[] for indexing. Require users to call ->get() to
convert to a simple pointer.
First btb ambiguity reported: https://github.com/dxx-rebirth/dxx-rebirth/pull/34
Second btb ambiguity reported: https://github.com/dxx-rebirth/dxx-rebirth/pull/43