diff options
| author | Shauren <shauren.trinity@gmail.com> | 2015-06-08 17:48:21 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2015-06-08 17:48:21 +0200 |
| commit | cb854a2b7bb7bd96cf9c4d1daf3789f797bf4db8 (patch) | |
| tree | bbea9fb4edd6d3dd5a218a0fc5a77eaf59edc944 /src/server/game/AI/SmartScripts | |
| parent | ac53442e4f65bdba7a4341265d5c352d120ca057 (diff) | |
Core/Maps: Removed dbguid/spawnid grid searchers, they are no longer neccessary
Diffstat (limited to 'src/server/game/AI/SmartScripts')
| -rw-r--r-- | src/server/game/AI/SmartScripts/SmartScript.h | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/src/server/game/AI/SmartScripts/SmartScript.h b/src/server/game/AI/SmartScripts/SmartScript.h index 0233d1aa7d0..c5cc5aedb43 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.h +++ b/src/server/game/AI/SmartScripts/SmartScript.h @@ -177,33 +177,25 @@ class SmartScript GameObject* FindGameObjectNear(WorldObject* searchObject, ObjectGuid::LowType guid) const { - GameObject* gameObject = NULL; + auto bounds = searchObject->GetMap()->GetGameObjectBySpawnIdStore().equal_range(guid); + if (bounds.first == bounds.second) + return nullptr; - CellCoord p(Trinity::ComputeCellCoord(searchObject->GetPositionX(), searchObject->GetPositionY())); - Cell cell(p); - - Trinity::GameObjectWithDbGUIDCheck goCheck(*searchObject, guid); - Trinity::GameObjectSearcher<Trinity::GameObjectWithDbGUIDCheck> checker(searchObject, gameObject, goCheck); - - TypeContainerVisitor<Trinity::GameObjectSearcher<Trinity::GameObjectWithDbGUIDCheck>, GridTypeMapContainer > objectChecker(checker); - cell.Visit(p, objectChecker, *searchObject->GetMap(), *searchObject, searchObject->GetGridActivationRange()); - - return gameObject; + return bounds.first->second; } Creature* FindCreatureNear(WorldObject* searchObject, ObjectGuid::LowType guid) const { - Creature* creature = NULL; - CellCoord p(Trinity::ComputeCellCoord(searchObject->GetPositionX(), searchObject->GetPositionY())); - Cell cell(p); + auto bounds = searchObject->GetMap()->GetCreatureBySpawnIdStore().equal_range(guid); + if (bounds.first == bounds.second) + return nullptr; - Trinity::CreatureWithDbGUIDCheck target_check(searchObject, guid); - Trinity::CreatureSearcher<Trinity::CreatureWithDbGUIDCheck> checker(searchObject, creature, target_check); - - TypeContainerVisitor<Trinity::CreatureSearcher <Trinity::CreatureWithDbGUIDCheck>, GridTypeMapContainer > unit_checker(checker); - cell.Visit(p, unit_checker, *searchObject->GetMap(), *searchObject, searchObject->GetGridActivationRange()); + auto creatureItr = std::find_if(bounds.first, bounds.second, [](Map::CreatureBySpawnIdContainer::value_type const& pair) + { + return pair.second->IsAlive(); + }); - return creature; + return creatureItr != bounds.second ? creatureItr->second : bounds.first->second; } ObjectListMap* mTargetStorage; |
