aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjackpoz <giacomopoz@gmail.com>2019-02-02 21:00:28 +0100
committerjackpoz <giacomopoz@gmail.com>2019-02-02 21:00:28 +0100
commit46c7446bd4ef606b1091c1582df50e027fab28b6 (patch)
tree5cbc8f2f4d2aba43b50b060b09bbc20b968ffeb2
parent806dd940cec8352cc3a619b9cab39c95d7b86e59 (diff)
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 518e6299ca08a362bc3709daaaa5e5d5633d1bf1
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 19751409268..a7868af74b7 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -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");