aboutsummaryrefslogtreecommitdiff
path: root/src/game/Object.cpp
diff options
context:
space:
mode:
authorn0n4m3 <none@none>2009-12-17 11:40:23 +0100
committern0n4m3 <none@none>2009-12-17 11:40:23 +0100
commit63659ea18b837a2f9c330de6c70dba16089d5c53 (patch)
treec9e50231f2374ae58a7bc4fac6162755e6963b84 /src/game/Object.cpp
parent5953596cee670517df4cf35fb1d428f9862a01b2 (diff)
Update some code for 322a
--HG-- branch : trunk
Diffstat (limited to 'src/game/Object.cpp')
-rw-r--r--src/game/Object.cpp54
1 files changed, 34 insertions, 20 deletions
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<Trinity::NearestCreatureEntryWithLiveStateInObjectRangeCheck> searcher(this, pCreature, checker);
- VisitNearbyObject(fMaxSearchRange, searcher);
- return pCreature;
+ Creature *creature = NULL;
+ Trinity::NearestCreatureEntryWithLiveStateInObjectRangeCheck checker(*this, entry, alive, range);
+ Trinity::CreatureLastSearcher<Trinity::NearestCreatureEntryWithLiveStateInObjectRangeCheck> 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<Trinity::NearestGameObjectEntryInObjectRangeCheck> searcher(this, pGO, checker);
- VisitNearbyGridObject(fMaxSearchRange, searcher);
- return pGO;
+ GameObject *go = NULL;
+ Trinity::NearestGameObjectEntryInObjectRangeCheck checker(*this, entry, range);
+ Trinity::GameObjectLastSearcher<Trinity::NearestGameObjectEntryInObjectRangeCheck> searcher(this, go, checker);
+ VisitNearbyGridObject(range, searcher);
+ return go;
+}
+
+void WorldObject::GetGameObjectListWithEntryInGrid(std::list<GameObject*>& 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<Trinity::AllGameObjectsWithEntryInRange> searcher(this, lList, check);
+ TypeContainerVisitor<Trinity::GameObjectListSearcher<Trinity::AllGameObjectsWithEntryInRange>, GridTypeMapContainer> visitor(searcher);
+
+ CellLock<GridReadGuard> cell_lock(cell, pair);
+ cell_lock->Visit(cell_lock, visitor, *(this->GetMap()));
}
void WorldObject::GetCreatureListWithEntryInGrid(std::list<Creature*>& 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<Trinity::AllCreaturesOfEntryInRange> searcher(this, lList, check);
TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange>, GridTypeMapContainer> visitor(searcher);
- VisitNearbyObject(fMaxSearchRange, searcher);
-}
-void WorldObject::GetGameObjectListWithEntryInGrid(std::list<GameObject*>& lList, uint32 uiEntry, float fMaxSearchRange)
-{
- Trinity::AllGameObjectsWithEntryInRange check(this, uiEntry, fMaxSearchRange);
- Trinity::GameObjectListSearcher<Trinity::AllGameObjectsWithEntryInRange> searcher(this, lList, check);
- TypeContainerVisitor<Trinity::GameObjectListSearcher<Trinity::AllGameObjectsWithEntryInRange>, GridTypeMapContainer> visitor(searcher);
- VisitNearbyGridObject(fMaxSearchRange, searcher);
+ CellLock<GridReadGuard> cell_lock(cell, pair);
+ cell_lock->Visit(cell_lock, visitor, *(this->GetMap()));
}
/*