aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjackpoz <giacomopoz@gmail.com>2019-02-02 21:00:28 +0100
committerShauren <shauren.trinity@gmail.com>2021-11-23 20:47:31 +0100
commite475cac63134be27d0902cb0d3efd869217bb464 (patch)
tree750bd300ca41af885a9cf0e70b27ed3aefb3bb54 /src
parent31f4bb14365ebe09c72a516eca7d5d48c6228ced (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 (cherry picked from commit 46c7446bd4ef606b1091c1582df50e027fab28b6)
Diffstat (limited to 'src')
-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 639e6e33593..af852db65e0 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -3184,9 +3184,14 @@ AuraApplication* Unit::_CreateAuraApplication(Aura* aura, uint32 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");