From 8b8337034f4cd58a4fd97623dcfe19e850b1fe6e Mon Sep 17 00:00:00 2001 From: hondacrx Date: Tue, 18 May 2021 12:33:20 -0400 Subject: [PATCH] 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) --- Source/Game/Maps/Map.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Source/Game/Maps/Map.cs b/Source/Game/Maps/Map.cs index 657432d81..1b0d71eca 100644 --- a/Source/Game/Maps/Map.cs +++ b/Source/Game/Maps/Map.cs @@ -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 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); } }