Global variable `grd_curcanv` is set to a variety of canvases, some of
which are local stack variables. Use of global variables in this way is
fragile, but works as long as the global is not used beyond the life of
the backing local.
Unfortunately, some existing uses do access the canvas beyond the
lifetime of the backing local. Playing movies sets the font of the
current canvas. If the current canvas is an expired stack variable,
setting the font overwrites other stack data. This data corruption
causes various symptoms, such as inability to play the escape tunnel
movie.
Prior to 03cca2b3dc, the corruption on
playing the endlevel movie had no user-visible effect. That commit
created a large local variable, which changed stack layout. Starting
with that commit, the corruption causes the movie to play as all black.
Fix this, and protect against some other data corruption possiblities,
by clearing the global when the local goes out of scope.
Reported-by: Havner <https://github.com/dxx-rebirth/dxx-rebirth/issues/345> (only as cutscene failure to play, not as the underlying corruption issue)
Rather than use an inline wrapper and rely on the compiler optimizer to
redirect gr_set_current_canvas(nullptr) to gr_set_default_canvas,
rewrite all relevant calls directly in the source.
git grep -l 'gr_set_current_canvas' | xargs sed -i -e 's:gr_set_current_canvas(\s*NULL\|nullptr\s*);:gr_set_default_canvas();:'
Defining SLEW_ON breaks the build due to use of member variable names
not used since before the D2X import in 2001.
`unifdef -USLEW_ON -m -- similar/main/endlevel.cpp`
psyke83 reports that Debian distributions for Raspberry Pi now require a
different name for some video libraries. Merge psyke83's SCons
enhancements to add support for the new names while retaining support
for the old names.
ignorecase=1 coerces the user's input only for validation, but retains
the original case for later processing.
ignorecase=2 coerces the user's input for all purposes, and retains the
coerced form for later processing.
Since other code compares the `raspberrypi` variable to specific values
from the whitelist, user input must be mapped to that whitelist both for
SCons validation and for that later code. With ignorecase=1, a user
could set `raspberrypi=MESA`, which would pass SCons validation, but
then not be treated as equal to `mesa` when computing default values.
With ignorecase=2, `raspberrypi=MESA` will be recorded as `mesa` and
compute the desired default value.
Fixes: 166b1ecd4d ("RPI: update vendor library names & add Mesa VC4 build support")
PhysFS 2.0 only offers PHYSFS_read/PHYSFS_write for I/O. PhysFS 3.0
deprecates PHYSFS_read / PHYSFS_write and offers PHYSFS_readBytes /
PHYSFS_writeBytes. Converting Rebirth to use the new API is somewhat
invasive, and would require dropping support for PhysFS 2.0.
For now, for compatibility with PhysFS 2.0, disable the deprecation
errors and continue to use the older functions.
Reported-by: gabeotisbenson <https://github.com/dxx-rebirth/dxx-rebirth/issues/352>
Vendor library has new names to avoid conflicts with Mesa. Update
raspberrypi argument to use new libraries and support Mesa VC4 driver.
* raspberrypi=1 will build against the (newly named) vendor libraries
* raspberrypi=mesa will target building against the VC4 driver.
Both will select GLES by default, but you can target GL for the VC4 driver
via "raspberrypi=mesa opengles=0"
This code was part of a feature abandoned before retail. It cannot be
usefully used in campaigns. Remove it to reduce code size and simplify
later changes.
SCons tries to probe the compiler designated by CXX before Environment()
returns. Set CXX in the call to Environment so that it probes the
correct tool.
If resolving the linker path fails, ld_path is not usable to run an
external program, but DXXProgram tried to use it as such. Test ld_path
before using it.
Splitting auto-generated paths is wasteful, but almost always harmless
on Linux. However, Windows uses backslash as a path separator, which
conflicts with its standard meaning as an escape character. Using
shlex.split on a generated Windows path strips required backslashes,
causing a later failure to find the command. Move the shlex.split call
to apply only to user-specified paths.
Reported-by: ef314159 <https://github.com/dxx-rebirth/dxx-rebirth/issues/349>
ef314159 reports that running SCons on Windows fails with an
AttributeError exception. `os.uname` is not available on Windows, but
SConstruct assumed it was. Trap the error and report a machine of
`None`, since this is purely for logging.
Reported-by: ef314159 <https://github.com/dxx-rebirth/dxx-rebirth/issues/348#issuecomment-334657171>
Fixes: 1ed7cec714 ("Tighten __builtin_constant_p check to handle gcc-7")
When print_function is imported (or Python 3 is used), print without
parentheses is an error. Historically, SCons has used only Python 2 and
has not enabled print_function. This may change, so add parentheses to
the one affected site. None of the print_function features are used, so
this should work in both Python 2 and Python 3.
Descent 1 bosses could always teleport, but were only placed in large
areas where free teleporting was always permitted.
Descent 2 boss 1 was placed in a confined segment and not permitted to
teleport out of it until it was opened. This was implemented by a
two-part change relative to Descent 1 rules:
- Descent 1 bosses were always permitted to teleport to any teleport
destination segment. Descent 2 bosses were only permitted to teleport
if the player was visible or the boss had recently been hit.
- When computing the permitted list of teleport destination segments,
Descent 1 used directly connected accessible segments, then stopped.
Descent 2 started with this rule, but if the list had at most 1 entry,
then it would assume this is the confined boss and recompute the list
with the first wall ignored. This recomputed list allowed the boss to
teleport to any segment in the larger arena outside its starting
segment.
After D2X-Rebirth support for emulating Descent 1 bosses was enhanced in
28bd4c1650, Descent 1 bosses gained the ability to teleport out of a
confining cube early, but only in D2X-Rebirth when emulating Descent 1.
In D1X-Rebirth, when a boss is placed in a confining cube, it can always
teleport, but only to that confining cube. In D2X-Rebirth, Descent 1
bosses retain the always-teleport rule of Descent 1, but gained the
Descent 2 rule for expanding its search to the surrounding arena. It
should only use the expanded search when it also abides by the Descent 2
restriction not to teleport before the first wall is opened. It did not
abide by that rule. This commit adds that restriction for Descent 1
bosses.
Reported-by: ef314159 <https://github.com/dxx-rebirth/dxx-rebirth/issues/348>
Fixes: 28bd4c1650 ("Enable D1 boss behavior in d2x build. So we get correct boss behavior when emulating D1, and 3rd party mn2s can include D1 bosses.")
Both the `if` and `else` paths had the same loop and post-loop
processing. The `if` path was a strict subset of the `else` path. The
`else` path had one setup statement, and was otherwise equal to the `if`
path. Move the shared statements outside the guarded path.
Commit b1b5de4 switched from enabling select physics flags to setting
those flags and clearing all others. Unfortunately, flag PF_USES_THRUST
was omitted from the enabled list, so it was disabled on reset. It is
required to let player ships move.
Reported-by: Sottises <https://github.com/dxx-rebirth/dxx-rebirth/issues/347>
Fixes: b1b5de4297 ("Additional safeguard for bug #306")
lukeman3000 asked how to control the volume of the in-game movies.
Prior to this commit, there was no in-game solution to this. This
change scales movie audio by the SoundFx slider.
Thanks to lukeman3000 for inspiring this change. Thanks to Ryusei117
for explaining what videos needed to be affected, and for testing an
earlier iteration of the change.
Requested-by: lukeman3000 <https://forum.dxx-rebirth.com/showthread.php?tid=986>
Editor groups write `struct segment` to a file in raw form, but had no
code to enforce that this raw form remained stable over time. Various
changes to `struct segment` have repeatedly changed its internal
structure. Each change created an incompatible dialect of the editor
group file, and all the dialects share the same version number.
According to
```
git log -p -L'/struct segment {/,/};/:common/main/segment.h' HEAD --not 0.58.1-d1x 0.58.1-d2x --
```
`struct segment` changed layout in:
* d1c6b89f17 ("Move dsx::segment -> dcx::segment") [D1 only]
* 596ecbb38d ("Rename segment::value to segment::station_idx") [D1 only]
* 6f10a67c09 ("Move segment::sides to end")
* c53b734abb ("Compute slide segments early") [D2 only]
* 40e90fea22 ("Move Light_subtracted[] to Segments[].light_subtracted")
* a65d774c83 ("Improve packing of struct segment")
* c70c6c98b3 ("Remove obsolete segment::degenerated flag")
Mark editor groups as broken to avoid making the mess worse. If anyone
cares about group support, it needs to be rewritten not to depend on the
internal layout of `struct segment`.
Descent 2, but not Descent 1, had a useless test in render_side:
type == QUAD ? 0 :
type == TRI_13 ? 1 :
0
This is useless since, if type is not QUAD, the second expression will
apply. If type is QUAD, then the type is not TRI_13, so the second
expression would choose the same result as the first. The extra
comparison does not save any work, so it is useless. Remove it.