diff --git a/src/dobject.h b/src/dobject.h index 6b9b87c75..dd03f669a 100644 --- a/src/dobject.h +++ b/src/dobject.h @@ -208,6 +208,7 @@ enum EObjectFlags OF_SerialSuccess = 1 << 9, // For debugging Serialize() calls 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_Spawned = 1 << 12, // Thinker was spawned at all (some thinkers get deleted before spawning) }; template class TObjPtr; diff --git a/src/dthinker.cpp b/src/dthinker.cpp index 7b63d2635..da68d8388 100644 --- a/src/dthinker.cpp +++ b/src/dthinker.cpp @@ -309,6 +309,7 @@ DEFINE_ACTION_FUNCTION(DThinker, PostBeginPlay) void DThinker::CallPostBeginPlay() { + ObjectFlags |= OF_Spawned; IFVIRTUAL(DThinker, PostBeginPlay) { // Without the type cast this picks the 'void *' assignment... diff --git a/src/events.cpp b/src/events.cpp index 3fb90dcbb..682b6da54 100755 --- a/src/events.cpp +++ b/src/events.cpp @@ -273,6 +273,10 @@ void E_WorldThingDestroyed(AActor* actor) // don't call anything if actor was destroyed on PostBeginPlay/BeginPlay/whatever. if (actor->ObjectFlags & OF_EuthanizeMe) 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) handler->WorldThingDestroyed(actor); }