- made setting actor TID more explicit

Now it's no longer possible to manipulate TID hash from arbitrary location
For example, this prevents linking of destroyed object into the hash
TID member is still public but writing to it is limited to a few very specific cases like serialization and player traveling between levels

https://forum.zdoom.org/viewtopic.php?t=64476
This commit is contained in:
alexey.lysiuk 2019-05-10 11:55:46 +03:00 committed by Christoph Oelckers
commit f5d80d0d8b
9 changed files with 42 additions and 38 deletions

View file

@ -2906,6 +2906,8 @@ void P_NightmareRespawn (AActor *mobj)
//
void AActor::AddToHash ()
{
assert(!(ObjectFlags & OF_EuthanizeMe));
if (tid == 0)
{
iprev = NULL;
@ -2947,6 +2949,23 @@ void AActor::RemoveFromHash ()
tid = 0;
}
void AActor::SetTID (int newTID)
{
RemoveFromHash();
if (ObjectFlags & OF_EuthanizeMe)
{
// Do not assign TID and do not link actor into the hash
// if it was already destroyed and will be freed by GC
return;
}
tid = newTID;
AddToHash();
}
//==========================================================================
//
// P_IsTIDUsed
@ -5465,8 +5484,7 @@ AActor *FLevelLocals::SpawnMapThing (FMapThing *mthing, int position)
}
// [RH] Add ThingID to mobj and link it in with the others
mobj->tid = mthing->thingid;
mobj->AddToHash ();
mobj->SetTID(mthing->thingid);
mobj->PrevAngles.Yaw = mobj->Angles.Yaw = (double)mthing->angle;