From b00d3812ab1b40636c79889e705042d8198b0c17 Mon Sep 17 00:00:00 2001 From: Treeston Date: Thu, 4 Jan 2018 15:19:37 +0100 Subject: Core/Map: Fix a crash that could happen if a player moved very far away from a creature they were in combat with. Closes #21177. (cherry picked from commit e0b609a178528995959e5ea54255a3f856e62913) --- src/server/game/Maps/Map.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index 557bec6dbd0..088cf8625ed 100644 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -875,10 +875,13 @@ void Map::Update(uint32 t_diff) // Handle updates for creatures in combat with player and are more than 60 yards away if (player->IsInCombat()) { + std::vector toVisit; for (auto const& pair : player->GetCombatManager().GetPvECombatRefs()) if (Creature* unit = pair.second->GetOther(player)->ToCreature()) if (unit->GetMapId() == player->GetMapId() && !unit->IsWithinDistInMap(player, GetVisibilityRange(), false)) - VisitNearbyCellsOf(unit, grid_object_update, world_object_update); + toVisit.push_back(unit); + for (Unit* unit : toVisit) + VisitNearbyCellsOf(unit, grid_object_update, world_object_update); } } -- cgit v1.2.3