- fixed: P_SpawnMapThing may not call playsim code.

There was one special case allowing to let an actor die on spawn, but this could call script code on an incompletely set up map which resulted in crashes.
This commit is contained in:
Christoph Oelckers 2022-11-05 09:43:06 +01:00
parent ec1525b0c4
commit 435e7dddcd
3 changed files with 10 additions and 1 deletions

View file

@ -347,6 +347,7 @@ xx(Greetings)
xx(Idle)
xx(GenericFreezeDeath)
xx(GenericCrush)
xx(DieFromSpawn)
// Bounce state names
xx(Bounce)

View file

@ -5776,7 +5776,12 @@ AActor *FLevelLocals::SpawnMapThing (FMapThing *mthing, int position)
else
mobj->health = -int(mthing->Health);
if (mthing->Health == 0)
mobj->CallDie(NULL, NULL);
{
// We cannot call 'Die' here directly because the level is not yet fully set up.
// This needs to be delayed by one tic.
auto state = mobj->FindState(NAME_DieFromSpawn);
if (state) mobj->SetState(state, true);
}
else if (mthing->Health != 1)
mobj->StartHealth = mobj->health;

View file

@ -1360,6 +1360,9 @@ class Actor : Thinker native
GenericCrush:
POL5 A -1;
Stop;
DieFromSpawn:
TNT1 A 1;
TNT1 A 1 { self.Die(null, null); }
}
// Internal functions