diff options
author | ariel- <ariel-@users.noreply.github.com> | 2018-03-01 20:38:07 -0300 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2021-08-18 22:57:52 +0200 |
commit | 6c642f33b58ce81eb5b1345a7f0eb89de6040251 (patch) | |
tree | 3b5948b7236ca656c39418662405ffdf118f4d46 /src | |
parent | b9ffac3afa485bff66265a3703604d15c78228d1 (diff) |
Core/Auras: added sanity checks for area auras having a different owner unit than caster
Closes #21517
(cherry picked from commit 54e841888621ce2ea6fbfde2f86842ec088cd575)
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Spells/Auras/SpellAuras.cpp | 19 | ||||
-rw-r--r-- | src/server/game/Spells/SpellMgr.cpp | 7 |
2 files changed, 24 insertions, 2 deletions
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<Unit*, uint32>& 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<SpellEffectInfo*>(effect)->TargetA = SpellImplicitTargetInfo(TARGET_UNIT_CASTER); + const_cast<SpellEffectInfo*>(effect)->TargetB = SpellImplicitTargetInfo(0); + } } // disable proc for magnet auras, they're handled differently |