From 8caa99803f5f43337fa0f8855cc51cde08450a8b Mon Sep 17 00:00:00 2001 From: hondacrx Date: Mon, 1 Aug 2022 11:32:31 -0400 Subject: [PATCH] Fixes aura assert by not removing player when crash from map. --- Source/Game/Entities/Unit/Unit.Spells.cs | 8 ++++---- Source/Game/Spells/Auras/Aura.cs | 9 ++++----- Source/Game/World/WorldManager.cs | 1 + 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Source/Game/Entities/Unit/Unit.Spells.cs b/Source/Game/Entities/Unit/Unit.Spells.cs index 07de1ca0e..9f03d0fcd 100644 --- a/Source/Game/Entities/Unit/Unit.Spells.cs +++ b/Source/Game/Entities/Unit/Unit.Spells.cs @@ -3393,11 +3393,11 @@ namespace Game.Entities // we want to have all auras removed, so use your brain when linking events for (int counter = 0; !m_appliedAuras.Empty() || !m_ownedAuras.Empty(); counter++) { - foreach (var aurAppIter in GetAppliedAuras()) - _UnapplyAura(aurAppIter, AuraRemoveMode.Default); + while (!m_appliedAuras.Empty()) + _UnapplyAura(m_appliedAuras.First(), AuraRemoveMode.Default); - foreach (var aurIter in GetOwnedAuras()) - RemoveOwnedAura(aurIter); + while (!m_ownedAuras.Empty()) + RemoveOwnedAura(m_ownedAuras.First()); const int maxIteration = 50; // give this loop a few tries, if there are still auras then log as much information as possible diff --git a/Source/Game/Spells/Auras/Aura.cs b/Source/Game/Spells/Auras/Aura.cs index 86d524d07..82ea458e1 100644 --- a/Source/Game/Spells/Auras/Aura.cs +++ b/Source/Game/Spells/Auras/Aura.cs @@ -517,27 +517,26 @@ namespace Game.Spells // mark all auras as ready to remove foreach (var app in m_applications) { - var existing = targets.FirstOrDefault(p => p.Key == app.Value.GetTarget()); // not found in current area - remove the aura - if (existing.Key == null) + if (!targets.TryGetValue(app.Value.GetTarget(), out uint existing)) targetsToRemove.Add(app.Value.GetTarget()); else { // needs readding - remove now, will be applied in next update cycle // (dbcs do not have auras which apply on same type of targets but have different radius, so this is not really needed) - if (!CanBeAppliedOn(existing.Key)) + if (!CanBeAppliedOn(app.Value.GetTarget())) { targetsToRemove.Add(app.Value.GetTarget()); continue; } // needs to add/remove effects from application, don't remove from map so it gets updated - if (app.Value.GetEffectMask() != existing.Value) + if (app.Value.GetEffectMask() != existing) continue; // nothing to do - aura already applied // remove from auras to register list - targets.Remove(existing.Key); + targets.Remove(app.Value.GetTarget()); } } // register auras for units diff --git a/Source/Game/World/WorldManager.cs b/Source/Game/World/WorldManager.cs index ece5f38a4..a0fec302f 100644 --- a/Source/Game/World/WorldManager.cs +++ b/Source/Game/World/WorldManager.cs @@ -236,6 +236,7 @@ namespace Game decrease_session = false; m_sessionsByBnetGuid.Remove(old.GetBattlenetAccountGUID(), old); + old.Dispose(); } }