diff --git a/Source/Game/Combat/ThreatManager.cs b/Source/Game/Combat/ThreatManager.cs index c8c6d2b7a..b98140495 100644 --- a/Source/Game/Combat/ThreatManager.cs +++ b/Source/Game/Combat/ThreatManager.cs @@ -465,7 +465,7 @@ namespace Game.Combat oldVictimRef = null; // in 99% of cases - we won't need to actually look at anything beyond the first element - ThreatReference highest = _sortedThreatList.Max(); + ThreatReference highest = _sortedThreatList.First(); // if the highest reference is offline, the entire list is offline, and we indicate this if (!highest.IsAvailable()) return null; diff --git a/Source/Game/Entities/Unit/Unit.Spells.cs b/Source/Game/Entities/Unit/Unit.Spells.cs index 9f03d0fcd..0af8aac53 100644 --- a/Source/Game/Entities/Unit/Unit.Spells.cs +++ b/Source/Game/Entities/Unit/Unit.Spells.cs @@ -3392,12 +3392,12 @@ namespace Game.Entities // this may be a dead loop if some events on aura remove will continiously apply aura on remove // 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++) - { - while (!m_appliedAuras.Empty()) - _UnapplyAura(m_appliedAuras.First(), AuraRemoveMode.Default); + { + foreach (var aurAppIter in GetAppliedAuras()) + _UnapplyAura(aurAppIter, AuraRemoveMode.Default); - while (!m_ownedAuras.Empty()) - RemoveOwnedAura(m_ownedAuras.First()); + foreach (var aurIter in GetOwnedAuras()) + RemoveOwnedAura(aurIter); const int maxIteration = 50; // give this loop a few tries, if there are still auras then log as much information as possible @@ -3608,6 +3608,10 @@ namespace Game.Entities // removes aura application from lists and unapplies effects public void _UnapplyAura(KeyValuePair pair, AuraRemoveMode removeMode) { + //Check if aura was already removed, if so just return. + if (!m_appliedAuras.Remove(pair)) + return; + AuraApplication aurApp = pair.Value; Cypher.Assert(aurApp != null); Cypher.Assert(!aurApp.HasRemoveMode()); @@ -3624,8 +3628,6 @@ namespace Game.Entities Unit caster = aura.GetCaster(); - m_appliedAuras.Remove(pair); - if (aura.GetSpellInfo().HasAnyAuraInterruptFlag()) { m_interruptableAuras.Remove(aurApp); diff --git a/Source/Game/Maps/MMapManager.cs b/Source/Game/Maps/MMapManager.cs index 5ee2b763c..47dec65fa 100644 --- a/Source/Game/Maps/MMapManager.cs +++ b/Source/Game/Maps/MMapManager.cs @@ -278,7 +278,7 @@ namespace Game if (mmap == null) return null; - return mmap.navMeshQueries[instanceId]; + return mmap.navMeshQueries.LookupByKey(instanceId); } public uint GetLoadedTilesCount() { return loadedTiles; }