diff --git a/src/actor.h b/src/actor.h index d83446827..08684bde1 100644 --- a/src/actor.h +++ b/src/actor.h @@ -627,6 +627,9 @@ public: virtual void BeginPlay(); // Called immediately after the actor is created void CallBeginPlay(); + // [ZZ] custom postbeginplay (calls E_WorldThingSpawned) + void CallPostBeginPlay() override; + void LevelSpawned(); // Called after BeginPlay if this actor was spawned by the world void HandleSpawnFlags(); // Translates SpawnFlags into in-game flags. diff --git a/src/c_console.cpp b/src/c_console.cpp index 649559966..eb4c55d02 100644 --- a/src/c_console.cpp +++ b/src/c_console.cpp @@ -1338,7 +1338,7 @@ DEFINE_ACTION_FUNCTION(_Console, Printf) { PARAM_PROLOGUE; FString s = FStringFormat(param, defaultparam, numparam, ret, numret); - Printf("%s", s); + Printf("%s\n", s); return 0; } diff --git a/src/dthinker.h b/src/dthinker.h index e0dcb607f..f86eff266 100644 --- a/src/dthinker.h +++ b/src/dthinker.h @@ -71,7 +71,7 @@ public: virtual void Tick (); void CallTick(); virtual void PostBeginPlay (); // Called just before the first tick - void CallPostBeginPlay(); + virtual void CallPostBeginPlay(); // different in actor. virtual void PostSerialize(); size_t PropagateMark(); diff --git a/src/events.cpp b/src/events.cpp index f1601911e..e61dd019a 100755 --- a/src/events.cpp +++ b/src/events.cpp @@ -4,6 +4,7 @@ #include "g_levellocals.h" #include "gi.h" #include "v_text.h" +#include "actor.h" DStaticEventHandler* E_FirstEventHandler = nullptr; @@ -232,6 +233,9 @@ void E_WorldUnloadedUnsafe() void E_WorldThingSpawned(AActor* actor) { + // don't call anything if actor was destroyed on PostBeginPlay/BeginPlay/whatever. + if (actor->ObjectFlags & OF_EuthanizeMe) + return; for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next) handler->WorldThingSpawned(actor); } diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index df6223242..b94098607 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -71,6 +71,7 @@ #include "virtual.h" #include "g_levellocals.h" #include "a_morph.h" +#include "events.h" // MACROS ------------------------------------------------------------------ @@ -4970,6 +4971,12 @@ void AActor::PostBeginPlay () flags7 |= MF7_HANDLENODELAY; } +void AActor::CallPostBeginPlay() +{ + Super::CallPostBeginPlay(); + E_WorldThingSpawned(this); +} + void AActor::MarkPrecacheSounds() const { SeeSound.MarkUsed(); diff --git a/src/scripting/codegeneration/codegen.cpp b/src/scripting/codegeneration/codegen.cpp index 8fd95c411..73a9ba1da 100644 --- a/src/scripting/codegeneration/codegen.cpp +++ b/src/scripting/codegeneration/codegen.cpp @@ -8206,9 +8206,10 @@ FxExpression *FxVMFunctionCall::Resolve(FCompileContext& ctx) if (x) { if (x->ValueType == TypeName || - x->ValueType == TypeSound) + x->ValueType == TypeSound || + x->ValueType == TypeSpriteID) // spriteID can be a string too. { - x = new FxStringCast(ArgList[i]); + x = new FxStringCast(x); x = x->Resolve(ctx); } }