Commit graph

10073 commits

Author SHA1 Message Date
Kp 289e984e10 Reduce scope of function-local constants 2018-07-22 04:46:19 +00:00
Kp 75d7eb6dce Skip paging in vclip entries with invalid num_frames
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>
2018-07-18 04:39:28 +00:00
Kp 19699037ce Move d2x-rebirth/main/bmread.cpp -> similar/main/bmread.cpp 2018-07-18 04:39:28 +00:00
Kp fd0238cb6b Silence gcc-8 -Wcast-function-type in except.cpp
gcc-8 adds a new warning controlled by -Wcast-function-type, which is
implied on by Rebirth's default options.  This new warning rejects
attempts to reinterpret_cast between function pointer types.  While this
might provide some value when the function pointer was derived by taking
the address of a properly declared function provided elsewhere in the
same program, it is wrong when the function pointer is returned by an
external library call, such as GetProcAddress, which always returns a
placeholder type instead of the actual type of the target function.
Switch to using a union with type-punning, which achieves the same
effect as the cast, but does not count as a cast, and therefore does not
provoke the warning.

References: <https://github.com/dxx-rebirth/dxx-rebirth/issues/388>
2018-07-15 04:43:55 +00:00
Kp 20f1934312 Move Redbook audio behind DXX_USE_SDL_REDBOOK_AUDIO
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>
2018-07-14 17:23:15 +00:00
Kp f33877d379 Make grs_main_bitmap::grs_main_bitmap() clear the whole structure 2018-07-14 17:23:15 +00:00
Kp 5d74fd48b5 Fix player appearance sound truncation
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")
2018-07-14 17:23:15 +00:00
Kp 9ea09107d1 Delegate managing SDL_RWops to SDL_mixer when possible
SDL_mixer 2 offers the option to have the library free the SDL_RWops.
Add macros to use this feature when available.

References: <https://github.com/dxx-rebirth/dxx-rebirth/issues/82>
2018-07-05 04:03:34 +00:00
Kp d97afc2ad5 Retain directory structure in New Game dialog
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>
2018-07-03 05:59:40 +00:00
Kp db80a88ad2 Improve error message on failure to load mission 2018-07-03 05:59:39 +00:00
Kp 1da76dde7d Fix SDL-only build of gauges.cpp
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")
2018-06-30 21:53:55 +00:00
Kp da268c6d21 Preprocess out glmprintf in normal builds
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")
2018-06-30 21:53:55 +00:00
Kp 90dfedb5cb Fix gauges.cpp for gcc-5
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")
2018-06-30 21:53:55 +00:00
Kp 7d4c521382 Fix SConf tests for Windows target
On Windows, SDL headers define `main` to `SDL_main` in addition to doing
it through `pkg-config`.  The countering `#undef` must occur after the
headers are included.  Commit 2a82207 changed the `#undef` to occur too
early.  Linux works fine, but Windows broke.

Move the `#undef` back down.  Switch to named format parameters to make
it easier to maintain.

