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

Closes #21517
This commit is contained in:
ariel-
2018-03-01 20:38:07 -03:00
parent fbb92047d7
commit 54e8418886
2 changed files with 23 additions and 1 deletions

View File

@@ -1019,8 +1019,20 @@ bool Aura::CanBeSaved() const
// Check if aura is single target, not only spell info
if (GetCasterGUID() != GetOwner()->GetGUID())
if (GetSpellInfo()->IsSingleTarget() || IsSingleTarget())
{
// owner == caster for area auras, check for possible bad data in DB
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
if (!GetSpellInfo()->Effects[i].IsEffect())
continue;
if (GetSpellInfo()->Effects[i].IsTargetingArea() || GetSpellInfo()->Effects[i].IsAreaAuraEffect())
return false;
}
if (IsSingleTarget() || GetSpellInfo()->IsSingleTarget())
return false;
}
// Can't be saved - aura handler relies on calculated amount and changes it
if (HasEffectType(SPELL_AURA_CONVERT_RUNE))
@@ -2521,6 +2533,9 @@ void UnitAura::FillTargetMap(std::unordered_map<Unit*, uint8>& targets, Unit* ca
}
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

@@ -4814,6 +4814,13 @@ void SpellMgr::LoadSpellInfoCorrections()
if (spellInfo->IsPassive() && GetTalentSpellCost(i))
if (spellInfo->Effects[j].TargetA.GetTarget() == TARGET_UNIT_PET)
spellInfo->Effects[j].TargetA = SpellImplicitTargetInfo(TARGET_UNIT_CASTER);
// Area auras may not target area (they're self cast)
if (spellInfo->Effects[j].IsAreaAuraEffect() && spellInfo->Effects[j].IsTargetingArea())
{
spellInfo->Effects[j].TargetA = SpellImplicitTargetInfo(TARGET_UNIT_CASTER);
spellInfo->Effects[j].TargetB = SpellImplicitTargetInfo(0);
}
}
// disable proc for magnet auras, they're handled differently