From 219b1e2b36296c1d58b327accbfd43b28f96ac6f Mon Sep 17 00:00:00 2001 From: hondacrx Date: Sat, 1 Jul 2023 08:48:01 -0400 Subject: [PATCH] Core/Auras: Fixed accessing invalid iterators in Unit::CalcHealAbsorb Port From (https://github.com/TrinityCore/TrinityCore/commit/63b2188e75704ef4220d1e169d07179d07e898c7) --- Source/Game/Entities/Unit/Unit.cs | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/Source/Game/Entities/Unit/Unit.cs b/Source/Game/Entities/Unit/Unit.cs index 0f45d075e..6a713fb3e 100644 --- a/Source/Game/Entities/Unit/Unit.cs +++ b/Source/Game/Entities/Unit/Unit.cs @@ -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(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)