diff --git a/Source/Game/Combat/CombatManager.cs b/Source/Game/Combat/CombatManager.cs index ea7135254..af0ba9707 100644 --- a/Source/Game/Combat/CombatManager.cs +++ b/Source/Game/Combat/CombatManager.cs @@ -235,6 +235,27 @@ namespace Game.Combat _pveRefs.First().Value.EndCombat(); } + public void RevalidateCombat() + { + foreach(var (guid, refe) in _pveRefs.ToList()) + { + if (!CanBeginCombat(_owner, refe.GetOther(_owner))) + { + _pveRefs.Remove(guid); // erase manually here to avoid iterator invalidation + refe.EndCombat(); + } + } + + foreach (var (guid, refe) in _pvpRefs.ToList()) + { + if (!CanBeginCombat(_owner, refe.GetOther(_owner))) + { + _pvpRefs.Remove(guid); // erase manually here to avoid iterator invalidation + refe.EndCombat(); + } + } + } + void EndAllPvPCombat() { while (!_pvpRefs.Empty()) diff --git a/Source/Game/Entities/Unit/Unit.Pets.cs b/Source/Game/Entities/Unit/Unit.Pets.cs index cc032db9b..a1cab890a 100644 --- a/Source/Game/Entities/Unit/Unit.Pets.cs +++ b/Source/Game/Entities/Unit/Unit.Pets.cs @@ -481,6 +481,7 @@ namespace Game.Entities Cypher.Assert(type != CharmType.Vehicle || (IsTypeId(TypeId.Unit) && IsVehicle())); charmer.SetCharm(this, false); + m_combatManager.RevalidateCombat(); Player playerCharmer = charmer.ToPlayer(); if (playerCharmer)