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.
segment inherits unique_segment, so unique_segment members can be
referenced from an instance of segment. Eventually, segment will be
removed. Adjust references to go through unique_segment to support this
change.
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>
Various sites assign GM_GAME_OVER to Game_mode, but no sites test for
it. Its only value would be to clear out other flags, but that can be
done by clearing Game_mode.
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>
Testing for buttons||hats||axes is equivalent to testing for
joysticks!=0, since SConstruct forces joysticks=0 when
buttons == 0 && hats == 0 && axes == 0. Remove tests of
buttons||hats||axes when those occur inside a test for joysticks!=0.
This ensures that an array is indexed by the appropriate type. Indexing
a mouse array with a joystick index is undefined behavior, and with this
change, such undefined behavior is now a compilation error.
If axes!=0 and buttons==0 and hats==0, then the build fails because some
button-related functionality is missing. Move the joystick axis->button
bridge into a conditional to exclude it in this case.
Fixes: 74ef8b02e6 ("Added axis buttons")
This makes the alignment data structure `chunk` private to interp.cpp,
and allows most files to ignore whether DXX_WORDS_NEED_ALIGNMENT is
enabled, thus improving the ccache hit rate.
lengthof was added to provide the size of C arrays. C++17 std::size is
now available, and can serve the same purpose. Remove the custom
lengthof.
The generated code is the same in both cases, other than the change in
line numbers caused by removal of the #include directives.