Since WorldThingDestroyed is the reverse of WorldThingSpawned, it should ignore actors that didn't call PostBeginPlay.

This commit is contained in:
ZZYZX 2017-01-31 04:53:18 +02:00
parent 89c475c2d1
commit 26d38e6527
3 changed files with 6 additions and 0 deletions

View file

@ -208,6 +208,7 @@ enum EObjectFlags
OF_SerialSuccess = 1 << 9, // For debugging Serialize() calls OF_SerialSuccess = 1 << 9, // For debugging Serialize() calls
OF_Sentinel = 1 << 10, // Object is serving as the sentinel in a ring list OF_Sentinel = 1 << 10, // Object is serving as the sentinel in a ring list
OF_Transient = 1 << 11, // Object should not be archived (references to it will be nulled on disk) OF_Transient = 1 << 11, // Object should not be archived (references to it will be nulled on disk)
OF_Spawned = 1 << 12, // Thinker was spawned at all (some thinkers get deleted before spawning)
}; };
template<class T> class TObjPtr; template<class T> class TObjPtr;

View file

@ -309,6 +309,7 @@ DEFINE_ACTION_FUNCTION(DThinker, PostBeginPlay)
void DThinker::CallPostBeginPlay() void DThinker::CallPostBeginPlay()
{ {
ObjectFlags |= OF_Spawned;
IFVIRTUAL(DThinker, PostBeginPlay) IFVIRTUAL(DThinker, PostBeginPlay)
{ {
// Without the type cast this picks the 'void *' assignment... // Without the type cast this picks the 'void *' assignment...

View file

@ -273,6 +273,10 @@ void E_WorldThingDestroyed(AActor* actor)
// don't call anything if actor was destroyed on PostBeginPlay/BeginPlay/whatever. // don't call anything if actor was destroyed on PostBeginPlay/BeginPlay/whatever.
if (actor->ObjectFlags & OF_EuthanizeMe) if (actor->ObjectFlags & OF_EuthanizeMe)
return; return;
// don't call anything for non-spawned things (i.e. those that were created, but immediately destroyed)
// this is because Destroyed should be reverse of Spawned. we don't want to catch random inventory give failures.
if (!(actor->ObjectFlags & OF_Spawned))
return;
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next) for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next)
handler->WorldThingDestroyed(actor); handler->WorldThingDestroyed(actor);
} }