- sanitized the 'frozen level' code.

This had two different flags that were checked totally inconsistently, and one was not even saved.
Moved everything into a few subfunctions so that these checks do not have to be scattered all over the code.
This commit is contained in:
Christoph Oelckers 2019-01-28 20:15:48 +01:00
commit 259ae41774
25 changed files with 124 additions and 65 deletions

View file

@ -2682,7 +2682,32 @@ DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, Vec3Offset, Vec3Offset)
ACTION_RETURN_VEC3(result);
}
static int isFrozen(FLevelLocals *self)
{
return self->isFrozen();
}
DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, isFrozen, isFrozen)
{
PARAM_SELF_STRUCT_PROLOGUE(FLevelLocals);
return isFrozen(self);
}
void setFrozen(FLevelLocals *self, int on)
{
self->frozenstate = (self->frozenstate & ~1) | !!on;
// For compatibility. The engine itself never checks this.
if (on) self->flags2 |= LEVEL2_FROZEN;
else self->flags2 &= ~LEVEL2_FROZEN;
}
DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, setFrozen, setFrozen)
{
PARAM_SELF_STRUCT_PROLOGUE(FLevelLocals);
PARAM_BOOL(on);
setFrozen(self, on);
return 0;
}
//=====================================================================================
//
@ -2764,6 +2789,7 @@ DEFINE_FIELD(FLevelLocals, outsidefogdensity)
DEFINE_FIELD(FLevelLocals, skyfog)
DEFINE_FIELD(FLevelLocals, pixelstretch)
DEFINE_FIELD(FLevelLocals, deathsequence)
DEFINE_FIELD_BIT(FLevelLocals, flags, noinventorybar, LEVEL_NOINVENTORYBAR)
DEFINE_FIELD_BIT(FLevelLocals, flags, monsterstelefrag, LEVEL_MONSTERSTELEFRAG)
DEFINE_FIELD_BIT(FLevelLocals, flags, actownspecial, LEVEL_ACTOWNSPECIAL)