Shrink it from 1MB to 300KB. Add a diagnostic if the expansion fails
due to insufficient capacity.
300KB is required for the ship cockpit bitmap. Everything else seems to
be smaller.
User jammer1 reports that Python under MSYS2[1] reports a `sys.platform`
of `msys`. For the limited purposes Rebirth requires, this platform can
be treated as if it were `win32`. Add a mapping to apply this change
automatically, so that users do not need to set it on the command line.
Reported-by: jammer1 <https://github.com/dxx-rebirth/dxx-rebirth/issues/405>
[1]: http://www.msys2.org/
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
enable_build_failure_summary=1 assumed that the command to display was a
list. For internal pseudo-commands, such as write_pch_inclusion_file,
the command was a string, so calling ' '.join() was incorrect. When the
output is not a list, pass it through unchanged.
Add macro cf_assert ("control flow" assert) to hint to gcc that certain
conditions are impossible. Use it to avoid generating range checks for
situations that never happen. If the event did happen, the only
consequence would be truncated UI text, rather than a correctness
problem.
The prior design was meant to allow the hook to be called instead of the
normal function, with the hook chaining to the normal function and then
performing other work as needed. This flexibility is unnecessary, and
complicates improvements elsewhere. Replace it with a hook that is
called with the result of the regular StaticObject call.
Use of the comprehensions makes the code less readable and harder to
modify. The performance benefit, if any, is in the noise. Switch to
an unpacked form.
Move it to a structure. Make all the modifiers methods. Change all
callers of those methods to pass the structure. This makes the stuck
object handling free of direct access to global game data.
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>
Commit a833d73d44 added the SDL_mixer backend for Rebirth sound. 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: heftig <https://github.com/dxx-rebirth/dxx-rebirth/issues/396>
gcc-7 allows `constexpr auto X = std::initializer_list<unsigned>{A1, A2,
...};`. gcc-8 rejects it:
```
common/arch/sdl/key.cpp:583:105: error: 'const std::initializer_list<const SDL_Scancode>{((const SDL_Scancode*)(&<anonymous>)), 3}' is not a constant expression
constexpr auto sticky_keys = {SDL_SCANCODE_CAPSLOCK, SDL_SCANCODE_SCROLLLOCK, SDL_SCANCODE_NUMLOCKCLEAR};
```
Switch to a macro and a fully anonymous list, which is accepted by both
versions.
Fixes: f491059ed7 ("Enable building with SDL2")
This commit enables Rebirth to build with SDL2, but the result is not
perfect.
- SDL2 removed some sticky key support. Rebirth may behave differently
now in this area.
- SDL2 removed some key-repeat related support. Rebirth may behave
differently now in this area.
- SDL2 gained the ability to make a window fullscreen by sizing it to
the desktop instead of by changing the desktop resolution. Rebirth
uses this, and it mostly works.
- Resizing while in the automap does not notify the automap code, so
the view is wrong until the player switches out of automap mode and
back in.
- SDL2 changed how to enumerate available resolutions. Since
fitting the window to the desktop is generally more useful than
fitting the desktop to the window, I chose to drop support for
enumerating resolutions instead of porting to the new API. Users can
now enter an arbitrary window dimension and Rebirth will make an
attempt to use it.
- It might be useful to cap the window dimension at the desktop
dimension, but that is not done yet.
- Entering fullscreen mode through the Controls->Graphics submenu
failed to notify the relevant subsystems, causing the rendered
content not to rescale. For now, compile out the option to toggle
full screen through that menu. Toggling through Alt+Enter works
properly.
Despite these quirks, this is a substantial improvement over the prior
commit, where SDL2 cannot be used at all. The remaining issues can be
resolved in future work.
References: <https://github.com/dxx-rebirth/dxx-rebirth/issues/82>
User Nemesis reported an unspecified crash, but never responded to
inquiries to provide more data. Users Tourmeister and Buff Skeleton
reported a fatal exception thrown while paging in a vclip, with initial
triggering conditions matching the report from Nemesis. Both
Tourmeister and Buff Skeleton are using v1.0 Descent 2 data. No one
with more recent data has reported a problem.
Add a try { ... } catch { ... } block to trap the partial_range
exception, log it, and then ignore paging in that vclip. This should
approximate what 0.58.1 did, assuming that the crash is due to a
negative `num_frames`. If the crash is due to a large positive
`num_frames`, this change will still prevent the previously reported
crash, but may only move the crash elsewhere. Various other subsystems
react badly to using a vclip that has not been paged in.
This change is tested not to break an otherwise working game. It is not
tested to confirm that it produces a working game for users who
experienced a crash without it.
Reported-by: Tourmeister <https://forum.dxx-rebirth.com/showthread.php?tid=943&pid=12159#pid12159>
Reported-by: Buff Skeleton <https://forum.dxx-rebirth.com/showthread.php?tid=943&pid=12290#pid12290>
References: <https://github.com/dxx-rebirth/dxx-rebirth/issues/371>