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

Port From (https://github.com/TrinityCore/TrinityCore/commit/6c642f33b58ce81eb5b1345a7f0eb89de6040251)
This commit is contained in:
hondacrx
2021-08-20 18:50:01 -04:00
parent 129c973ca0
commit 936f9d4d93
2 changed files with 24 additions and 2 deletions
+17 -2
View File
@@ -965,9 +965,21 @@ namespace Game.Spells
return false; return false;
// Check if aura is single target, not only spell info // Check if aura is single target, not only spell info
if (GetCasterGUID() != GetOwner().GetGUID() || IsSingleTarget()) if (GetCasterGUID() != GetOwner().GetGUID())
if (GetSpellInfo().IsSingleTarget()) {
// owner == caster for area auras, check for possible bad data in DB
foreach (SpellEffectInfo effect in GetSpellInfo().GetEffects())
{
if (effect == null || !effect.IsEffect())
continue;
if (effect.IsTargetingArea() || effect.IsAreaAuraEffect())
return false;
}
if (IsSingleTarget() || GetSpellInfo().IsSingleTarget())
return false; return false;
}
if (GetSpellInfo().HasAttribute(SpellCustomAttributes.AuraCannotBeSaved)) if (GetSpellInfo().HasAttribute(SpellCustomAttributes.AuraCannotBeSaved))
return false; return false;
@@ -2547,6 +2559,9 @@ namespace Game.Spells
} }
else else
{ {
Cypher.Assert(caster != null, $"Area aura (Id: {GetSpellInfo().Id}) has nullptr caster ({GetCasterGUID()})");
Cypher.Assert(GetCasterGUID() == GetUnitOwner().GetGUID(), $"Area aura (Id: {GetSpellInfo().Id}) has owner ({GetUnitOwner().GetGUID()}) different to caster ({GetCasterGUID()})");
// skip area update if owner is not in world! // skip area update if owner is not in world!
if (!GetUnitOwner().IsInWorld) if (!GetUnitOwner().IsInWorld)
continue; continue;
+7
View File
@@ -2962,6 +2962,13 @@ namespace Game.Entities
if (effect.TargetA.GetSelectionCategory() == SpellTargetSelectionCategories.Cone || effect.TargetB.GetSelectionCategory() == SpellTargetSelectionCategories.Cone) if (effect.TargetA.GetSelectionCategory() == SpellTargetSelectionCategories.Cone || effect.TargetB.GetSelectionCategory() == SpellTargetSelectionCategories.Cone)
if (MathFunctions.fuzzyEq(spellInfo.ConeAngle, 0.0f)) if (MathFunctions.fuzzyEq(spellInfo.ConeAngle, 0.0f))
spellInfo.ConeAngle = 90.0f; spellInfo.ConeAngle = 90.0f;
// Area auras may not target area (they're self cast)
if (effect.IsAreaAuraEffect() && effect.IsTargetingArea())
{
effect.TargetA = new(Targets.UnitCaster);
effect.TargetB = new();
}
} }
// disable proc for magnet auras, they're handled differently // disable proc for magnet auras, they're handled differently