From 6c642f33b58ce81eb5b1345a7f0eb89de6040251 Mon Sep 17 00:00:00 2001 From: ariel- Date: Thu, 1 Mar 2018 20:38:07 -0300 Subject: Core/Auras: added sanity checks for area auras having a different owner unit than caster Closes #21517 (cherry picked from commit 54e841888621ce2ea6fbfde2f86842ec088cd575) --- src/server/game/Spells/Auras/SpellAuras.cpp | 19 +++++++++++++++++-- src/server/game/Spells/SpellMgr.cpp | 7 +++++++ 2 files changed, 24 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp index e906511df52..2a6cb060419 100644 --- a/src/server/game/Spells/Auras/SpellAuras.cpp +++ b/src/server/game/Spells/Auras/SpellAuras.cpp @@ -1022,9 +1022,21 @@ bool Aura::CanBeSaved() const return false; // Check if aura is single target, not only spell info - if (GetCasterGUID() != GetOwner()->GetGUID() || IsSingleTarget()) - if (GetSpellInfo()->IsSingleTarget()) + if (GetCasterGUID() != GetOwner()->GetGUID()) + { + // owner == caster for area auras, check for possible bad data in DB + for (SpellEffectInfo const* effect : GetSpellInfo()->GetEffects()) + { + if (!effect || !effect->IsEffect()) + continue; + + if (effect->IsTargetingArea() || effect->IsAreaAuraEffect()) + return false; + } + + if (IsSingleTarget() || GetSpellInfo()->IsSingleTarget()) return false; + } if (GetSpellInfo()->HasAttribute(SPELL_ATTR0_CU_AURA_CANNOT_BE_SAVED)) return false; @@ -2283,6 +2295,9 @@ void UnitAura::FillTargetMap(std::unordered_map& targets, Unit* c } else { + ASSERT(caster, "Area aura (Id: %u) has nullptr caster (%s)", m_spellInfo->Id, GetCasterGUID().ToString().c_str()); + ASSERT(GetCasterGUID() == GetUnitOwner()->GetGUID(), "Area aura (Id: %u) has owner (%s) different to caster (%s)", m_spellInfo->Id, GetUnitOwner()->GetGUID().ToString().c_str(), GetCasterGUID().ToString().c_str()); + // skip area update if owner is not in world! if (!GetUnitOwner()->IsInWorld()) continue; diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index 8422ff6360c..d07cd6a54cb 100644 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -4541,6 +4541,13 @@ void SpellMgr::LoadSpellInfoCorrections() if (effect->TargetA.GetSelectionCategory() == TARGET_SELECT_CATEGORY_CONE || effect->TargetB.GetSelectionCategory() == TARGET_SELECT_CATEGORY_CONE) if (G3D::fuzzyEq(spellInfo->ConeAngle, 0.f)) spellInfo->ConeAngle = 90.f; + + // Area auras may not target area (they're self cast) + if (effect->IsAreaAuraEffect() && effect->IsTargetingArea()) + { + const_cast(effect)->TargetA = SpellImplicitTargetInfo(TARGET_UNIT_CASTER); + const_cast(effect)->TargetB = SpellImplicitTargetInfo(0); + } } // disable proc for magnet auras, they're handled differently -- cgit v1.2.3