Core/Auras: Fixed accessing invalid iterators in Unit::CalcHealAbsorb

Port From (https://github.com/TrinityCore/TrinityCore/commit/63b2188e75704ef4220d1e169d07179d07e898c7)
This commit is contained in:
hondacrx
2023-07-01 08:48:01 -04:00
parent 5bc15e6c2d
commit 219b1e2b36
+2 -23
View File
@@ -3738,11 +3738,7 @@ namespace Game.Entities
if (healInfo.GetHeal() == 0)
return;
// Need remove expired auras after
bool existExpired = false;
// absorb without mana cost
var vHealAbsorb = healInfo.GetTarget().GetAuraEffectsByType(AuraType.SchoolHealAbsorb);
var vHealAbsorb = new List<AuraEffect>(healInfo.GetTarget().GetAuraEffectsByType(AuraType.SchoolHealAbsorb));
for (var i = 0; i < vHealAbsorb.Count && healInfo.GetHeal() > 0; ++i)
{
AuraEffect absorbAurEff = vHealAbsorb[i];
@@ -3784,7 +3780,7 @@ namespace Game.Entities
absorbAurEff.ChangeAmount(absorbAurEff.GetAmount() - currentAbsorb);
// Aura cannot absorb anything more - remove it
if (absorbAurEff.GetAmount() <= 0)
existExpired = true;
absorbAurEff.GetBase().Remove(AuraRemoveMode.EnemySpell);
}
}
@@ -3801,23 +3797,6 @@ namespace Game.Entities
healInfo.GetTarget().SendMessageToSet(absorbLog, true);
}
}
// Remove all expired absorb auras
if (existExpired)
{
for (var i = 0; i < vHealAbsorb.Count;)
{
AuraEffect auraEff = vHealAbsorb[i];
++i;
if (auraEff.GetAmount() <= 0)
{
uint removedAuras = healInfo.GetTarget().m_removedAurasCount;
auraEff.GetBase().Remove(AuraRemoveMode.EnemySpell);
if (removedAuras + 1 < healInfo.GetTarget().m_removedAurasCount)
i = 0;
}
}
}
}
public static uint CalcArmorReducedDamage(Unit attacker, Unit victim, uint damage, SpellInfo spellInfo, WeaponAttackType attackType = WeaponAttackType.Max, uint attackerLevel = 0)