Previously, callers chose whether to use a fullscreen background image,
and the newmenu code inferred that callers without a background image
wanted a background box, while those with a background image wanted no
box. Change newmenu_layout to take a parameter specifying the caller's
intent, so that a caller can choose to have any combination of a
background image and a background box.
Previously, if the background failed to load, the kmatrix window was
immediately aborted. Change the logic so that a failure to load uses a
blank black background, but still shows the kmatrix window.
Define separate enum values for rotation data in both the high bits,
where it is usually kept, and the low bits, where it is sometimes used
for math or comparisons.
Define an enum value to represent the composite of the index and the
rotation, since the composite is not suitable for use as an array
subscript. Add helper functions to extract the component pieces.
gcc and clang disagree about how to disambiguate when an identifier is
both a typename and a member. Avoid the disagreement by renaming the
member.
Reported-by: Kreeblah <https://github.com/dxx-rebirth/dxx-rebirth/issues/532>
Descent tracked hoard orbs by borrowing the player's proximity bomb
slot. Commit 829e95b6f8 moved proximity
bomb tracking to its own slot, but failed to update the player
death/deres logic accordingly. This caused multiple inconsistencies
when a player was killed in hoard mode:
- The killed player saw the orb drop as expected.
- The killed player _also_ kept the orb in inventory after respawn,
because the counter was not reset.
- Other players saw no orb drop.
Fix the inappropriate retention by resetting the orb count in
init_player_stats_new_ship. Fix the inappropriate failure to drop by
adding a new unconditional field to the player death/deres message. In
hoard games, use it to pass the orb count. In other games, ignore it.
Fixes: 829e95b6f8 ("Separate hoard/proximity tracking")
Reported-by: snytek <https://github.com/dxx-rebirth/dxx-rebirth/issues/526>
TORRaven reported an issue where `Descent: First Strike` level 4 in
cooperative games would cause the player 0 ship to be unable to move.
On investigation, this occurs when the host has enabled extra player
starts, and the resulting synthesis of new player start positions moves
the player 0 start out of its origin segment. The physics engine reacts
poorly to this situation, causing the object to be unable to move and to
report HIT_BAD_P0 in debug builds. Add a test to cancel the
displacement if get_seg_masks reports that the center point would move
outside the origin segment. More clever logic might be appropriate, but
since this is the first report of problems with the feature since its
introduction in 5a64ee5132, this commit just eliminates the
immediate problem. Possible future improvements if the existing
displacement causes collisions:
- Reduce the magnitude of the existing displacement, instead of
abandoning it entirely.
- Move the player start to the segment's center before displacing it.
- Add logic to move the player into a nearby logically connected
segment.
Reported-by: TORRaven <https://github.com/dxx-rebirth/dxx-rebirth/issues/483>
Fixes: 5a64ee5132 ("Add experimental support for larger cooperative games")
Only the console player's last position needs to be remembered across
frames. Copy the console player's position out before processsing
object movement. For all other objects, retain a temporary for use by
the position recovery code.
Descent 2 has a hack, present as far back as I can trace, that
suppresses starting sounds during level load. The original reason was
not recorded, but this hack has the useful side effect that it avoids
using uninitialized data when set_sound_sources tries to use a Viewer
that has not been reset for the objects of the new level.
Descent 1 lacks this hack, so an invalid Viewer is used, which may
trigger a valptridx trap if the undefined data has an invalid segment
number, and could cause memory corruption in builds which do not
validate the segment index. The valptridx trap:
```
terminate called after throwing an instance of 'valptridx<dcx::segment>::index_range_exception'
what(): similar/main/digiobj.cpp:389: invalid index used in array subscript: base=(nil) size=9000 index=65021
```
The backtrace leading to the trap:
```
d1x::digi_link_sound_common (viewer=..., so=..., pos=..., forever=<optimized out>, max_volume=<optimized out>, max_distance=..., soundnum=42, segnum=...) at similar/main/digiobj.cpp:389
0x00005555555a4e2d in d1x::digi_link_sound_to_pos2 (vcobjptr=..., max_distance=..., max_volume=32768, forever=1, pos=..., sidenum=4, segnum=..., org_soundnum=121) at similar/main/digiobj.cpp:483
d1x::digi_link_sound_to_pos (soundnum=soundnum@entry=121, segnum=..., sidenum=sidenum@entry=4, pos=..., forever=forever@entry=1, max_volume=32768) at similar/main/digiobj.cpp:490
0x00005555555c140d in d1x::set_sound_sources (vcsegptridx=..., vcvertptr=...) at similar/main/gameseq.cpp:817
d1x::LoadLevel (level_num=<optimized out>, page_in_textures=1) at similar/main/gameseq.cpp:1022
0x00005555555c2654 in d1x::StartNewLevelSub (level_num=-1, page_in_textures=<optimized out>) at similar/main/gameseq.cpp:1865
```
Backport this hack into Descent 1. Ultimately, the hack should go away
and data should be loaded in an order that does not access undefined
memory.
Reported-by: Spacecpp <https://github.com/dxx-rebirth/dxx-rebirth/issues/463>
Single player games relied on the quirk that the pilot's name was always
kept in Players[], even outside a game. Commit 0c7de10512 removed
that quirk, which had the unintended consequence that single player
games are now played by the anonymous pilot. Set the player's callsign
during game setup so that the high score entry can be attributed
correctly.
Fixes: 0c7de10512 ("Track chosen pilot name outside Players[]")
Reported-by: Neurochild247 <https://github.com/dxx-rebirth/dxx-rebirth/issues/443>
Bisected-by: zicodxx <https://github.com/dxx-rebirth/dxx-rebirth/issues/443#issuecomment-523827234>
The number of hostages in a game is a function of the the game's levels,
not any particular player. Move it to d_game_unique_state and rename it
to total_hostages.
The number of hostages on a level is a function of the level, not any
particular player. Move it to d_level_unique_object_state and rename it
to total_hostages.
The number of robots accumulated in a game is a function of the the
game's levels, not any particular player. Move it to
d_game_unique_state and rename it to accumulated_robots.