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 ++++++++++++++++++++++++++++----------------- src/game/Object.h | 10 ++++----- src/game/ObjectAccessor.cpp | 8 ++++++- src/game/ObjectAccessor.h | 1 - 4 files changed, 45 insertions(+), 28 deletions(-) (limited to 'src') 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())); } /* 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& lList, uint32 uiEntry, float fMaxSearchRange); void GetGameObjectListWithEntryInGrid(std::list& lList, uint32 uiEntry, float fMaxSearchRange); + void GetCreatureListWithEntryInGrid(std::list& 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(uint32 mapid, floa template Corpse* ObjectAccessor::GetObjectInWorld(uint32 mapid, float x, float y, uint64 guid, Corpse* /*fake*/); template GameObject* ObjectAccessor::GetObjectInWorld(uint32 mapid, float x, float y, uint64 guid, GameObject* /*fake*/); template DynamicObject* ObjectAccessor::GetObjectInWorld(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