From ad2e16576c078ead9c67219af691f4754d527969 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 25 Oct 2014 13:10:38 +0200 Subject: [PATCH] - fixed_ P_ExplodeMissile skipped most of its logic when the missile got destroyed by having no death state. Apparently a band-aid fix was applied to this function because AActor::Destroy could not be called on an already destroyed actor again which could happen here due to incorrect ordering of actions. Moving the state change to a later point in this function - after hitting a sky has been checked and decals have been spawned - returns everything to a safe state and ensures that nothing gets skipped. --- src/p_mobj.cpp | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index a67b96dfb9..2b0782b8fe 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -1199,13 +1199,7 @@ void P_ExplodeMissile (AActor *mo, line_t *line, AActor *target) if (nextstate == NULL) nextstate = mo->FindState(NAME_Death, NAME_Extreme); } if (nextstate == NULL) nextstate = mo->FindState(NAME_Death); - mo->SetState (nextstate); - if (mo->ObjectFlags & OF_EuthanizeMe) - { - return; - } - if (line != NULL && line->special == Line_Horizon && !(mo->flags3 & MF3_SKYEXPLODE)) { // [RH] Don't explode missiles on horizon lines. @@ -1280,8 +1274,17 @@ void P_ExplodeMissile (AActor *mo, line_t *line, AActor *target) } } - if (nextstate != NULL) + // play the sound before changing the state, so that AActor::Destroy can call S_RelinkSounds on it and the death state can override it. + if (mo->DeathSound) { + S_Sound (mo, CHAN_VOICE, mo->DeathSound, 1, + (mo->flags3 & MF3_FULLVOLDEATH) ? ATTN_NONE : ATTN_NORM); + } + + mo->SetState (nextstate); + if (!(mo->ObjectFlags & OF_EuthanizeMe)) + { + // The rest only applies if the missile actor still exists. // [RH] Change render style of exploding rockets if (mo->flags5 & MF5_DEHEXPLOSION) { @@ -1314,11 +1317,6 @@ void P_ExplodeMissile (AActor *mo, line_t *line, AActor *target) mo->flags &= ~MF_MISSILE; - if (mo->DeathSound) - { - S_Sound (mo, CHAN_VOICE, mo->DeathSound, 1, - (mo->flags3 & MF3_FULLVOLDEATH) ? ATTN_NONE : ATTN_NORM); - } } }