- 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.
This commit is contained in:
Christoph Oelckers 2014-10-25 13:10:38 +02:00
parent edd53f22a1
commit ad2e16576c
1 changed files with 10 additions and 12 deletions

View File

@ -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);
}
}
}