Fixes: 2a82207e91 ("Add unit tests for valptridx parameter validation")
2018-06-30 18:59:53 +00:00
Kp 9dafe85bbf Simplify clamping color values in SDL palette setup 2018-06-29 03:24:36 +00:00
Kp 676cab8921 Adjust d_event_mouse_moved member types for SDL2
References: <https://github.com/dxx-rebirth/dxx-rebirth/issues/82>
2018-06-27 03:34:34 +00:00
Kp d20901edba Adjust physfsrwops.cpp for SDL2
References: <https://github.com/dxx-rebirth/dxx-rebirth/issues/82>
2018-06-27 03:34:34 +00:00
Kp 60a99f1ea2 Allow longer mission titles in New Game dialog 2018-06-27 03:34:34 +00:00
Kp d1a4e3b7a1 Update Gentoo ebuild to current stable-0.60.x
_p38 since the target commit is 38 commits after tag 0.60.0-beta2.
2018-06-24 18:05:48 +00:00
Kp 30a83eec41 Eliminate some uses of valptridx::operator-> 2018-06-24 05:06:15 +00:00
Kp c97b41404c Factor out pick_connected_drop_segment 2018-06-24 05:06:15 +00:00
Kp 6fca290663 Pass object& to read_flying_controls 2018-06-24 05:06:15 +00:00
Kp 0fd7e0e4ce Pass context arrays to WALL_IS_DOORWAY 2018-06-24 05:06:15 +00:00
Kp 3408e3a0cd Switch to shared_segment arguments where possible 2018-06-24 05:06:15 +00:00
Kp 20caecfa0e Eliminate most uses of segment * 2018-06-24 05:06:15 +00:00
Kp fb68e7f9ec Eliminate use of side * 2018-06-24 05:06:15 +00:00
Kp 0c3e99f14c Split side uses based on shared vs unique 2018-06-24 05:06:15 +00:00
Kp 98e6b36145 Pass shared_segment for some segment I/O 2018-06-24 05:06:15 +00:00
Kp 2de3a1dd06 Pass unique_segment to objects_in 2018-06-24 05:06:14 +00:00
Kp 4ae88b6594 Pass only shared_segment to compute_segment_center 2018-06-24 05:06:14 +00:00
Kp 6d0d68d188 Split some segment uses based on shared vs unique
Leave `sides` in `shared_segment` to minimize churn.  Parts of it must
move to `unique_segment` before this project finishes.
2018-06-24 05:06:14 +00:00
Kp 06f10c88f5 Fix stack buffer overflow in tracker handling
`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. ...")
2018-06-22 04:42:18 +00:00
Kp 144515ff88 Warn users about tracker NAT hole punch feature
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. ...")
2018-06-21 03:08:36 +00:00
Kp e3d42913a4 Remove always-disabled editor/segment.cpp code
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.
2018-06-20 04:16:06 +00:00
Kp 0886aee3ea Always destroy control center when kill goal timer expires
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.
2018-06-20 04:16:06 +00:00
Kp 1d6ff380f7 Jump thread wall_is_doorway 2018-06-20 04:16:06 +00:00
Kp 946d5e19cb Pass screen width/height to HUD_SCALE_X/HUD_SCALE_Y explicitly 2018-06-20 04:16:06 +00:00
Kp a0fd264133 Tighten checks on create_path_points parameters 2018-06-20 04:16:06 +00:00
Kp fa8253fe22 Fix -Wsign-compare warnings in morph.cpp 2018-06-18 04:11:40 +00:00
Kp c8b04d0c83 Allow more items on screen in a listbox 2018-06-18 04:11:39 +00:00
Kp 6f4270ecd8 Store mission list filenames inside mission_menu 2018-06-18 04:11:39 +00:00
Kp 2a82207e91 Add unit tests for valptridx parameter validation 2018-06-17 05:04:38 +00:00
Kp 9b2d5d5162 Add debug hook $DXX_SCONS_DEBUG_USER_SETTINGS to log user_settings init
For the benefit of users less familiar with how setup is handled, add a
hook triggered by $DXX_SCONS_DEBUG_USER_SETTINGS to log initialization
of `user_settings` so that users can trace which values combined to
produce the observed results.
2018-06-17 05:04:38 +00:00
Kp 2f4524d3c2 Add screenshot=none to disable screenshot support
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.
2018-06-16 04:13:37 +00:00
Kp d7bb190621 Fix assertion on close of game over window 2018-06-15 02:58:01 +00:00
Kp 39edf53496 Check for freed canvas in release builds 2018-06-14 02:39:15 +00:00
Kp c991f8b107 Prevent Point_segs underflow on player death
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.
2018-06-14 02:39:15 +00:00
Kp 8690bf4ca7 Change handling of explicitly blank briefings
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")
2018-06-13 02:02:58 +00:00
Kp 5526de4c10 Simplify case insensitive lookups 2018-06-13 02:02:58 +00:00
Kp d5bfeb0813 Fix OS X build break
Github user bdamm (Rebirth forum user dammfine) reports[1][2][3] a build
failure on OS X, likely caused by clang failing to implement forwarding
constructors fully.  The Rebirth fallback to variadic constructor
forwarding is imperfect, and in this case caused a failure.  Add an
explicit conversion to disambiguate the ternary expression's type.

[1]: Rebirth forum report: https://forum.dxx-rebirth.com/showthread.php?tid=1055
[2]: Github commit comment: ccc2a288f1?diff=unified#commitcomment-29322121
[3]: Github issue: https://github.com/dxx-rebirth/dxx-rebirth/issues/391

Reported-by: bdamm <https://github.com/dxx-rebirth/dxx-rebirth/issues/391>
Fixes: ccc2a288f1 ("Simplify HUD_SCALE_X_AR, HUD_SCALE_Y_AR")
2018-06-12 02:53:06 +00:00