Core/Auras: added sanity checks for area auras having a different owner unit than caster

Closes #21517

(cherry picked from commit 54e8418886)
This commit is contained in:
ariel-
2018-03-01 20:38:07 -03:00
committed by Shauren
parent b9ffac3afa
commit 6c642f33b5
2 changed files with 24 additions and 2 deletions

View File

@@ -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;

View File

@@ -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