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 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>
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>
Currently, DXX_USE_SDL_REDBOOK_AUDIO is an alias for !SDL2. However,
this patch enables interested users to readily patch out Redbook even
for SDL1.
References: <https://github.com/dxx-rebirth/dxx-rebirth/issues/82>
The player appearance sound was tied to the player appearance vclip,
but this is wrong because the vclip has a shorter lifetime than the
sound. This mistake was previously hidden by the hack that caused
non-permanent sounds to be routed off to a separate queue that lost the
association between object and sound. Commit 4a98e79 eliminated that
hack because it complicated the work of that commit. However, without
the hack, object sound effects cannot outlive their host object.
Fix this by binding the sound to the position of the appearance effect,
not to the appearance object. This works since the appearance effect
cannot move, so there was no value to binding the sound to the object.
This solution could not be used for objects that move and terminate
before their associated sound effect.
Reported-by: Ryusei117 <https://github.com/dxx-rebirth/dxx-rebirth/issues/88#issuecomment-390054173>
Fixes: 4a98e796ab ("Prevent stacking weapon rotation sounds")
User jcotton42 suggested copying a D2X-XL feature: preserving the
directory structure of the user's missions area when showing a New Game
dialog. This was substantially more trouble than it should have been,
but the result is good.
Previously, the dialog presented all missions at any depth below the
starting point, and sorted them as if they were all in the root
directory.
Now:
- Empty directories are hidden entirely. There is nothing for the user
to do in them, so there is no point showing them.
- A directory with exactly one entry has that entry promoted into the
parent, since there is no ambiguity about what the user would want.
If the parent in turn has only that one promoted element when the scan
of the parent finishes, then the element can be promoted up again.
This continues until the root is reached or until a level has more
than one entry. For this purpose, both missions and directories count
as entries.
- Directory entries are decorated to inform the user how many
immediate subdirectories are present, how many missions are present
immediately in the directory, and how many missions total are present,
counting all subdirectories. If there are zero immediate
subdirectories, then the directory count is not shown. For this
purpose, directories that were hidden due to a lack of missions are
not counted.
- Sub-dialog boxes for inner directories use a title that reminds the
user of the path so far, and recaps the directory/mission statistics.
- On entry to the New Game dialog, if the last played mission is in a
sub-dialog, appropriate sub-dialogs are opened so that the last played
mission can be pre-selected.
Currently, there is no in-game override to return to the prior rollup
rules.
Requested-by: jcotton42 <https://github.com/dxx-rebirth/dxx-rebirth/issues/392>
Even when empty and default-constructible, const members must be
explicitly constructed. Add a default constructor to do this.
Fixes: 893e8cde06 ("Combine hud gauge parameters")
Using sizeof(con_printf A) was a trick to avoid code generation, but it
interacts badly with gcc-6 and the other macros that con_printf
produces. On >=gcc-6, `DXX_ALWAYS_ERROR_FUNCTION` is a complicated hack
to work around undesirable changes in `__builtin_constant_p`. That hack
includes introducing a dummy type. gcc-6 rejects declaring a type
inside a statement expression inside a sizeof. gcc-7 permits this, so
it went unnoticed.
This particular usage was to prevent future regressions in calls that
had been broken for years without anyone noticing. As such, reverting
to not checking those calls is unlikely to matter.
Reported-by: Ambaire <https://github.com/dxx-rebirth/dxx-rebirth/issues/393#issuecomment-401565872>
Fixes: 9b17450914 ("Fix up long broken glmprintf support")
gcc-5 rejects `V == V::E` where the first V is a variable of type V and
the second V is a scope specifier to indicate the member E in the type
V. gcc-7 permits this.
Fixes: 5cafec2268 ("Use enum for gauges weapon_type")
`memcpy(a, b, strlen(b));` is just a complicated way of writing
`strcpy(a, b);`, but even more dangerous since it omits the null
terminator. `strcpy` on untrusted data is always unsafe, and this data
does not appear to be checked before use. There is no need to copy the
data before using it, so switch to using it in place. This eliminates
the security problem and makes the code slightly smaller.
Fixes: 730879d733 ("Updated handling of data sent by tracker. ...")
The new tracker automatically exposes LAN games to the Internet. This
surprised one user rather badly, prompting him to think he had been
hacked. Add a first-host warning explaining the feature and asking the
user to choose whether to enable NAT hole punch.
Reported-by: Tourmeister <https://forum.dxx-rebirth.com/showthread.php?tid=943&pid=12179#pid12179>
References: <https://github.com/dxx-rebirth/dxx-rebirth/issues/372>
Fixes: 730879d733 ("... Added support for handling ACKs from tracker and Hole punching between game clients via tracker. ...")
Various functions are preprocessor-excluded by `BOTTOM_STUFF`, which has
been 0 since btb added it in a196e6d554
(October 2001). It seems unlikely that anyone will miss it.
Prior releases destroyed the control center when the kill goal timer
expired, even if no player had scored any kills. General cleanup of
kill goal quirks eliminated this odd rule, but players liked the old
rule and want it back. Restore it.
Per comment from kreator, some Apple systems now ship without a working
print screen key. It makes no sense to provide print screen support
bound to a key which does not exist. Add `screenshot=none` and activate
it on OS X to remove the unreachable screenshot support.
If the player commits suicide in Descent 2, Point_segs[-2] is accessed
because aip->hide_index = -1, aip->path_length = 0. As a spot fix,
check for underflow and skip the access if it would be out of bounds.
Prior versions of Descent had a bug that specifying `briefing=` did not
inhibit a briefing. Instead the directive was completely ignored. The
engine would then use the auto-detected briefing if one was found. This
quirk was eliminated during refactoring of the mission parsing code.
Unfortunately, some published missions relied on this bug: they ship a
briefing, but their mission file explicitly states that there is no
briefing. Players expect the briefing to play despite the mission
stating that there is none.
Reorder the logic to restore the bug that `briefing=` is ignored.
Reported-by: Calmarius <https://forum.dxx-rebirth.com/showthread.php?tid=1054>
Fixes: 6020c9c013 ("Use d_fname for DOS filenames")