diff options
author | n0n4m3 <none@none> | 2009-12-17 11:40:23 +0100 |
---|---|---|
committer | n0n4m3 <none@none> | 2009-12-17 11:40:23 +0100 |
commit | 63659ea18b837a2f9c330de6c70dba16089d5c53 (patch) | |
tree | c9e50231f2374ae58a7bc4fac6162755e6963b84 | |
parent | 5953596cee670517df4cf35fb1d428f9862a01b2 (diff) |
Update some code for 322a
--HG--
branch : trunk
-rw-r--r-- | src/game/Object.cpp | 54 | ||||
-rw-r--r-- | src/game/Object.h | 10 | ||||
-rw-r--r-- | src/game/ObjectAccessor.cpp | 8 | ||||
-rw-r--r-- | src/game/ObjectAccessor.h | 1 |
4 files changed, 45 insertions, 28 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())); } /* diff --git a/src/game/Object.h b/src/game/Object.h index b068033bdf3..cc876f1c756 100644 --- a/src/game/Object.h +++ b/src/game/Object.h @@ -237,8 +237,7 @@ class TRINITY_DLL_SPEC Object bool HasFlag( uint16 index, uint32 flag ) const { - if(index >= m_valuesCount && !PrintIndexError(index , false)) - return false; + if( index >= m_valuesCount && !PrintIndexError( index , false ) ) return false; return (m_uint32Values[ index ] & flag) != 0; } @@ -611,11 +610,11 @@ class TRINITY_DLL_SPEC WorldObject : public Object, public WorldLocation GameObject* SummonGameObject(uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime); Creature* SummonTrigger(float x, float y, float z, float ang, uint32 dur, CreatureAI* (*GetAI)(Creature*) = NULL); - Creature* FindNearestCreature(uint32 uiEntry, float fMaxSearchRange, bool bAlive = true); - GameObject* FindNearestGameObject(uint32 uiEntry, float fMaxSearchRange); + Creature* FindNearestCreature(uint32 entry, float range, bool alive = true); + GameObject* FindNearestGameObject(uint32 entry, float range); - void GetCreatureListWithEntryInGrid(std::list<Creature*>& lList, uint32 uiEntry, float fMaxSearchRange); void GetGameObjectListWithEntryInGrid(std::list<GameObject*>& lList, uint32 uiEntry, float fMaxSearchRange); + void GetCreatureListWithEntryInGrid(std::list<Creature*>& lList, uint32 uiEntry, float fMaxSearchRange); void DestroyForNearbyPlayers(); @@ -655,4 +654,3 @@ class TRINITY_DLL_SPEC WorldObject : public Object, public WorldLocation uint32 m_phaseMask; // in area phase state }; #endif - diff --git a/src/game/ObjectAccessor.cpp b/src/game/ObjectAccessor.cpp index 2dfd9c9ae7b..e52423eabd8 100644 --- a/src/game/ObjectAccessor.cpp +++ b/src/game/ObjectAccessor.cpp @@ -49,7 +49,10 @@ ObjectAccessor::ObjectAccessor() {} ObjectAccessor::~ObjectAccessor() { for (Player2CorpsesMapType::const_iterator itr = i_player2corpse.begin(); itr != i_player2corpse.end(); ++itr) + { + itr->second->RemoveFromWorld(); delete itr->second; + } } Creature* @@ -351,6 +354,10 @@ ObjectAccessor::ConvertCorpseForPlayer(uint64 player_guid, bool insignia) // remove corpse from DB corpse->DeleteFromDB(); + // we don't want bones to save some cpu.. :) + delete corpse; + return NULL; + Corpse *bones = NULL; // create the bones only if the map and the grid is loaded at the corpse's location // ignore bones creating option in case insignia @@ -521,4 +528,3 @@ template Creature* ObjectAccessor::GetObjectInWorld<Creature>(uint32 mapid, floa template Corpse* ObjectAccessor::GetObjectInWorld<Corpse>(uint32 mapid, float x, float y, uint64 guid, Corpse* /*fake*/); template GameObject* ObjectAccessor::GetObjectInWorld<GameObject>(uint32 mapid, float x, float y, uint64 guid, GameObject* /*fake*/); template DynamicObject* ObjectAccessor::GetObjectInWorld<DynamicObject>(uint32 mapid, float x, float y, uint64 guid, DynamicObject* /*fake*/); - diff --git a/src/game/ObjectAccessor.h b/src/game/ObjectAccessor.h index 79afa78fb6a..780c108e5e4 100644 --- a/src/game/ObjectAccessor.h +++ b/src/game/ObjectAccessor.h @@ -267,4 +267,3 @@ class MANGOS_DLL_DECL ObjectAccessor : public MaNGOS::Singleton<ObjectAccessor, LockType i_petGuard; }; #endif - |