`obj_get_signature()` examines all objects with a type other than
`OBJ_NONE` to find an unused signature.
`load_game_data()`->`read_object()` set an object's type before calling
`obj_get_signature()`, so `obj_get_signature()` would consider the
uninitialized signature of the newly loaded object for exclusion.
Reorder the initialization to compute the signature before the object is
given a type, then store the signature on the object after the poison
bytes (if any) are written.
Move the main part of obj_link into obj_link_unchecked. Implement
obj_link as sanity check assertions followed by a call to
obj_link_unchecked. Remove caller-side writes that were present solely
to bypass the assertions, since the assertions can now be bypassed by
calling obj_link_unchecked directly.
Kreator reports that a level from back when Descent was new fails the
test for bogus matcen triggers. This level cannot be played when that
test throws an exception, so downgrade the exception to a CON_URGENT
message. This will hopefully deter level authors from creating any new
levels with this problem, but will allow users to play existing levels.
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/'
Field width conversion `.*` always takes an `int`.
On Win32, casting `long` to `int` triggers a `-Wuseless-cast` warning.
Omitting the cast works correctly.
On Linux/amd64, casting `long` to `int` works correctly.
Omitting the cast triggers a `-Wformat` warning.
Add a macro that conditionally expands to `static_cast<int>` or to ``,
as necessary for the target platform.
Objects are overwritten without using obj_allocate, so the normal poison
path is not triggered. Poison objects explicitly to trap uninitialized
data from a previous level.
This also fixes an unreported issue where player shields always reset to
100 on entering a new level. The game is supposed to raise shields to
100 if the player was lower on exiting the level. However, it is not
supposed to reduce shields to 100 if the player had a higher value on
exiting the level.
This also fixes a demo consistency issue reported by zicodxx <https://github.com/dxx-rebirth/dxx-rebirth/issues/168>.
Fixes: 2e28a491f2 ("Move player shields to struct object")
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>