From b7a8a88a76027a04dc03bd0639b9aab2a67ffd29 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Fri, 21 Apr 2023 18:32:54 -0400 Subject: [PATCH] Core/Auras: Fixed iterator invalidation crash with procs using SPELL_ATTR0_PROC_FAILURE_BURNS_CHARGE attribute Port From (https://github.com/TrinityCore/TrinityCore/commit/15451ce699540c7d175f4a24d257778dedb0e3d7) --- Source/Game/Entities/Unit/Unit.Spells.cs | 2 +- Source/Game/Spells/Auras/Aura.cs | 23 +++++++++++++---------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Source/Game/Entities/Unit/Unit.Spells.cs b/Source/Game/Entities/Unit/Unit.Spells.cs index 96eac3be7..f3f308795 100644 --- a/Source/Game/Entities/Unit/Unit.Spells.cs +++ b/Source/Game/Entities/Unit/Unit.Spells.cs @@ -1544,7 +1544,7 @@ namespace Game.Entities if (procEntry != null) { aurApp.GetBase().PrepareProcChargeDrop(procEntry, eventInfo); - aurApp.GetBase().ConsumeProcCharges(procEntry); + aurasTriggeringProc.Add(Tuple.Create(0u, aurApp)); } } diff --git a/Source/Game/Spells/Auras/Aura.cs b/Source/Game/Spells/Auras/Aura.cs index 96bc80028..3be801ca4 100644 --- a/Source/Game/Spells/Auras/Aura.cs +++ b/Source/Game/Spells/Auras/Aura.cs @@ -1884,20 +1884,23 @@ namespace Game.Spells public void TriggerProcOnEvent(uint procEffectMask, AuraApplication aurApp, ProcEventInfo eventInfo) { - bool prevented = CallScriptProcHandlers(aurApp, eventInfo); - if (!prevented) + if (procEffectMask != 0) { - for (byte i = 0; i < SpellConst.MaxEffects; ++i) + bool prevented = CallScriptProcHandlers(aurApp, eventInfo); + if (!prevented) { - if (!Convert.ToBoolean(procEffectMask & (1 << i))) - continue; + for (byte i = 0; i < SpellConst.MaxEffects; ++i) + { + if (!Convert.ToBoolean(procEffectMask & (1 << i))) + continue; - // OnEffectProc / AfterEffectProc hooks handled in AuraEffect.HandleProc() - if (aurApp.HasEffect(i)) - GetEffect(i).HandleProc(aurApp, eventInfo); + // OnEffectProc / AfterEffectProc hooks handled in AuraEffect.HandleProc() + if (aurApp.HasEffect(i)) + GetEffect(i).HandleProc(aurApp, eventInfo); + } + + CallScriptAfterProcHandlers(aurApp, eventInfo); } - - CallScriptAfterProcHandlers(aurApp, eventInfo); } ConsumeProcCharges(Global.SpellMgr.GetSpellProcEntry(GetSpellInfo()));