diff options
author | Carbenium <carbenium@outlook.com> | 2015-09-23 22:32:03 +0200 |
---|---|---|
committer | Carbenium <carbenium@outlook.com> | 2015-09-23 22:32:03 +0200 |
commit | a40d855337bd29f55d898fb5213af92abd5b43a1 (patch) | |
tree | 89b9550edff51064f4e1a6668e2a4407070bac0d /src | |
parent | a3dbb0dd9caa1af61ff4e313ef1b75a98c17e30b (diff) | |
parent | 3c188ac10e48f448489b7d9067d56a60e107c1ca (diff) |
Merge pull request #15538 from pete318/combat_bug
Combat with distant creatures (Mk II)
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Maps/Map.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index 22cc1f1bbd0..b50099b9787 100644 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -678,6 +678,26 @@ void Map::Update(const uint32 t_diff) player->Update(t_diff); VisitNearbyCellsOf(player, grid_object_update, world_object_update); + + // Handle updates for creatures in combat with player and are more than 60 yards away + if (player->IsInCombat()) + { + std::vector<Creature*> updateList; + HostileReference* ref = player->getHostileRefManager().getFirst(); + + while (ref) + { + if (Unit* unit = ref->GetSource()->GetOwner()) + if (unit->ToCreature() && unit->GetMapId() == player->GetMapId() && !unit->IsWithinDistInMap(player, GetVisibilityRange(), false)) + updateList.push_back(unit->ToCreature()); + + ref = ref->next(); + } + + // Process deferred update list for player + for (Creature* c : updateList) + VisitNearbyCellsOf(c, grid_object_update, world_object_update); + } } // non-player active objects, increasing iterator in the loop in case of object removal |