diff --git a/src/actor.h b/src/actor.h index e6ae8d9f8..30e67fa30 100644 --- a/src/actor.h +++ b/src/actor.h @@ -647,6 +647,8 @@ public: // Returns true if this actor is within melee range of its target bool CheckMeleeRange(); + bool CheckNoDelay(); + virtual void BeginPlay(); // Called immediately after the actor is created virtual void PostBeginPlay(); // Called immediately before the actor's first tick virtual void LevelSpawned(); // Called after BeginPlay if this actor was spawned by the world diff --git a/src/g_shared/a_fastprojectile.cpp b/src/g_shared/a_fastprojectile.cpp index da71358f9..4f103be57 100644 --- a/src/g_shared/a_fastprojectile.cpp +++ b/src/g_shared/a_fastprojectile.cpp @@ -138,17 +138,8 @@ void AFastProjectile::Tick () } } } - if ((flags7 & MF7_HANDLENODELAY) && !(flags2 & MF2_DORMANT)) - { - flags7 &= ~MF7_HANDLENODELAY; - if (state->GetNoDelay()) - { - // For immediately spawned objects with the NoDelay flag set for their - // Spawn state, explicitly call the current state's function. - if (state->CallAction(this, this) && (ObjectFlags & OF_EuthanizeMe)) - return; // freed itself - } - } + if (!CheckNoDelay()) + return; // freed itself // Advance the state if (tics != -1) { diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index a7573f4dc..eba7f86fd 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -3841,17 +3841,8 @@ void AActor::Tick () Destroy(); return; } - if ((flags7 & MF7_HANDLENODELAY) && !(flags2 & MF2_DORMANT)) - { - flags7 &= ~MF7_HANDLENODELAY; - if (state->GetNoDelay()) - { - // For immediately spawned objects with the NoDelay flag set for their - // Spawn state, explicitly call the current state's function. - if (state->CallAction(this, this) && (ObjectFlags & OF_EuthanizeMe)) - return; // freed itself - } - } + if (!CheckNoDelay()) + return; // freed itself // cycle through states, calling action functions at transitions if (tics != -1) { @@ -3892,6 +3883,38 @@ void AActor::Tick () } } +//========================================================================== +// +// AActor :: CheckNoDelay +// +//========================================================================== + +bool AActor::CheckNoDelay() +{ + if ((flags7 & MF7_HANDLENODELAY) && !(flags2 & MF2_DORMANT)) + { + flags7 &= ~MF7_HANDLENODELAY; + if (state->GetNoDelay()) + { + // For immediately spawned objects with the NoDelay flag set for their + // Spawn state, explicitly call the current state's function. + if (state->CallAction(this, this)) + { + if (ObjectFlags & OF_EuthanizeMe) + { + return false; // freed itself + } + if (ObjectFlags & OF_StateChanged) + { + ObjectFlags &= ~OF_StateChanged; + return SetState(state); + } + } + } + } + return true; +} + //========================================================================== // // AActor :: CheckSectorTransition