aboutsummaryrefslogtreecommitdiff
path: root/src/bindings/scripts/include
diff options
context:
space:
mode:
authormaximius <none@none>2009-11-22 00:46:38 -0800
committermaximius <none@none>2009-11-22 00:46:38 -0800
commitda5c1bca546028d310bbf12340ca721146dc02f0 (patch)
tree141914dc48555e4fce0dac2376e78636a7b44968 /src/bindings/scripts/include
parent461e8d134f9ca432349e65d96fb038269fa4127f (diff)
*Cleanup, fix a few warnings, and make the SD2 grid searchers just pass through to the standard Trinity grid searchers, as they have identical functionality. Thanks thmarth. Closes #387, #388
--HG-- branch : trunk
Diffstat (limited to 'src/bindings/scripts/include')
-rw-r--r--src/bindings/scripts/include/sc_creature.cpp96
-rw-r--r--src/bindings/scripts/include/sc_creature.h12
2 files changed, 25 insertions, 83 deletions
diff --git a/src/bindings/scripts/include/sc_creature.cpp b/src/bindings/scripts/include/sc_creature.cpp
index 9f643eae30d..bb4d3e68888 100644
--- a/src/bindings/scripts/include/sc_creature.cpp
+++ b/src/bindings/scripts/include/sc_creature.cpp
@@ -637,50 +637,50 @@ void BossAI::TeleportCheaters()
float x, y, z;
me->GetPosition(x, y, z);
std::list<HostilReference*> &m_threatlist = me->getThreatManager().getThreatList();
- for (std::list<HostilReference*>::iterator itr = m_threatlist.begin(); itr!= m_threatlist.end(); ++itr)
+ for (std::list<HostilReference*>::iterator itr = m_threatlist.begin(); itr != m_threatlist.end(); ++itr)
if((*itr)->getTarget()->GetTypeId() == TYPEID_PLAYER && !CheckBoundary((*itr)->getTarget()))
(*itr)->getTarget()->NearTeleportTo(x, y, z, 0);
}
bool BossAI::CheckBoundary(Unit *who)
{
- if(!boundary || !who)
+ if (!boundary || !who)
return true;
for (BossBoundaryMap::const_iterator itr = boundary->begin(); itr != boundary->end(); ++itr)
{
- switch(itr->first)
+ switch (itr->first)
{
case BOUNDARY_N:
- if(me->GetPositionX() > itr->second)
+ if (me->GetPositionX() > itr->second)
return false;
break;
case BOUNDARY_S:
- if(me->GetPositionX() < itr->second)
+ if (me->GetPositionX() < itr->second)
return false;
break;
case BOUNDARY_E:
- if(me->GetPositionY() < itr->second)
+ if (me->GetPositionY() < itr->second)
return false;
break;
case BOUNDARY_W:
- if(me->GetPositionY() > itr->second)
+ if (me->GetPositionY() > itr->second)
return false;
break;
case BOUNDARY_NW:
- if(me->GetPositionX() + me->GetPositionY() > itr->second)
+ if (me->GetPositionX() + me->GetPositionY() > itr->second)
return false;
break;
case BOUNDARY_SE:
- if(me->GetPositionX() + me->GetPositionY() < itr->second)
+ if (me->GetPositionX() + me->GetPositionY() < itr->second)
return false;
break;
case BOUNDARY_NE:
- if(me->GetPositionX() - me->GetPositionY() > itr->second)
+ if (me->GetPositionX() - me->GetPositionY() > itr->second)
return false;
break;
case BOUNDARY_SW:
- if(me->GetPositionX() - me->GetPositionY() < itr->second)
+ if (me->GetPositionX() - me->GetPositionY() < itr->second)
return false;
break;
}
@@ -752,76 +752,20 @@ void LoadOverridenDBCData()
}
}
-//return closest GO in grid, with range from pSource
-GameObject* GetClosestGameObjectWithEntry(WorldObject* pSource, uint32 uiEntry, float fMaxSearchRange)
+// SD2 grid searchers.
+Creature *GetClosestCreatureWithEntry(WorldObject *pSource, uint32 uiEntry, float fMaxSearchRange, bool bAlive)
{
- GameObject* pGo = NULL;
-
- CellPair pair(MaNGOS::ComputeCellPair(pSource->GetPositionX(), pSource->GetPositionY()));
- Cell cell(pair);
- cell.data.Part.reserved = ALL_DISTRICT;
- cell.SetNoCreate();
-
- MaNGOS::NearestGameObjectEntryInObjectRangeCheck go_check(*pSource, uiEntry, fMaxSearchRange);
- MaNGOS::GameObjectLastSearcher<MaNGOS::NearestGameObjectEntryInObjectRangeCheck> searcher(pSource, pGo, go_check);
-
- TypeContainerVisitor<MaNGOS::GameObjectLastSearcher<MaNGOS::NearestGameObjectEntryInObjectRangeCheck>, GridTypeMapContainer> go_searcher(searcher);
-
- CellLock<GridReadGuard> cell_lock(cell, pair);
- cell_lock->Visit(cell_lock, go_searcher, *pSource->GetMap(), *pSource, fMaxSearchRange);
-
- return pGo;
+ return pSource->FindNearestCreature(uiEntry, fMaxSearchRange, bAlive);
}
-
-//return closest creature alive in grid, with range from pSource
-Creature* GetClosestCreatureWithEntry(WorldObject* pSource, uint32 uiEntry, float fMaxSearchRange)
+GameObject *GetClosestGameObjectWithEntry(WorldObject *pSource, uint32 uiEntry, float fMaxSearchRange)
{
- Creature* pCreature = NULL;
-
- CellPair pair(MaNGOS::ComputeCellPair(pSource->GetPositionX(), pSource->GetPositionY()));
- Cell cell(pair);
- cell.data.Part.reserved = ALL_DISTRICT;
- cell.SetNoCreate();
-
- MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck creature_check(*pSource, uiEntry, true, fMaxSearchRange);
- MaNGOS::CreatureLastSearcher<MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck> searcher(pSource, pCreature, creature_check);
-
- TypeContainerVisitor<MaNGOS::CreatureLastSearcher<MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck>, GridTypeMapContainer> creature_searcher(searcher);
-
- CellLock<GridReadGuard> cell_lock(cell, pair);
- cell_lock->Visit(cell_lock, creature_searcher,*(pSource->GetMap()), *pSource, fMaxSearchRange);
-
- return pCreature;
+ return pSource->FindNearestGameObject(uiEntry, fMaxSearchRange);
}
-
-/*
-void GetGameObjectListWithEntryInGrid(std::list<GameObject*>& lList , WorldObject* pSource, uint32 uiEntry, float fMaxSearchRange)
+void GetCreatureListWithEntryInGrid(std::list<Creature*>& lList, WorldObject *pSource, uint32 uiEntry, float fMaxSearchRange)
{
- CellPair pair(MaNGOS::ComputeCellPair(pSource->GetPositionX(), pSource->GetPositionY()));
- Cell cell(pair);
- cell.data.Part.reserved = ALL_DISTRICT;
- cell.SetNoCreate();
-
- AllGameObjectsWithEntryInRange check(pSource, uiEntry, fMaxSearchRange);
- MaNGOS::GameObjectListSearcher<AllGameObjectsWithEntryInRange> searcher(pSource, lList, check);
- TypeContainerVisitor<MaNGOS::GameObjectListSearcher<AllGameObjectsWithEntryInRange>, GridTypeMapContainer> visitor(searcher);
-
- CellLock<GridReadGuard> cell_lock(cell, pair);
- cell_lock->Visit(cell_lock, visitor, *(pSource->GetMap()), *pSource, fMaxSearchRange);
+ return pSource->GetCreatureListWithEntryInGrid(lList, uiEntry, fMaxSearchRange);
}
-
-void GetCreatureListWithEntryInGrid(std::list<Creature*>& lList, WorldObject* pSource, uint32 uiEntry, float fMaxSearchRange)
+void GetGameObjectListWithEntryInGrid(std::list<GameObject*>& lList, WorldObject *pSource, uint32 uiEntry, float fMaxSearchRange)
{
- CellPair pair(MaNGOS::ComputeCellPair(pSource->GetPositionX(), pSource->GetPositionY()));
- Cell cell(pair);
- cell.data.Part.reserved = ALL_DISTRICT;
- cell.SetNoCreate();
-
- AllCreaturesOfEntryInRange check(pSource, uiEntry, fMaxSearchRange);
- MaNGOS::CreatureListSearcher<AllCreaturesOfEntryInRange> searcher(pSource, lList, check);
- TypeContainerVisitor<MaNGOS::CreatureListSearcher<AllCreaturesOfEntryInRange>, GridTypeMapContainer> visitor(searcher);
-
- CellLock<GridReadGuard> cell_lock(cell, pair);
- cell_lock->Visit(cell_lock, visitor, *(pSource->GetMap()), *pSource, fMaxSearchRange);
+ return pSource->GetGameObjectListWithEntryInGrid(lList, uiEntry, fMaxSearchRange);
}
-*/
diff --git a/src/bindings/scripts/include/sc_creature.h b/src/bindings/scripts/include/sc_creature.h
index 4b461296775..fdeea02997c 100644
--- a/src/bindings/scripts/include/sc_creature.h
+++ b/src/bindings/scripts/include/sc_creature.h
@@ -221,13 +221,11 @@ struct TRINITY_DLL_DECL BossAI : public ScriptedAI
void TeleportCheaters();
};
-// SD2's grid searchers
-
-//return closest gameobject in grid, with range from pSource
-GameObject* GetClosestGameObjectWithEntry(WorldObject *pSource, uint32 uiEntry, float fMaxSearchRange);
-
-//return closest creature alive in grid, with range from pSource
-Creature* GetClosestCreatureWithEntry(WorldObject *pSource, uint32 Entry, float fMaxSearchRange);
+// SD2 grid searchers.
+Creature *GetClosestCreatureWithEntry(WorldObject *pSource, uint32 uiEntry, float fMaxSearchRange, bool bAlive = true);
+GameObject *GetClosestGameObjectWithEntry(WorldObject *pSource, uint32 uiEntry, float fMaxSearchRange);
+void GetCreatureListWithEntryInGrid(std::list<Creature*>& lList, WorldObject* pSource, uint32 uiEntry, float fMaxSearchRange);
+void GetGameObjectListWithEntryInGrid(std::list<GameObject*>& lList, WorldObject* pSource, uint32 uiEntry, float fMaxSearchRange);
#endif