Core/Map: Fix a crash that could happen if a player moved very far away from a creature they were in combat with.

Port From (https://github.com/TrinityCore/TrinityCore/commit/b00d3812ab1b40636c79889e705042d8198b0c17)
This commit is contained in:
hondacrx
2021-05-18 12:33:20 -04:00
parent 66ba3fe724
commit 8b8337034f
+5 -1
View File
@@ -762,13 +762,17 @@ namespace Game.Maps
// Handle updates for creatures in combat with player and are more than 60 yards away
if (player.IsInCombat())
{
List<Unit> toVisit = new();
foreach (var pair in player.GetCombatManager().GetPvECombatRefs())
{
Creature unit = pair.Value.GetOther(player).ToCreature();
if (unit != null)
if (unit.GetMapId() == player.GetMapId() && !unit.IsWithinDistInMap(player, GetVisibilityRange(), false))
VisitNearbyCellsOf(unit, grid_object_update, world_object_update);
toVisit.Add(unit);
}
foreach (Unit unit in toVisit)
VisitNearbyCellsOf(unit, grid_object_update, world_object_update);
}
}