Core/Combat: Fixed combat after remove charm

Port From (https://github.com/TrinityCore/TrinityCore/commit/4ed918fcb38d7fd3752899a0eafd7ad62b7217af)
This commit is contained in:
hondacrx
2022-05-30 13:26:37 -04:00
parent 91fda8f37d
commit 2276940252
2 changed files with 22 additions and 0 deletions
+21
View File
@@ -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())