The game has an alternative level file format that is not normally used.
This format can enable seismic events on a timer, independent of reactor
countdown or earthshaker usage. However, this feature is not reset on
loading a regular level after playing a level with the timer-driven
seismic events, so the regular level shakes according to the timer, even
though its author never designed it to do so.
Fix that by resetting the timer state to 0 before loading a regular
level.
It is reinitialized if the segment is a special segment, but not
reinitialized if the segment is a normal segment. Most segments are
normal segments. The absence of this initialization permitted players
to keep the value from a prior level. For normal segments, this would
normally not be a problem, because the value is only meaningful for
special segments. However, the netgame synchronization code always
mixes in the value of every station_idx, regardless of whether the
segment is a special segment. As a result, late-joining guests who
started directly onto the current level could disagree with the host
about the value, causing a synchronization mismatch. The host would be
wrong, but the guests would be blocked from joining. For this purpose,
late-joining includes both people who joined the campaign late and
people who left the game and restarted the program, even if they had
previously been in the game.
Reported-by: OldSaltyGamer <https://forum.dxx-rebirth.com/showthread.php?tid=1098&pid=12630#pid12630>
[ Possibly also previously reported by LightWolf, but that report never
had enough information to proceed. The report from OldSaltyGamer solved
this. ]
Fixes: 596ecbb38d ("Rename segment::value to segment::station_idx")
`value` is generic and unclear. It is always meant to be used as an
index into the Station array, so rename it `station_idx` to show this.
Define and consistently use `station_none` to represent that no station
is assigned.
Early unification efforts missed this one because it was in gamemine.c
for Descent 1, but segment.c for Descent 2. Move it to gamemine.cpp for
both, so that it can be static for both games.
Previously, valptridx used PREFIX for allow-invalid+mutable, c#PREFIX
for allow-invalid+const, v#PREFIX for require-valid+mutable, vc#PREFIX
for require-valid+const. Convert the types, factories, and all usage
sites to specify a qualifier for all four combinations:
im#PREFIX -> allow-invalid+mutable
ic#PREFIX -> allow-invalid+const
vm#PREFIX -> require-valid+mutable
vc#PREFIX -> require-valid+const
Changes to common/include/valptridx.h and common/include/fwd-valptridx.h
are manual. All other changes are generated by:
git grep -lz -e '\(obj\|seg\|clwall\|wall\|actdoor\|trg\)\(ptridx\|ptr\|idx\)\(_t\)\?\>' | xargs -0 sed -i -e 's/\<\(v\?\)\(\(obj\|seg\|clwall\|wall\|actdoor\|trg\)\(ptridx\|ptr\|idx\)\(_t\)\?\)\>/\1m\2/g'
for the 'm' prefix and:
git grep -lz -e '\(obj\|seg\|clwall\|wall\|actdoor\|trg\)\(ptridx\|ptr\|idx\)\(_t\)\?\>' | xargs -0 sed -i -e 's/\<\([cm]\(obj\|seg\|clwall\|wall\|actdoor\|trg\)\(ptridx\|ptr\|idx\)\(_t\)\?\)\>/i&/g'
for the 'i' prefix.
One caller uses fuelcen_activate when segp->special != station_type.
Every other caller passes the type that was already on the segment.
Move the assignment into the one caller that needs it, then remove the
argument.
Rename symbol EDITOR to DXX_USE_EDITOR to show that it is a DXX
symbol, not one inherited from a library. Move it to dxxsconf.h to
shorten the command line.
This is a mostly automated transform, but the changes to SConstruct were
manual.
git grep -wl EDITOR -- '*.h' '*.cpp' | xargs sed -i -e 's/^\s*#ifdef \(EDITOR\)\>/#if DXX_USE_\1/' -e 's/\s*#\(el\)\?if \(.*\)defined(\(EDITOR\))/#\1if \2DXX_USE_\3/' -e 's/^\s*#ifndef \(EDITOR\)\>/#if !DXX_USE_\1/'
The cast provokes a warning on systems that require alignment, so remove
it. memcpy takes const void* input, so the cast is unnecessary.
Reported-by: MattWatt <https://github.com/dxx-rebirth/dxx-rebirth/issues/119>