From be0b2fcf97404af624e538be96ea05892d3f41be Mon Sep 17 00:00:00 2001 From: kaelima Date: Wed, 19 Oct 2011 17:40:44 +0100 Subject: Core/Grid: - Simplified CellArea calculation (Original author: SilverIce) - Removed unused code in Cell class (Original author: SilverIce) - Improve some Visit functions. --- src/server/game/Entities/Object/Object.cpp | 25 ++++++++----------------- src/server/game/Entities/Object/Object.h | 6 +++--- 2 files changed, 11 insertions(+), 20 deletions(-) (limited to 'src/server/game/Entities/Object') diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index 5e020941a2a..3bbe06dd4fb 100755 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -1871,7 +1871,6 @@ void WorldObject::MonsterSay(const char* text, uint32 language, uint64 TargetGui CellCoord p = Trinity::ComputeCellCoord(GetPositionX(), GetPositionY()); Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); Trinity::MonsterCustomChatBuilder say_build(*this, CHAT_MSG_MONSTER_SAY, text, language, TargetGuid); @@ -1886,7 +1885,6 @@ void WorldObject::MonsterSay(int32 textId, uint32 language, uint64 TargetGuid) CellCoord p = Trinity::ComputeCellCoord(GetPositionX(), GetPositionY()); Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); Trinity::MonsterChatBuilder say_build(*this, CHAT_MSG_MONSTER_SAY, textId, language, TargetGuid); @@ -1901,7 +1899,6 @@ void WorldObject::MonsterYell(const char* text, uint32 language, uint64 TargetGu CellCoord p = Trinity::ComputeCellCoord(GetPositionX(), GetPositionY()); Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); Trinity::MonsterCustomChatBuilder say_build(*this, CHAT_MSG_MONSTER_YELL, text, language, TargetGuid); @@ -1916,7 +1913,6 @@ void WorldObject::MonsterYell(int32 textId, uint32 language, uint64 TargetGuid) CellCoord p = Trinity::ComputeCellCoord(GetPositionX(), GetPositionY()); Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); Trinity::MonsterChatBuilder say_build(*this, CHAT_MSG_MONSTER_YELL, textId, language, TargetGuid); @@ -1951,7 +1947,6 @@ void WorldObject::MonsterTextEmote(int32 textId, uint64 TargetGuid, bool IsBossE CellCoord p = Trinity::ComputeCellCoord(GetPositionX(), GetPositionY()); Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); Trinity::MonsterChatBuilder say_build(*this, IsBossEmote ? CHAT_MSG_RAID_BOSS_EMOTE : CHAT_MSG_MONSTER_EMOTE, textId, LANG_UNIVERSAL, TargetGuid); @@ -2393,32 +2388,30 @@ GameObject* WorldObject::FindNearestGameObject(uint32 entry, float range) const return go; } -void WorldObject::GetGameObjectListWithEntryInGrid(std::list& lList, uint32 uiEntry, float fMaxSearchRange) const +void WorldObject::GetGameObjectListWithEntryInGrid(std::list& gameobjectList, uint32 entry, float maxSearchRange) const { CellCoord pair(Trinity::ComputeCellCoord(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); + Trinity::AllGameObjectsWithEntryInRange check(this, entry, maxSearchRange); + Trinity::GameObjectListSearcher searcher(this, gameobjectList, check); TypeContainerVisitor, GridTypeMapContainer> visitor(searcher); - cell.Visit(pair, visitor, *(this->GetMap())); + cell.Visit(pair, visitor, *(this->GetMap()), *this, maxSearchRange); } -void WorldObject::GetCreatureListWithEntryInGrid(std::list& lList, uint32 uiEntry, float fMaxSearchRange) const +void WorldObject::GetCreatureListWithEntryInGrid(std::list& creatureList, uint32 entry, float maxSearchRange) const { CellCoord pair(Trinity::ComputeCellCoord(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); + Trinity::AllCreaturesOfEntryInRange check(this, entry, maxSearchRange); + Trinity::CreatureListSearcher searcher(this, creatureList, check); TypeContainerVisitor, GridTypeMapContainer> visitor(searcher); - cell.Visit(pair, visitor, *(this->GetMap())); + cell.Visit(pair, visitor, *(this->GetMap()), *this, maxSearchRange); } /* @@ -2531,7 +2524,6 @@ void WorldObject::GetNearPoint(WorldObject const* /*searcher*/, float &x, float { CellCoord p(Trinity::ComputeCellCoord(GetPositionX(), GetPositionY())); Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); Trinity::NearUsedPosDo u_do(*this, searcher, absAngle, selector); @@ -2828,7 +2820,6 @@ void WorldObject::BuildUpdate(UpdateDataMapType& data_map) { CellCoord p = Trinity::ComputeCellCoord(GetPositionX(), GetPositionY()); Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); WorldObjectChangeAccumulator notifier(*this, data_map); TypeContainerVisitor player_notifier(notifier); diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h index 7bcd785554e..dfcf6a3cfa4 100755 --- a/src/server/game/Entities/Object/Object.h +++ b/src/server/game/Entities/Object/Object.h @@ -793,9 +793,9 @@ class WorldObject : public Object, public WorldLocation bool isActiveObject() const { return m_isActive; } void setActive(bool isActiveObject); void SetWorldObject(bool apply); - template void VisitNearbyObject(const float &radius, NOTIFIER ¬ifier) const { if (IsInWorld()) GetMap()->VisitAll(GetPositionX(), GetPositionY(), radius, notifier); } - template void VisitNearbyGridObject(const float &radius, NOTIFIER ¬ifier) const { if (IsInWorld()) GetMap()->VisitGrid(GetPositionX(), GetPositionY(), radius, notifier); } - template void VisitNearbyWorldObject(const float &radius, NOTIFIER ¬ifier) const { if (IsInWorld()) GetMap()->VisitWorld(GetPositionX(), GetPositionY(), radius, notifier); } + template void VisitNearbyObject(float const& radius, NOTIFIER& notifier) const { if (IsInWorld()) GetMap()->VisitAll(GetPositionX(), GetPositionY(), radius, notifier); } + template void VisitNearbyGridObject(float const& radius, NOTIFIER& notifier) const { if (IsInWorld()) GetMap()->VisitGrid(GetPositionX(), GetPositionY(), radius, notifier); } + template void VisitNearbyWorldObject(float const& radius, NOTIFIER& notifier) const { if (IsInWorld()) GetMap()->VisitWorld(GetPositionX(), GetPositionY(), radius, notifier); } #ifdef MAP_BASED_RAND_GEN int32 irand(int32 min, int32 max) const { return int32 (GetMap()->mtRand.randInt(max - min)) + min; } -- cgit v1.2.3