Clean up behaviors properly when moving levels

Also adds support for foreach loops with the behavior iterator.
This commit is contained in:
Boondorl 2025-01-25 10:52:54 -05:00 committed by Ricardo Luís Vaz Silva
commit 1e05bb2a55
6 changed files with 55 additions and 2 deletions

View file

@ -1607,6 +1607,7 @@ void FLevelLocals::StartTravel ()
if (Players[i]->health > 0)
{
pawn->UnlinkFromWorld (nullptr);
pawn->UnlinkBehaviorsFromLevel();
int tid = pawn->tid; // Save TID
pawn->SetTID(0);
pawn->tid = tid; // Restore TID (but no longer linked into the hash chain)
@ -1617,6 +1618,7 @@ void FLevelLocals::StartTravel ()
{
inv->ChangeStatNum (STAT_TRAVELLING);
inv->UnlinkFromWorld (nullptr);
inv->UnlinkBehaviorsFromLevel();
inv->DeleteAttachedLights();
}
}
@ -1720,6 +1722,7 @@ int FLevelLocals::FinishTravel ()
pawndup->Destroy();
}
pawn->LinkToWorld (nullptr);
pawn->LinkBehaviorsToLevel();
pawn->ClearInterpolation();
pawn->ClearFOVInterpolation();
const int tid = pawn->tid; // Save TID (actor isn't linked into the hash chain yet)
@ -1733,6 +1736,7 @@ int FLevelLocals::FinishTravel ()
inv->ChangeStatNum (STAT_INVENTORY);
inv->LinkToWorld (nullptr);
P_FindFloorCeiling(inv, FFCF_ONLYSPAWNPOS);
inv->LinkBehaviorsToLevel();
IFVIRTUALPTRNAME(inv, NAME_Inventory, Travelled)
{