Core/Spells: Fix assert triggered

Fix assert triggered when a spell would trigger another spell in OnEffectHitTarget that would kill the aura owner, then processing the main spell effects. The triggered spell can kill the aura owner, changing its death state to CORPSE and removing auras created.

Fix #21856
Ref 518e6299ca
This commit is contained in:
jackpoz
2019-02-02 21:00:28 +01:00
parent 806dd940ce
commit 46c7446bd4

View File

@@ -3291,9 +3291,14 @@ AuraApplication* Unit::_CreateAuraApplication(Aura* aura, uint8 effMask)
{
// can't apply aura on unit which is going to be deleted - to not create a memory leak
ASSERT(!m_cleanupDone);
// aura musn't be removed (but it could have been removed by OnEffectHitTarget script handler
// casting a spell that killed the target and set deathState to CORPSE)
ASSERT(!aura->IsRemoved() || !IsAlive());
// just return if the aura has been already removed
// this can happen if OnEffectHitTarget() script hook killed the unit or the aura owner (which can be different)
if (aura->IsRemoved())
{
TC_LOG_ERROR("spells", "Unit::_CreateAuraApplication() called with a removed aura. Check if OnEffectHitTarget() is triggering any spell with apply aura effect (that's not allowed!)\nUnit: %s\nAura: %s", GetDebugInfo().c_str(), aura->GetDebugInfo().c_str());
return nullptr;
}
// aura mustn't be already applied on target
ASSERT (!aura->IsAppliedOnTarget(GetGUID()) && "Unit::_CreateAuraApplication: aura musn't be applied on target");