clang chokes on use of a `constexpr bool` that is initialized separately
from its definition. gcc allows this. Move the value computation into
a constexpr helper function, so that the variable can be defined and
initialized in the same statement.
Instead of creating the powerup from a player, then overwriting the
location and velocity of the powerup, and fixing up its segment, create
the powerup directly where it should be, with the intended velocity.
Iterating over it returns each side number in turn. This allows
converting many loops of the form:
```
for (int i = 0; i < MAX_SIDES_PER_SEGMENT; ++i)
```
to the compact form:
```
for (const auto i : MAX_SIDES_PER_SEGMENT)
```
The compact form brings the usual benefit of range-based for: delegating
iteration to the compiler prevents the loop body from skipping a step,
and makes clear in the code that this is the case.
Some flags merit a type other than int8_t. Begin moving flags out to
distinct variables with their own type.
Add static_assert checks that the ABI relevant structures do not change.
clang warns that an implicit copy constructor is deprecated in the
presence of an explicitly defaulted copy-assignment operator.
Add an explicitly defaulted default constructor too, since the
explicitly defaulted copy constructor suppresses generation of an
implicit default constructor, and the default constructor is needed.
Commit 4d6affd74d ("Fix SDL-only briefing crash") added a hack to
prevent a crash when the briefing window is automatically resized.
However, a logic error in that hack causes some subcanvases that were
not wrong to be truncated. Change the logic to fix those subcanvases,
such as the one used for rendering a background in the High Scores
window. The new logic still avoids the crash in in SDL-only mode.
Fixes: 4d6affd74d ("Fix SDL-only briefing crash")
On some systems, such as the Apple M1 (ARM-based Macs),
dylibbundler is in $PATH, but not in a directory found by the limited
path that SCons uses for Command() invocations. This causes the SConf
test to succeed (because it uses the full $PATH), but the Command() to
fail (because it uses a reduced path). Fix this by using the user's
$PATH, if defined, for this Command() invocation.
Along the way, rework tool_bundle.py to use SCons' Node() objects in
place of direct path manipulation. This lets SCons produce better error
messages in some cases.
Reported-by: Kreeblah <https://github.com/dxx-rebirth/dxx-rebirth/pull/610>
If std::common_type<range::index_type>... finds a common index_type
among all the zipped ranges, pass that common type through as
zip<...>::index_type. Otherwise, set zip<...>::index_type to void.
This allows enumerate(zip(...))) to report a better index_type.
Trim the bitmap's current width and height to be not more than its
parent. Otherwise, an automatic screen resize, such as triggered when
playing the robot briefings in Descent 2, will give the window a new
smaller bm_data, but continue to use the old dimensions. This then
causes load_briefing_screen -> gr_bitmap_scale_to -> scale_line to write
off the end of the smaller bm_data, causing memory corruption and
eventually a crash.
enum game_mode_flags must be visible in common code, which does not
define DXX_BUILD_DESCENT_II. To avoid One Definition Rule errors,
game_mode_flags must have the same definition in all files.
Fortunately, the DXX_BUILD_DESCENT_II definition is a superset of the
common definition, so the preprocessor guards can be replaced with
advisory comments.
Fixes: 2b718da343 ("Use enum class for Game_mode, Newdemo_game_mode")
Change it from the level number on which the path was created to a
true/false flag. The previous logic only tested whether the number was
equal to the current level number.
This also fixes a bug where the action was not available on the first
secret level, since that level is `-1`, and the value was set to `-1` to
indicate that it should be enabled.