From 63659ea18b837a2f9c330de6c70dba16089d5c53 Mon Sep 17 00:00:00 2001 From: n0n4m3 Date: Thu, 17 Dec 2009 11:40:23 +0100 Subject: Update some code for 322a --HG-- branch : trunk --- src/game/Object.cpp | 54 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 20 deletions(-) (limited to 'src/game/Object.cpp') diff --git a/src/game/Object.cpp b/src/game/Object.cpp index 6aa4b3949c5..3e619104272 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -1932,38 +1932,52 @@ Creature* WorldObject::SummonTrigger(float x, float y, float z, float ang, uint3 return summon; } -Creature* WorldObject::FindNearestCreature(uint32 uiEntry, float fMaxSearchRange, bool bAlive) +Creature* WorldObject::FindNearestCreature(uint32 entry, float range, bool alive) { - Creature *pCreature = NULL; - Trinity::NearestCreatureEntryWithLiveStateInObjectRangeCheck checker(*this, uiEntry, bAlive, fMaxSearchRange); - Trinity::CreatureLastSearcher searcher(this, pCreature, checker); - VisitNearbyObject(fMaxSearchRange, searcher); - return pCreature; + Creature *creature = NULL; + Trinity::NearestCreatureEntryWithLiveStateInObjectRangeCheck checker(*this, entry, alive, range); + Trinity::CreatureLastSearcher searcher(this, creature, checker); + VisitNearbyObject(range, searcher); + return creature; } -GameObject* WorldObject::FindNearestGameObject(uint32 uiEntry, float fMaxSearchRange) +GameObject* WorldObject::FindNearestGameObject(uint32 entry, float range) { - GameObject *pGO = NULL; - Trinity::NearestGameObjectEntryInObjectRangeCheck checker(*this, uiEntry, fMaxSearchRange); - Trinity::GameObjectLastSearcher searcher(this, pGO, checker); - VisitNearbyGridObject(fMaxSearchRange, searcher); - return pGO; + GameObject *go = NULL; + Trinity::NearestGameObjectEntryInObjectRangeCheck checker(*this, entry, range); + Trinity::GameObjectLastSearcher searcher(this, go, checker); + VisitNearbyGridObject(range, searcher); + return go; +} + +void WorldObject::GetGameObjectListWithEntryInGrid(std::list& lList, uint32 uiEntry, float fMaxSearchRange) +{ + CellPair pair(Trinity::ComputeCellPair(this->GetPositionX(), this->GetPositionY())); + Cell cell(pair); + cell.data.Part.reserved = ALL_DISTRICT; + cell.SetNoCreate(); + + Trinity::AllGameObjectsWithEntryInRange check(this, uiEntry, fMaxSearchRange); + Trinity::GameObjectListSearcher searcher(this, lList, check); + TypeContainerVisitor, GridTypeMapContainer> visitor(searcher); + + CellLock cell_lock(cell, pair); + cell_lock->Visit(cell_lock, visitor, *(this->GetMap())); } void WorldObject::GetCreatureListWithEntryInGrid(std::list& lList, uint32 uiEntry, float fMaxSearchRange) { + CellPair pair(Trinity::ComputeCellPair(this->GetPositionX(), this->GetPositionY())); + Cell cell(pair); + cell.data.Part.reserved = ALL_DISTRICT; + cell.SetNoCreate(); + Trinity::AllCreaturesOfEntryInRange check(this, uiEntry, fMaxSearchRange); Trinity::CreatureListSearcher searcher(this, lList, check); TypeContainerVisitor, GridTypeMapContainer> visitor(searcher); - VisitNearbyObject(fMaxSearchRange, searcher); -} -void WorldObject::GetGameObjectListWithEntryInGrid(std::list& lList, uint32 uiEntry, float fMaxSearchRange) -{ - Trinity::AllGameObjectsWithEntryInRange check(this, uiEntry, fMaxSearchRange); - Trinity::GameObjectListSearcher searcher(this, lList, check); - TypeContainerVisitor, GridTypeMapContainer> visitor(searcher); - VisitNearbyGridObject(fMaxSearchRange, searcher); + CellLock cell_lock(cell, pair); + cell_lock->Visit(cell_lock, visitor, *(this->GetMap())); } /* -- cgit v1.2.3