aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorkaelima <kaelima@live.se>2011-10-19 17:40:44 +0100
committerkaelima <kaelima@live.se>2011-10-19 17:40:44 +0100
commitbe0b2fcf97404af624e538be96ea05892d3f41be (patch)
tree8849332a9a8930226fea13b4e5188f4b521a70c3 /src
parentd7e019072677dd098c491986ebe8c48259d20155 (diff)
Core/Grid:
- Simplified CellArea calculation (Original author: SilverIce) - Removed unused code in Cell class (Original author: SilverIce) - Improve some Visit functions.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/server/game/AI/EventAI/CreatureEventAI.cpp7
-rw-r--r--src/server/game/AI/ScriptedAI/ScriptedCreature.cpp3
-rw-r--r--src/server/game/AI/SmartScripts/SmartScript.cpp19
-rw-r--r--src/server/game/AI/SmartScripts/SmartScript.h12
-rwxr-xr-xsrc/server/game/Achievements/AchievementMgr.cpp1
-rwxr-xr-xsrc/server/game/Chat/Chat.cpp5
-rwxr-xr-xsrc/server/game/Chat/Commands/Level3.cpp3
-rwxr-xr-xsrc/server/game/Entities/Creature/Creature.cpp13
-rwxr-xr-xsrc/server/game/Entities/GameObject/GameObject.cpp2
-rwxr-xr-xsrc/server/game/Entities/Object/Object.cpp25
-rwxr-xr-xsrc/server/game/Entities/Object/Object.h6
-rwxr-xr-xsrc/server/game/Grids/Cells/Cell.h94
-rw-r--r--src/server/game/Grids/Cells/CellImpl.h168
-rw-r--r--src/server/game/Grids/GridDefines.h7
-rwxr-xr-xsrc/server/game/Maps/Map.cpp27
-rwxr-xr-xsrc/server/game/Maps/Map.h19
-rwxr-xr-xsrc/server/game/Scripting/MapScripts.cpp18
-rwxr-xr-xsrc/server/game/Server/Protocol/Handlers/ChatHandler.cpp1
-rwxr-xr-xsrc/server/game/Spells/Auras/SpellAuraEffects.cpp1
-rwxr-xr-xsrc/server/game/Spells/Spell.cpp2
-rw-r--r--src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp3
-rw-r--r--src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp7
-rw-r--r--src/server/scripts/EasternKingdoms/ZulAman/boss_janalai.cpp9
-rw-r--r--src/server/scripts/EasternKingdoms/ZulAman/boss_nalorakk.cpp3
-rw-r--r--src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp25
25 files changed, 127 insertions, 353 deletions
diff --git a/src/server/game/AI/EventAI/CreatureEventAI.cpp b/src/server/game/AI/EventAI/CreatureEventAI.cpp
index 8f3bf52c37e..be0dd8c3679 100755
--- a/src/server/game/AI/EventAI/CreatureEventAI.cpp
+++ b/src/server/game/AI/EventAI/CreatureEventAI.cpp
@@ -1179,7 +1179,6 @@ Unit* CreatureEventAI::DoSelectLowestHpFriendly(float range, uint32 minHPDiff)
{
CellCoord p(Trinity::ComputeCellCoord(me->GetPositionX(), me->GetPositionY()));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
Unit* unit = NULL;
@@ -1201,7 +1200,6 @@ void CreatureEventAI::DoFindFriendlyCC(std::list<Creature*>& _list, float range)
{
CellCoord p(Trinity::ComputeCellCoord(me->GetPositionX(), me->GetPositionY()));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
Trinity::FriendlyCCedInRange u_check(me, range);
@@ -1209,14 +1207,13 @@ void CreatureEventAI::DoFindFriendlyCC(std::list<Creature*>& _list, float range)
TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::FriendlyCCedInRange>, GridTypeMapContainer > grid_creature_searcher(searcher);
- cell.Visit(p, grid_creature_searcher, *me->GetMap());
+ cell.Visit(p, grid_creature_searcher, *me->GetMap(), *me, range);
}
void CreatureEventAI::DoFindFriendlyMissingBuff(std::list<Creature*>& _list, float range, uint32 spellid)
{
CellCoord p(Trinity::ComputeCellCoord(me->GetPositionX(), me->GetPositionY()));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
Trinity::FriendlyMissingBuffInRange u_check(me, range, spellid);
@@ -1224,7 +1221,7 @@ void CreatureEventAI::DoFindFriendlyMissingBuff(std::list<Creature*>& _list, flo
TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::FriendlyMissingBuffInRange>, GridTypeMapContainer > grid_creature_searcher(searcher);
- cell.Visit(p, grid_creature_searcher, *me->GetMap());
+ cell.Visit(p, grid_creature_searcher, *me->GetMap(), *me, range);
}
// *********************************
diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
index 95c07b665ae..953bbf7521a 100644
--- a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
+++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
@@ -365,14 +365,13 @@ Player* ScriptedAI::GetPlayerAtMinimumRange(float minimumRange)
CellCoord pair(Trinity::ComputeCellCoord(me->GetPositionX(), me->GetPositionY()));
Cell cell(pair);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
Trinity::PlayerAtMinimumRangeAway check(me, minimumRange);
Trinity::PlayerSearcher<Trinity::PlayerAtMinimumRangeAway> searcher(me, player, check);
TypeContainerVisitor<Trinity::PlayerSearcher<Trinity::PlayerAtMinimumRangeAway>, GridTypeMapContainer> visitor(searcher);
- cell.Visit(pair, visitor, *(me->GetMap()));
+ cell.Visit(pair, visitor, *me->GetMap(), *me, minimumRange);
return player;
}
diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp
index 650ae1b8efe..143cb1f0ec1 100644
--- a/src/server/game/AI/SmartScripts/SmartScript.cpp
+++ b/src/server/game/AI/SmartScripts/SmartScript.cpp
@@ -2877,10 +2877,11 @@ uint32 SmartScript::DoChat(int8 id, uint64 whisperGuid)
Unit* SmartScript::DoSelectLowestHpFriendly(float range, uint32 MinHPDiff)
{
- if (!me) return NULL;
+ if (!me)
+ return NULL;
+
CellCoord p(Trinity::ComputeCellCoord(me->GetPositionX(), me->GetPositionY()));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
Unit* unit = NULL;
@@ -2896,10 +2897,11 @@ Unit* SmartScript::DoSelectLowestHpFriendly(float range, uint32 MinHPDiff)
void SmartScript::DoFindFriendlyCC(std::list<Creature*>& _list, float range)
{
- if (!me) return;
+ if (!me)
+ return;
+
CellCoord p(Trinity::ComputeCellCoord(me->GetPositionX(), me->GetPositionY()));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
Trinity::FriendlyCCedInRange u_check(me, range);
@@ -2907,15 +2909,16 @@ void SmartScript::DoFindFriendlyCC(std::list<Creature*>& _list, float range)
TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::FriendlyCCedInRange>, GridTypeMapContainer > grid_creature_searcher(searcher);
- cell.Visit(p, grid_creature_searcher, *me->GetMap());
+ cell.Visit(p, grid_creature_searcher, *me->GetMap(), *me, range);
}
void SmartScript::DoFindFriendlyMissingBuff(std::list<Creature*>& list, float range, uint32 spellid)
{
- if (!me) return;
+ if (!me)
+ return;
+
CellCoord p(Trinity::ComputeCellCoord(me->GetPositionX(), me->GetPositionY()));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
Trinity::FriendlyMissingBuffInRange u_check(me, range, spellid);
@@ -2923,7 +2926,7 @@ void SmartScript::DoFindFriendlyMissingBuff(std::list<Creature*>& list, float ra
TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::FriendlyMissingBuffInRange>, GridTypeMapContainer > grid_creature_searcher(searcher);
- cell.Visit(p, grid_creature_searcher, *me->GetMap());
+ cell.Visit(p, grid_creature_searcher, *me->GetMap(), *me, range);
}
void SmartScript::SetScript9(SmartScriptHolder& e, uint32 entry)
diff --git a/src/server/game/AI/SmartScripts/SmartScript.h b/src/server/game/AI/SmartScripts/SmartScript.h
index d102c579abb..03d04f4b3df 100644
--- a/src/server/game/AI/SmartScripts/SmartScript.h
+++ b/src/server/game/AI/SmartScripts/SmartScript.h
@@ -157,31 +157,29 @@ class SmartScript
CellCoord p(Trinity::ComputeCellCoord(searchObject->GetPositionX(), searchObject->GetPositionY()));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
Trinity::GameObjectWithDbGUIDCheck goCheck(*searchObject, guid);
Trinity::GameObjectSearcher<Trinity::GameObjectWithDbGUIDCheck> checker(searchObject, gameObject, goCheck);
TypeContainerVisitor<Trinity::GameObjectSearcher<Trinity::GameObjectWithDbGUIDCheck>, GridTypeMapContainer > objectChecker(checker);
- cell.Visit(p, objectChecker, *searchObject->GetMap());
+ cell.Visit(p, objectChecker, *searchObject->GetMap(), *searchObject, searchObject->GetGridActivationRange());
return gameObject;
}
Creature* FindCreatureNear(WorldObject* searchObject, uint32 guid) const
{
- Creature* crea = NULL;
+ Creature* creature = NULL;
CellCoord p(Trinity::ComputeCellCoord(searchObject->GetPositionX(), searchObject->GetPositionY()));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
Trinity::CreatureWithDbGUIDCheck target_check(searchObject, guid);
- Trinity::CreatureSearcher<Trinity::CreatureWithDbGUIDCheck> checker(searchObject, crea, target_check);
+ Trinity::CreatureSearcher<Trinity::CreatureWithDbGUIDCheck> checker(searchObject, creature, target_check);
TypeContainerVisitor<Trinity::CreatureSearcher <Trinity::CreatureWithDbGUIDCheck>, GridTypeMapContainer > unit_checker(checker);
- cell.Visit(p, unit_checker, *searchObject->GetMap());
+ cell.Visit(p, unit_checker, *searchObject->GetMap(), *searchObject, searchObject->GetGridActivationRange());
- return crea;
+ return creature;
}
ObjectListMap* mTargetStorage;
diff --git a/src/server/game/Achievements/AchievementMgr.cpp b/src/server/game/Achievements/AchievementMgr.cpp
index ce03fb3ca87..30f66925060 100755
--- a/src/server/game/Achievements/AchievementMgr.cpp
+++ b/src/server/game/Achievements/AchievementMgr.cpp
@@ -669,7 +669,6 @@ void AchievementMgr::SendAchievementEarned(AchievementEntry const* achievement)
CellCoord p = Trinity::ComputeCellCoord(GetPlayer()->GetPositionX(), GetPlayer()->GetPositionY());
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
Trinity::AchievementChatBuilder say_builder(*GetPlayer(), CHAT_MSG_ACHIEVEMENT, LANG_ACHIEVEMENT_EARNED, achievement->ID);
diff --git a/src/server/game/Chat/Chat.cpp b/src/server/game/Chat/Chat.cpp
index 5be49fb433d..7d6e9f7a004 100755
--- a/src/server/game/Chat/Chat.cpp
+++ b/src/server/game/Chat/Chat.cpp
@@ -1224,7 +1224,7 @@ GameObject* ChatHandler::GetNearbyGameObject()
GameObject* obj = NULL;
Trinity::NearestGameObjectCheck check(*pl);
Trinity::GameObjectLastSearcher<Trinity::NearestGameObjectCheck> searcher(pl, obj, check);
- pl->VisitNearbyGridObject(999, searcher);
+ pl->VisitNearbyGridObject(SIZE_OF_GRIDS, searcher);
return obj;
}
@@ -1242,13 +1242,12 @@ GameObject* ChatHandler::GetObjectGlobalyWithGuidOrNearWithDbGuid(uint32 lowguid
// search near player then
CellCoord p(Trinity::ComputeCellCoord(pl->GetPositionX(), pl->GetPositionY()));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
Trinity::GameObjectWithDbGUIDCheck go_check(*pl, lowguid);
Trinity::GameObjectSearcher<Trinity::GameObjectWithDbGUIDCheck> checker(pl, obj, go_check);
TypeContainerVisitor<Trinity::GameObjectSearcher<Trinity::GameObjectWithDbGUIDCheck>, GridTypeMapContainer > object_checker(checker);
- cell.Visit(p, object_checker, *pl->GetMap());
+ cell.Visit(p, object_checker, *pl->GetMap(), *pl, pl->GetGridActivationRange());
}
return obj;
diff --git a/src/server/game/Chat/Commands/Level3.cpp b/src/server/game/Chat/Commands/Level3.cpp
index ade4c38ad2e..8dd5e17f550 100755
--- a/src/server/game/Chat/Commands/Level3.cpp
+++ b/src/server/game/Chat/Commands/Level3.cpp
@@ -3472,14 +3472,13 @@ bool ChatHandler::HandleRespawnCommand(const char* /*args*/)
CellCoord p(Trinity::ComputeCellCoord(pl->GetPositionX(), pl->GetPositionY()));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
Trinity::RespawnDo u_do;
Trinity::WorldObjectWorker<Trinity::RespawnDo> worker(pl, u_do);
TypeContainerVisitor<Trinity::WorldObjectWorker<Trinity::RespawnDo>, GridTypeMapContainer > obj_worker(worker);
- cell.Visit(p, obj_worker, *pl->GetMap());
+ cell.Visit(p, obj_worker, *pl->GetMap(), *pl, pl->GetGridActivationRange());
return true;
}
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp
index a4dfe76dd21..3d6eaf1a198 100755
--- a/src/server/game/Entities/Creature/Creature.cpp
+++ b/src/server/game/Entities/Creature/Creature.cpp
@@ -661,7 +661,6 @@ void Creature::DoFleeToGetAssistance()
CellCoord p(Trinity::ComputeCellCoord(GetPositionX(), GetPositionY()));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
Trinity::NearestAssistCreatureInCreatureRangeCheck u_check(this, getVictim(), radius);
Trinity::CreatureLastSearcher<Trinity::NearestAssistCreatureInCreatureRangeCheck> searcher(this, creature, u_check);
@@ -1762,7 +1761,6 @@ Unit* Creature::SelectNearestTarget(float dist) const
{
CellCoord p(Trinity::ComputeCellCoord(GetPositionX(), GetPositionY()));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
Unit* target = NULL;
@@ -1789,7 +1787,6 @@ Unit* Creature::SelectNearestTargetInAttackDistance(float dist) const
{
CellCoord p(Trinity::ComputeCellCoord(GetPositionX(), GetPositionY()));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
Unit* target = NULL;
@@ -1852,7 +1849,6 @@ void Creature::CallAssistance()
{
CellCoord p(Trinity::ComputeCellCoord(GetPositionX(), GetPositionY()));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
Trinity::AnyAssistCreatureInRangeCheck u_check(this, getVictim(), radius);
@@ -1878,22 +1874,21 @@ void Creature::CallAssistance()
}
}
-void Creature::CallForHelp(float fRadius)
+void Creature::CallForHelp(float radius)
{
- if (fRadius <= 0.0f || !getVictim() || isPet() || isCharmed())
+ if (radius <= 0.0f || !getVictim() || isPet() || isCharmed())
return;
CellCoord p(Trinity::ComputeCellCoord(GetPositionX(), GetPositionY()));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
- Trinity::CallOfHelpCreatureInRangeDo u_do(this, getVictim(), fRadius);
+ Trinity::CallOfHelpCreatureInRangeDo u_do(this, getVictim(), radius);
Trinity::CreatureWorker<Trinity::CallOfHelpCreatureInRangeDo> worker(this, u_do);
TypeContainerVisitor<Trinity::CreatureWorker<Trinity::CallOfHelpCreatureInRangeDo>, GridTypeMapContainer > grid_creature_searcher(worker);
- cell.Visit(p, grid_creature_searcher, *GetMap(), *this, fRadius);
+ cell.Visit(p, grid_creature_searcher, *GetMap(), *this, radius);
}
bool Creature::CanAssistTo(const Unit* u, const Unit* enemy, bool checkfaction /*= true*/) const
diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp
index c00ceacaf65..a894ee16c2d 100755
--- a/src/server/game/Entities/GameObject/GameObject.cpp
+++ b/src/server/game/Entities/GameObject/GameObject.cpp
@@ -933,7 +933,6 @@ void GameObject::TriggeringLinkedGameObject(uint32 trapEntry, Unit* target)
// using original GO distance
CellCoord p(Trinity::ComputeCellCoord(GetPositionX(), GetPositionY()));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
Trinity::NearestGameObjectEntryInObjectRangeCheck go_check(*target, trapEntry, range);
Trinity::GameObjectLastSearcher<Trinity::NearestGameObjectEntryInObjectRangeCheck> checker(this, trapGO, go_check);
@@ -953,7 +952,6 @@ GameObject* GameObject::LookupFishingHoleAround(float range)
CellCoord p(Trinity::ComputeCellCoord(GetPositionX(), GetPositionY()));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
Trinity::NearestGameObjectFishingHole u_check(*this, range);
Trinity::GameObjectSearcher<Trinity::NearestGameObjectFishingHole> checker(this, ok, u_check);
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<GameObject*>& lList, uint32 uiEntry, float fMaxSearchRange) const
+void WorldObject::GetGameObjectListWithEntryInGrid(std::list<GameObject*>& 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<Trinity::AllGameObjectsWithEntryInRange> searcher(this, lList, check);
+ Trinity::AllGameObjectsWithEntryInRange check(this, entry, maxSearchRange);
+ Trinity::GameObjectListSearcher<Trinity::AllGameObjectsWithEntryInRange> searcher(this, gameobjectList, check);
TypeContainerVisitor<Trinity::GameObjectListSearcher<Trinity::AllGameObjectsWithEntryInRange>, GridTypeMapContainer> visitor(searcher);
- cell.Visit(pair, visitor, *(this->GetMap()));
+ cell.Visit(pair, visitor, *(this->GetMap()), *this, maxSearchRange);
}
-void WorldObject::GetCreatureListWithEntryInGrid(std::list<Creature*>& lList, uint32 uiEntry, float fMaxSearchRange) const
+void WorldObject::GetCreatureListWithEntryInGrid(std::list<Creature*>& 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<Trinity::AllCreaturesOfEntryInRange> searcher(this, lList, check);
+ Trinity::AllCreaturesOfEntryInRange check(this, entry, maxSearchRange);
+ Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange> searcher(this, creatureList, check);
TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange>, 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<WorldObjectChangeAccumulator, WorldTypeMapContainer > 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<class NOTIFIER> void VisitNearbyObject(const float &radius, NOTIFIER &notifier) const { if (IsInWorld()) GetMap()->VisitAll(GetPositionX(), GetPositionY(), radius, notifier); }
- template<class NOTIFIER> void VisitNearbyGridObject(const float &radius, NOTIFIER &notifier) const { if (IsInWorld()) GetMap()->VisitGrid(GetPositionX(), GetPositionY(), radius, notifier); }
- template<class NOTIFIER> void VisitNearbyWorldObject(const float &radius, NOTIFIER &notifier) const { if (IsInWorld()) GetMap()->VisitWorld(GetPositionX(), GetPositionY(), radius, notifier); }
+ template<class NOTIFIER> void VisitNearbyObject(float const& radius, NOTIFIER& notifier) const { if (IsInWorld()) GetMap()->VisitAll(GetPositionX(), GetPositionY(), radius, notifier); }
+ template<class NOTIFIER> void VisitNearbyGridObject(float const& radius, NOTIFIER& notifier) const { if (IsInWorld()) GetMap()->VisitGrid(GetPositionX(), GetPositionY(), radius, notifier); }
+ template<class NOTIFIER> 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; }
diff --git a/src/server/game/Grids/Cells/Cell.h b/src/server/game/Grids/Cells/Cell.h
index 12648881719..13bb0afc494 100755
--- a/src/server/game/Grids/Cells/Cell.h
+++ b/src/server/game/Grids/Cells/Cell.h
@@ -29,88 +29,34 @@
class Map;
class WorldObject;
-enum District
-{
- UPPER_DISTRICT = 1,
- LOWER_DISTRICT = 1 << 1,
- LEFT_DISTRICT = 1 << 2,
- RIGHT_DISTRICT = 1 << 3,
- CENTER_DISTRICT = 1 << 4,
- UPPER_LEFT_DISTRICT = (UPPER_DISTRICT | LEFT_DISTRICT),
- UPPER_RIGHT_DISTRICT = (UPPER_DISTRICT | RIGHT_DISTRICT),
- LOWER_LEFT_DISTRICT = (LOWER_DISTRICT | LEFT_DISTRICT),
- LOWER_RIGHT_DISTRICT = (LOWER_DISTRICT | RIGHT_DISTRICT),
- ALL_DISTRICT = (UPPER_DISTRICT | LOWER_DISTRICT | LEFT_DISTRICT | RIGHT_DISTRICT | CENTER_DISTRICT)
-};
-
struct CellArea
{
- CellArea() : right_offset(0), left_offset(0), upper_offset(0), lower_offset(0) {}
- CellArea(int right, int left, int upper, int lower) : right_offset(right), left_offset(left), upper_offset(upper), lower_offset(lower) {}
- bool operator!() const { return !right_offset && !left_offset && !upper_offset && !lower_offset; }
+ CellArea() {}
+ CellArea(CellCoord low, CellCoord high) : low_bound(low), high_bound(high) {}
+
+ bool operator!() const { return low_bound == high_bound; }
void ResizeBorders(CellCoord& begin_cell, CellCoord& end_cell) const
{
- begin_cell.dec_x(left_offset);
- begin_cell.dec_y(lower_offset);
- end_cell.inc_x(right_offset);
- end_cell.inc_y(upper_offset);
+ begin_cell = low_bound;
+ end_cell = high_bound;
}
- int right_offset;
- int left_offset;
- int upper_offset;
- int lower_offset;
+ CellCoord low_bound;
+ CellCoord high_bound;
};
struct Cell
{
Cell() { data.All = 0; }
- Cell(const Cell &cell) { data.All = cell.data.All; }
+ Cell(Cell const& cell) { data.All = cell.data.All; }
explicit Cell(CellCoord const& p);
explicit Cell(float x, float y);
- void operator|=(Cell &cell)
- {
- data.Part.reserved = 0;
- cell.data.Part.reserved = 0;
- uint32 x, y, old_x, old_y;
- Compute(x, y);
- cell.Compute(old_x, old_y);
-
- if (std::abs(int(x-old_x)) > 1 || std::abs(int(y-old_y)) > 1)
- {
- data.Part.reserved = ALL_DISTRICT;
- cell.data.Part.reserved = ALL_DISTRICT;
- return;
- }
-
- if (x < old_x)
- {
- data.Part.reserved |= LEFT_DISTRICT;
- cell.data.Part.reserved |= RIGHT_DISTRICT;
- }
- else if (old_x < x)
- {
- data.Part.reserved |= RIGHT_DISTRICT;
- cell.data.Part.reserved |= LEFT_DISTRICT;
- }
- if (y < old_y)
- {
- data.Part.reserved |= UPPER_DISTRICT;
- cell.data.Part.reserved |= LOWER_DISTRICT;
- }
- else if (old_y < y)
- {
- data.Part.reserved |= LOWER_DISTRICT;
- cell.data.Part.reserved |= UPPER_DISTRICT;
- }
- }
-
void Compute(uint32 &x, uint32 &y) const
{
- x = data.Part.grid_x*MAX_NUMBER_OF_CELLS + data.Part.cell_x;
- y = data.Part.grid_y*MAX_NUMBER_OF_CELLS + data.Part.cell_y;
+ x = data.Part.grid_x * MAX_NUMBER_OF_CELLS + data.Part.cell_x;
+ y = data.Part.grid_y * MAX_NUMBER_OF_CELLS + data.Part.cell_y;
}
bool DiffCell(const Cell &cell) const
@@ -135,18 +81,18 @@ struct Cell
CellCoord GetCellCoord() const
{
return CellCoord(
- data.Part.grid_x*MAX_NUMBER_OF_CELLS+data.Part.cell_x,
- data.Part.grid_y*MAX_NUMBER_OF_CELLS+data.Part.cell_y);
+ data.Part.grid_x * MAX_NUMBER_OF_CELLS+data.Part.cell_x,
+ data.Part.grid_y * MAX_NUMBER_OF_CELLS+data.Part.cell_y);
}
- Cell& operator=(const Cell &cell)
+ Cell& operator=(Cell const& cell)
{
this->data.All = cell.data.All;
return *this;
}
- bool operator == (const Cell &cell) const { return (data.All == cell.data.All); }
- bool operator != (const Cell &cell) const { return !operator == (cell); }
+ bool operator == (Cell const& cell) const { return (data.All == cell.data.All); }
+ bool operator != (Cell const& cell) const { return !operator == (cell); }
union
{
struct
@@ -161,15 +107,13 @@ struct Cell
uint32 All;
} data;
- template<class T, class CONTAINER> void Visit(const CellCoord&, TypeContainerVisitor<T, CONTAINER> &visitor, Map &) const;
- template<class T, class CONTAINER> void Visit(const CellCoord&, TypeContainerVisitor<T, CONTAINER> &visitor, Map &, const WorldObject&, float) const;
- template<class T, class CONTAINER> void Visit(const CellCoord&, TypeContainerVisitor<T, CONTAINER> &visitor, Map &, float, float, float) const;
+ template<class T, class CONTAINER> void Visit(CellCoord const&, TypeContainerVisitor<T, CONTAINER>& visitor, Map &, WorldObject const&, float) const;
+ template<class T, class CONTAINER> void Visit(CellCoord const&, TypeContainerVisitor<T, CONTAINER>& visitor, Map &, float, float, float) const;
- static CellArea CalculateCellArea(const WorldObject &obj, float radius);
static CellArea CalculateCellArea(float x, float y, float radius);
private:
- template<class T, class CONTAINER> void VisitCircle(TypeContainerVisitor<T, CONTAINER> &, Map &, const CellCoord&, const CellCoord&) const;
+ template<class T, class CONTAINER> void VisitCircle(TypeContainerVisitor<T, CONTAINER> &, Map &, CellCoord const&, CellCoord const&) const;
};
#endif
diff --git a/src/server/game/Grids/Cells/CellImpl.h b/src/server/game/Grids/Cells/CellImpl.h
index 5a5be4d7358..af697b9f21d 100644
--- a/src/server/game/Grids/Cells/CellImpl.h
+++ b/src/server/game/Grids/Cells/CellImpl.h
@@ -46,140 +46,22 @@ inline Cell::Cell(float x, float y)
data.Part.reserved = 0;
}
-template<class T, class CONTAINER>
-inline void
-Cell::Visit(const CellCoord& standing_cell, TypeContainerVisitor<T, CONTAINER> &visitor, Map &m) const
-{
- if (!standing_cell.IsCoordValid())
- return;
-
- uint16 district = (District)this->data.Part.reserved;
- if (district == CENTER_DISTRICT)
- {
- m.Visit(*this, visitor);
- return;
- }
-
- // set up the cell range based on the district
- CellCoord begin_cell = standing_cell;
- CellCoord end_cell = standing_cell;
-
- switch (district)
- {
- case ALL_DISTRICT:
- {
- begin_cell.dec_x(1); begin_cell.dec_y(1); // upper left
- end_cell.inc_x(1); end_cell.inc_y(1); // lower right
- break;
- }
- case UPPER_LEFT_DISTRICT:
- {
- begin_cell.dec_x(1); begin_cell.dec_y(1); // upper left
- break;
- }
- case UPPER_RIGHT_DISTRICT:
- {
- begin_cell.dec_y(1); // up
- end_cell.inc_x(1); // right
- break;
- }
- case LOWER_LEFT_DISTRICT:
- {
- begin_cell.dec_x(1); // left
- end_cell.inc_y(1); // down
- break;
- }
- case LOWER_RIGHT_DISTRICT:
- {
- end_cell.inc_x(1); end_cell.inc_y(1); // lower right
- break;
- }
- case LEFT_DISTRICT:
- {
- begin_cell.dec_y(1); // up
- end_cell.inc_x(1); end_cell.inc_y(1); // lower right
- break;
- }
- case RIGHT_DISTRICT:
- {
- begin_cell.dec_x(1); begin_cell.dec_y(1); // upper left
- end_cell.inc_y(1); // down
- break;
- }
- case UPPER_DISTRICT:
- {
- begin_cell.dec_x(1); begin_cell.dec_y(1); // upper left
- end_cell.inc_x(1); // right
- break;
- }
- case LOWER_DISTRICT:
- {
- begin_cell.dec_x(1); // left
- end_cell.inc_x(1); end_cell.inc_y(1); // lower right
- break;
- }
- default:
- {
- ASSERT(false);
- break;
- }
- }
-
- // loop the cell range
- for (uint32 x = begin_cell.x_coord; x <= end_cell.x_coord; x++)
- {
- for (uint32 y = begin_cell.y_coord; y <= end_cell.y_coord; y++)
- {
- CellCoord cellCoord(x, y);
- Cell r_zone(cellCoord);
- r_zone.data.Part.nocreate = this->data.Part.nocreate;
- m.Visit(r_zone, visitor);
- }
- }
-}
-
-inline int CellHelper(const float radius)
-{
- if (radius < 1.0f)
- return 0;
-
- return (int)ceilf(radius/SIZE_OF_GRID_CELL);
-}
-
-inline CellArea Cell::CalculateCellArea(const WorldObject &obj, float radius)
-{
- return Cell::CalculateCellArea(obj.GetPositionX(), obj.GetPositionY(), radius);
-}
-
inline CellArea Cell::CalculateCellArea(float x, float y, float radius)
{
if (radius <= 0.0f)
- return CellArea();
-
- //lets calculate object coord offsets from cell borders.
- //TODO: add more correct/generic method for this task
- const float x_offset = (x - CENTER_GRID_CELL_OFFSET)/SIZE_OF_GRID_CELL;
- const float y_offset = (y - CENTER_GRID_CELL_OFFSET)/SIZE_OF_GRID_CELL;
-
- const float x_val = floor(x_offset + CENTER_GRID_CELL_ID + 0.5f);
- const float y_val = floor(y_offset + CENTER_GRID_CELL_ID + 0.5f);
-
- const float x_off = (x_offset - x_val + CENTER_GRID_CELL_ID) * SIZE_OF_GRID_CELL;
- const float y_off = (y_offset - y_val + CENTER_GRID_CELL_ID) * SIZE_OF_GRID_CELL;
+ {
+ CellCoord center = Trinity::ComputeCellCoord(x, y).normalize();
+ return CellArea(center, center);
+ }
- const float tmp_diff = radius - CENTER_GRID_CELL_OFFSET;
- //lets calculate upper/lower/right/left corners for cell search
- int right = CellHelper(tmp_diff + x_off);
- int left = CellHelper(tmp_diff - x_off);
- int upper = CellHelper(tmp_diff + y_off);
- int lower = CellHelper(tmp_diff - y_off);
+ CellCoord centerX = Trinity::ComputeCellCoord(x - radius, y - radius).normalize();
+ CellCoord centerY = Trinity::ComputeCellCoord(x + radius, y + radius).normalize();
- return CellArea(right, left, upper, lower);
+ return CellArea(centerX, centerY);
}
template<class T, class CONTAINER>
-inline void
-Cell::Visit(const CellCoord& standing_cell, TypeContainerVisitor<T, CONTAINER> &visitor, Map &m, float radius, float x_off, float y_off) const
+inline void Cell::Visit(CellCoord const& standing_cell, TypeContainerVisitor<T, CONTAINER>& visitor, Map& map, float radius, float x_off, float y_off) const
{
if (!standing_cell.IsCoordValid())
return;
@@ -189,7 +71,7 @@ Cell::Visit(const CellCoord& standing_cell, TypeContainerVisitor<T, CONTAINER> &
//maybe it is better to just return when radius <= 0.0f?
if (radius <= 0.0f)
{
- m.Visit(*this, visitor);
+ map.Visit(*this, visitor);
return;
}
//lets limit the upper value for search radius
@@ -201,32 +83,28 @@ Cell::Visit(const CellCoord& standing_cell, TypeContainerVisitor<T, CONTAINER> &
//if radius fits inside standing cell
if (!area)
{
- m.Visit(*this, visitor);
+ map.Visit(*this, visitor);
return;
}
- CellCoord begin_cell = standing_cell;
- CellCoord end_cell = standing_cell;
-
- area.ResizeBorders(begin_cell, end_cell);
//visit all cells, found in CalculateCellArea()
//if radius is known to reach cell area more than 4x4 then we should call optimized VisitCircle
//currently this technique works with MAX_NUMBER_OF_CELLS 16 and higher, with lower values
//there are nothing to optimize because SIZE_OF_GRID_CELL is too big...
- if (((end_cell.x_coord - begin_cell.x_coord) > 4) && ((end_cell.y_coord - begin_cell.y_coord) > 4))
+ if (((area.high_bound.x_coord - area.low_bound.x_coord) > 4) && ((area.high_bound.y_coord - area.low_bound.y_coord) > 4))
{
- VisitCircle(visitor, m, begin_cell, end_cell);
+ VisitCircle(visitor, map, area.low_bound, area.high_bound);
return;
}
//ALWAYS visit standing cell first!!! Since we deal with small radiuses
//it is very essential to call visitor for standing cell firstly...
- m.Visit(*this, visitor);
+ map.Visit(*this, visitor);
// loop the cell range
- for (uint32 x = begin_cell.x_coord; x <= end_cell.x_coord; ++x)
+ for (uint32 x = area.low_bound.x_coord; x <= area.high_bound.x_coord; ++x)
{
- for (uint32 y = begin_cell.y_coord; y <= end_cell.y_coord; ++y)
+ for (uint32 y = area.low_bound.y_coord; y <= area.high_bound.y_coord; ++y)
{
CellCoord cellCoord(x, y);
//lets skip standing cell since we already visited it
@@ -234,24 +112,22 @@ Cell::Visit(const CellCoord& standing_cell, TypeContainerVisitor<T, CONTAINER> &
{
Cell r_zone(cellCoord);
r_zone.data.Part.nocreate = this->data.Part.nocreate;
- m.Visit(r_zone, visitor);
+ map.Visit(r_zone, visitor);
}
}
}
}
template<class T, class CONTAINER>
-inline void
-Cell::Visit(const CellCoord& l, TypeContainerVisitor<T, CONTAINER> &visitor, Map &m, const WorldObject &obj, float radius) const
+inline void Cell::Visit(CellCoord const& standing_cell, TypeContainerVisitor<T, CONTAINER>& visitor, Map& map, WorldObject const& obj, float radius) const
{
//we should increase search radius by object's radius, otherwise
//we could have problems with huge creatures, which won't attack nearest players etc
- Visit(l, visitor, m, radius + obj.GetObjectSize(), obj.GetPositionX(), obj.GetPositionY());
+ Visit(standing_cell, visitor, map, radius + obj.GetObjectSize(), obj.GetPositionX(), obj.GetPositionY());
}
template<class T, class CONTAINER>
-inline void
-Cell::VisitCircle(TypeContainerVisitor<T, CONTAINER> &visitor, Map &m, const CellCoord& begin_cell, const CellCoord& end_cell) const
+inline void Cell::VisitCircle(TypeContainerVisitor<T, CONTAINER>& visitor, Map& map, CellCoord const& begin_cell, CellCoord const& end_cell) const
{
//here is an algorithm for 'filling' circum-squared octagon
uint32 x_shift = (uint32)ceilf((end_cell.x_coord - begin_cell.x_coord) * 0.3f - 0.5f);
@@ -267,7 +143,7 @@ Cell::VisitCircle(TypeContainerVisitor<T, CONTAINER> &visitor, Map &m, const Cel
CellCoord cellCoord(x, y);
Cell r_zone(cellCoord);
r_zone.data.Part.nocreate = this->data.Part.nocreate;
- m.Visit(r_zone, visitor);
+ map.Visit(r_zone, visitor);
}
}
@@ -291,13 +167,13 @@ Cell::VisitCircle(TypeContainerVisitor<T, CONTAINER> &visitor, Map &m, const Cel
CellCoord cellCoord_left(x_start - step, y);
Cell r_zone_left(cellCoord_left);
r_zone_left.data.Part.nocreate = this->data.Part.nocreate;
- m.Visit(r_zone_left, visitor);
+ map.Visit(r_zone_left, visitor);
//right trapezoid cell visit
CellCoord cellCoord_right(x_end + step, y);
Cell r_zone_right(cellCoord_right);
r_zone_right.data.Part.nocreate = this->data.Part.nocreate;
- m.Visit(r_zone_right, visitor);
+ map.Visit(r_zone_right, visitor);
}
}
}
diff --git a/src/server/game/Grids/GridDefines.h b/src/server/game/Grids/GridDefines.h
index c8abc314ff0..44e2588ef81 100644
--- a/src/server/game/Grids/GridDefines.h
+++ b/src/server/game/Grids/GridDefines.h
@@ -128,6 +128,13 @@ struct CoordPair
return x_coord < LIMIT && y_coord < LIMIT;
}
+ CoordPair& normalize()
+ {
+ x_coord = std::min(x_coord, LIMIT - 1);
+ y_coord = std::min(y_coord, LIMIT - 1);
+ return *this;
+ }
+
uint32 x_coord;
uint32 y_coord;
};
diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp
index 485b1ba164f..425a31fc38a 100755
--- a/src/server/game/Maps/Map.cpp
+++ b/src/server/game/Maps/Map.cpp
@@ -484,22 +484,16 @@ bool Map::IsGridLoaded(const GridCoord &p) const
void Map::VisitNearbyCellsOf(WorldObject* obj, TypeContainerVisitor<Trinity::ObjectUpdater, GridTypeMapContainer> &gridVisitor, TypeContainerVisitor<Trinity::ObjectUpdater, WorldTypeMapContainer> &worldVisitor)
{
- CellCoord standing_cell(Trinity::ComputeCellCoord(obj->GetPositionX(), obj->GetPositionY()));
-
- // Check for correctness of standing_cell, it also avoids problems with update_cell
- if (!standing_cell.IsCoordValid())
+ // Check for valid position
+ if (!obj->IsPositionValid())
return;
- // the overloaded operators handle range checking
- // so there's no need for range checking inside the loop
- CellCoord begin_cell(standing_cell), end_cell(standing_cell);
- //lets update mobs/objects in ALL visible cells around object!
- CellArea area = Cell::CalculateCellArea(*obj, obj->GetGridActivationRange());
- area.ResizeBorders(begin_cell, end_cell);
+ // Update mobs/objects in ALL visible cells around object!
+ CellArea area = Cell::CalculateCellArea(obj->GetPositionX(), obj->GetPositionY(), obj->GetGridActivationRange());
- for (uint32 x = begin_cell.x_coord; x <= end_cell.x_coord; ++x)
+ for (uint32 x = area.low_bound.x_coord; x <= area.high_bound.x_coord; ++x)
{
- for (uint32 y = begin_cell.y_coord; y <= end_cell.y_coord; ++y)
+ for (uint32 y = area.low_bound.y_coord; y <= area.high_bound.y_coord; ++y)
{
// marked cells are those that have been visited
// don't visit the same cell twice
@@ -510,9 +504,8 @@ void Map::VisitNearbyCellsOf(WorldObject* obj, TypeContainerVisitor<Trinity::Obj
markCell(cell_id);
CellCoord pair(x, y);
Cell cell(pair);
- cell.data.Part.reserved = CENTER_DISTRICT;
- cell.Visit(pair, gridVisitor, *this);
- cell.Visit(pair, worldVisitor, *this);
+ Visit(cell, gridVisitor);
+ Visit(cell, worldVisitor);
}
}
}
@@ -1841,7 +1834,7 @@ bool Map::IsInWater(float x, float y, float pZ, LiquidData* data) const
LiquidData liquid_status;
LiquidData* liquid_ptr = data ? data : &liquid_status;
if (getLiquidStatus(x, y, pZ, MAP_ALL_LIQUIDS, liquid_ptr))
- return true;
+ return true;
}
return false;
}
@@ -1880,7 +1873,6 @@ const char* Map::GetMapName() const
void Map::UpdateObjectVisibility(WorldObject* obj, Cell cell, CellCoord cellpair)
{
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
Trinity::VisibleChangesNotifier notifier(*obj);
TypeContainerVisitor<Trinity::VisibleChangesNotifier, WorldTypeMapContainer > player_notifier(notifier);
@@ -1891,7 +1883,6 @@ void Map::UpdateObjectsVisibilityFor(Player* player, Cell cell, CellCoord cellpa
{
Trinity::VisibleNotifier notifier(*player);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
TypeContainerVisitor<Trinity::VisibleNotifier, WorldTypeMapContainer > world_notifier(notifier);
TypeContainerVisitor<Trinity::VisibleNotifier, GridTypeMapContainer > grid_notifier(notifier);
diff --git a/src/server/game/Maps/Map.h b/src/server/game/Maps/Map.h
index 2247908fb08..a8386360ae2 100755
--- a/src/server/game/Maps/Map.h
+++ b/src/server/game/Maps/Map.h
@@ -615,8 +615,7 @@ class BattlegroundMap : public Map
};
template<class T, class CONTAINER>
-inline void
-Map::Visit(const Cell& cell, TypeContainerVisitor<T, CONTAINER> &visitor)
+inline void Map::Visit(Cell const& cell, TypeContainerVisitor<T, CONTAINER>& visitor)
{
const uint32 x = cell.GridX();
const uint32 y = cell.GridY();
@@ -631,12 +630,10 @@ Map::Visit(const Cell& cell, TypeContainerVisitor<T, CONTAINER> &visitor)
}
template<class NOTIFIER>
-inline void
-Map::VisitAll(const float &x, const float &y, float radius, NOTIFIER &notifier)
+inline void Map::VisitAll(float const& x, float const& y, float radius, NOTIFIER& notifier)
{
CellCoord p(Trinity::ComputeCellCoord(x, y));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
TypeContainerVisitor<NOTIFIER, WorldTypeMapContainer> world_object_notifier(notifier);
@@ -647,12 +644,10 @@ Map::VisitAll(const float &x, const float &y, float radius, NOTIFIER &notifier)
// should be used with Searcher notifiers, tries to search world if nothing found in grid
template<class NOTIFIER>
-inline void
-Map::VisitFirstFound(const float &x, const float &y, float radius, NOTIFIER &notifier)
+inline void Map::VisitFirstFound(const float &x, const float &y, float radius, NOTIFIER &notifier)
{
CellCoord p(Trinity::ComputeCellCoord(x, y));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
TypeContainerVisitor<NOTIFIER, WorldTypeMapContainer> world_object_notifier(notifier);
@@ -665,12 +660,10 @@ Map::VisitFirstFound(const float &x, const float &y, float radius, NOTIFIER &not
}
template<class NOTIFIER>
-inline void
-Map::VisitWorld(const float &x, const float &y, float radius, NOTIFIER &notifier)
+inline void Map::VisitWorld(const float &x, const float &y, float radius, NOTIFIER &notifier)
{
CellCoord p(Trinity::ComputeCellCoord(x, y));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
TypeContainerVisitor<NOTIFIER, WorldTypeMapContainer> world_object_notifier(notifier);
@@ -678,12 +671,10 @@ Map::VisitWorld(const float &x, const float &y, float radius, NOTIFIER &notifier
}
template<class NOTIFIER>
-inline void
-Map::VisitGrid(const float &x, const float &y, float radius, NOTIFIER &notifier)
+inline void Map::VisitGrid(const float &x, const float &y, float radius, NOTIFIER &notifier)
{
CellCoord p(Trinity::ComputeCellCoord(x, y));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
TypeContainerVisitor<NOTIFIER, GridTypeMapContainer > grid_object_notifier(notifier);
diff --git a/src/server/game/Scripting/MapScripts.cpp b/src/server/game/Scripting/MapScripts.cpp
index 8f51eccf791..88c9795e896 100755
--- a/src/server/game/Scripting/MapScripts.cpp
+++ b/src/server/game/Scripting/MapScripts.cpp
@@ -266,21 +266,20 @@ inline void Map::_ScriptProcessDoor(Object* source, Object* target, const Script
}
}
-inline GameObject* Map::_FindGameObject(WorldObject* pSearchObject, uint32 guid) const
+inline GameObject* Map::_FindGameObject(WorldObject* searchObject, uint32 guid) const
{
- GameObject* pGameObject = NULL;
+ GameObject* gameobject = NULL;
- CellCoord p(Trinity::ComputeCellCoord(pSearchObject->GetPositionX(), pSearchObject->GetPositionY()));
+ CellCoord p(Trinity::ComputeCellCoord(searchObject->GetPositionX(), searchObject->GetPositionY()));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
- Trinity::GameObjectWithDbGUIDCheck goCheck(*pSearchObject, guid);
- Trinity::GameObjectSearcher<Trinity::GameObjectWithDbGUIDCheck> checker(pSearchObject, pGameObject, goCheck);
+ Trinity::GameObjectWithDbGUIDCheck goCheck(*searchObject, guid);
+ Trinity::GameObjectSearcher<Trinity::GameObjectWithDbGUIDCheck> checker(searchObject, gameobject, goCheck);
TypeContainerVisitor<Trinity::GameObjectSearcher<Trinity::GameObjectWithDbGUIDCheck>, GridTypeMapContainer > objectChecker(checker);
- cell.Visit(p, objectChecker, *pSearchObject->GetMap());
+ cell.Visit(p, objectChecker, *searchObject->GetMap(), *searchObject, searchObject->GetGridActivationRange());
- return pGameObject;
+ return gameobject;
}
/// Process queued scripts
@@ -820,13 +819,12 @@ void Map::ScriptsProcess()
CellCoord p(Trinity::ComputeCellCoord(wSource->GetPositionX(), wSource->GetPositionY()));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
Trinity::CreatureWithDbGUIDCheck target_check(wSource, step.script->CallScript.CreatureEntry);
Trinity::CreatureSearcher<Trinity::CreatureWithDbGUIDCheck> checker(wSource, cTarget, target_check);
TypeContainerVisitor<Trinity::CreatureSearcher <Trinity::CreatureWithDbGUIDCheck>, GridTypeMapContainer > unit_checker(checker);
- cell.Visit(p, unit_checker, *wSource->GetMap());
+ cell.Visit(p, unit_checker, *wSource->GetMap(), *wSource, wSource->GetGridActivationRange());
}
else //check hashmap holders
{
diff --git a/src/server/game/Server/Protocol/Handlers/ChatHandler.cpp b/src/server/game/Server/Protocol/Handlers/ChatHandler.cpp
index d1a70cd89de..70dc0ace8eb 100755
--- a/src/server/game/Server/Protocol/Handlers/ChatHandler.cpp
+++ b/src/server/game/Server/Protocol/Handlers/ChatHandler.cpp
@@ -569,7 +569,6 @@ void WorldSession::HandleTextEmoteOpcode(WorldPacket & recv_data)
CellCoord p = Trinity::ComputeCellCoord(GetPlayer()->GetPositionX(), GetPlayer()->GetPositionY());
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
Trinity::EmoteChatBuilder emote_builder(*GetPlayer(), text_emote, emoteNum, unit);
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
index 9fc74ae1345..ed585739399 100755
--- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp
+++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
@@ -5713,7 +5713,6 @@ void AuraEffect::HandlePeriodicDummyAuraTick(Unit* target, Unit* caster) const
CellCoord p(Trinity::ComputeCellCoord(target->GetPositionX(), target->GetPositionY()));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
Trinity::AnyUnfriendlyAttackableVisibleUnitInObjectRangeCheck u_check(target, radius);
Trinity::UnitListSearcher<Trinity::AnyUnfriendlyAttackableVisibleUnitInObjectRangeCheck> checker(target, targets, u_check);
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index 98ac52114c8..7eb64e74080 100755
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -600,7 +600,6 @@ WorldObject* Spell::FindCorpseUsing()
CellCoord p(Trinity::ComputeCellCoord(m_caster->GetPositionX(), m_caster->GetPositionY()));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
WorldObject* result = NULL;
@@ -5831,7 +5830,6 @@ SpellCastResult Spell::CheckItems()
{
CellCoord p(Trinity::ComputeCellCoord(m_caster->GetPositionX(), m_caster->GetPositionY()));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
GameObject* ok = NULL;
Trinity::GameObjectFocusCheck go_check(m_caster, m_spellInfo->RequiresSpellFocus);
diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp
index 881e407d7c8..4e3f3899b35 100644
--- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp
+++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp
@@ -486,13 +486,12 @@ public:
CellCoord pair(Trinity::ComputeCellCoord(x, y));
Cell cell(pair);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
Trinity::AllCreaturesOfEntryInRange check(me, entry, 100);
Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange> searcher(me, templist, check);
TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange>, GridTypeMapContainer> cSearcher(searcher);
- cell.Visit(pair, cSearcher, *(me->GetMap()));
+ cell.Visit(pair, cSearcher, *(me->GetMap()), *me, me->GetGridActivationRange());
for (std::list<Creature*>::const_iterator i = templist.begin(); i != templist.end(); ++i)
{
diff --git a/src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp b/src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp
index 026b2d2fda3..413897c94e8 100644
--- a/src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp
+++ b/src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp
@@ -191,20 +191,19 @@ class boss_akilzon : public CreatureScript
CellCoord p(Trinity::ComputeCellCoord(me->GetPositionX(), me->GetPositionY()));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
std::list<Unit*> tempUnitMap;
{
- Trinity::AnyAoETargetUnitInObjectRangeCheck u_check(me, me, 999);
+ Trinity::AnyAoETargetUnitInObjectRangeCheck u_check(me, me, SIZE_OF_GRIDS);
Trinity::UnitListSearcher<Trinity::AnyAoETargetUnitInObjectRangeCheck> searcher(me, tempUnitMap, u_check);
TypeContainerVisitor<Trinity::UnitListSearcher<Trinity::AnyAoETargetUnitInObjectRangeCheck>, WorldTypeMapContainer > world_unit_searcher(searcher);
TypeContainerVisitor<Trinity::UnitListSearcher<Trinity::AnyAoETargetUnitInObjectRangeCheck>, GridTypeMapContainer > grid_unit_searcher(searcher);
- cell.Visit(p, world_unit_searcher, *(me->GetMap()));
- cell.Visit(p, grid_unit_searcher, *(me->GetMap()));
+ cell.Visit(p, world_unit_searcher, *me->GetMap(), *me, SIZE_OF_GRIDS);
+ cell.Visit(p, grid_unit_searcher, *me->GetMap(), *me, SIZE_OF_GRIDS);
}
//dealdamege
for (std::list<Unit*>::const_iterator i = tempUnitMap.begin(); i != tempUnitMap.end(); ++i)
diff --git a/src/server/scripts/EasternKingdoms/ZulAman/boss_janalai.cpp b/src/server/scripts/EasternKingdoms/ZulAman/boss_janalai.cpp
index e49891f0b51..aea9e322583 100644
--- a/src/server/scripts/EasternKingdoms/ZulAman/boss_janalai.cpp
+++ b/src/server/scripts/EasternKingdoms/ZulAman/boss_janalai.cpp
@@ -235,7 +235,6 @@ class boss_janalai : public CreatureScript
{
CellCoord pair(Trinity::ComputeCellCoord(x, y));
Cell cell(pair);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
Trinity::AllCreaturesOfEntryInRange check(me, MOB_EGG, 100);
@@ -243,7 +242,7 @@ class boss_janalai : public CreatureScript
TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange>, GridTypeMapContainer> cSearcher(searcher);
- cell.Visit(pair, cSearcher, *(me->GetMap()));
+ cell.Visit(pair, cSearcher, *me->GetMap(), *me, me->GetGridActivationRange());
}
//sLog->outError("Eggs %d at middle", templist.size());
@@ -269,7 +268,6 @@ class boss_janalai : public CreatureScript
{
CellCoord pair(Trinity::ComputeCellCoord(x, y));
Cell cell(pair);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
Trinity::AllCreaturesOfEntryInRange check(me, MOB_FIRE_BOMB, 100);
@@ -277,7 +275,7 @@ class boss_janalai : public CreatureScript
TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange>, GridTypeMapContainer> cSearcher(searcher);
- cell.Visit(pair, cSearcher, *(me->GetMap()));
+ cell.Visit(pair, cSearcher, *me->GetMap(), *me, me->GetGridActivationRange());
}
for (std::list<Creature*>::const_iterator i = templist.begin(); i != templist.end(); ++i)
{
@@ -521,7 +519,6 @@ class mob_janalai_hatcher : public CreatureScript
{
CellCoord pair(Trinity::ComputeCellCoord(x, y));
Cell cell(pair);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
Trinity::AllCreaturesOfEntryInRange check(me, 23817, 50);
@@ -529,7 +526,7 @@ class mob_janalai_hatcher : public CreatureScript
TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange>, GridTypeMapContainer> cSearcher(searcher);
- cell.Visit(pair, cSearcher, *(me->GetMap()));
+ cell.Visit(pair, cSearcher, *(me->GetMap()), *me, me->GetGridActivationRange());
}
//sLog->outError("Eggs %d at %d", templist.size(), side);
diff --git a/src/server/scripts/EasternKingdoms/ZulAman/boss_nalorakk.cpp b/src/server/scripts/EasternKingdoms/ZulAman/boss_nalorakk.cpp
index 20fb8fdf68c..3ff465a3c1d 100644
--- a/src/server/scripts/EasternKingdoms/ZulAman/boss_nalorakk.cpp
+++ b/src/server/scripts/EasternKingdoms/ZulAman/boss_nalorakk.cpp
@@ -164,7 +164,6 @@ class boss_nalorakk : public CreatureScript
{
CellCoord pair(Trinity::ComputeCellCoord(x, y));
Cell cell(pair);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
Trinity::AllFriendlyCreaturesInGrid check(me);
@@ -172,7 +171,7 @@ class boss_nalorakk : public CreatureScript
TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::AllFriendlyCreaturesInGrid>, GridTypeMapContainer> cSearcher(searcher);
- cell.Visit(pair, cSearcher, *(me->GetMap()));
+ cell.Visit(pair, cSearcher, *(me->GetMap()), *me, me->GetGridActivationRange());
}
if (templist.empty())
diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp
index 077ab9dda36..187ff9b9dd7 100644
--- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp
+++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp
@@ -459,7 +459,9 @@ void hyjalAI::SummonCreature(uint32 entry, float Base[4][3])
creature = me->SummonCreature(entry, SpawnPointSpecial[SPAWN_NEAR_TOWER][0]+irand(-20, 20), SpawnPointSpecial[SPAWN_NEAR_TOWER][1]+irand(-20, 20), SpawnPointSpecial[SPAWN_NEAR_TOWER][2]+irand(-10, 10), 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 120000);
if (creature)
CAST_AI(hyjal_trashAI, creature->AI())->useFlyPath = true;
- }else{//summon at gate
+ }
+ else
+ {//summon at gate
creature = me->SummonCreature(entry, SpawnPointSpecial[SPAWN_GARG_GATE][0]+irand(-10, 10), SpawnPointSpecial[SPAWN_GARG_GATE][1]+irand(-10, 10), SpawnPointSpecial[SPAWN_GARG_GATE][2]+irand(-10, 10), 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 120000);
}
break;
@@ -910,6 +912,7 @@ void hyjalAI::UpdateAI(const uint32 diff)
DoMeleeAttackIfReady();
}
+
void hyjalAI::JustDied(Unit* /*killer*/)
{
if (IsDummy)return;
@@ -932,23 +935,20 @@ void hyjalAI::JustDied(Unit* /*killer*/)
instance->SetData(DATA_RESET_RAIDDAMAGE, 0);//reset damage on die
}
}
+
void hyjalAI::HideNearPos(float x, float y)
{
CellCoord pair(Trinity::ComputeCellCoord(x, y));
Cell cell(pair);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
// First get all creatures.
std::list<Creature*> creatures;
Trinity::AllFriendlyCreaturesInGrid creature_check(me);
Trinity::CreatureListSearcher<Trinity::AllFriendlyCreaturesInGrid> creature_searcher(me, creatures, creature_check);
- TypeContainerVisitor
- <Trinity::CreatureListSearcher<Trinity::AllFriendlyCreaturesInGrid>,
- GridTypeMapContainer> creature_visitor(creature_searcher);
- // Get Creatures
- cell.Visit(pair, creature_visitor, *(me->GetMap()));
+ TypeContainerVisitor <Trinity::CreatureListSearcher<Trinity::AllFriendlyCreaturesInGrid>, GridTypeMapContainer> creature_visitor(creature_searcher);
+ cell.Visit(pair, creature_visitor, *(me->GetMap()), *me, me->GetGridActivationRange());
if (!creatures.empty())
{
@@ -959,18 +959,19 @@ void hyjalAI::HideNearPos(float x, float y)
}
}
}
+
void hyjalAI::RespawnNearPos(float x, float y)
{
CellCoord p(Trinity::ComputeCellCoord(x, y));
Cell cell(p);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
Trinity::RespawnDo u_do;
Trinity::WorldObjectWorker<Trinity::RespawnDo> worker(me, u_do);
TypeContainerVisitor<Trinity::WorldObjectWorker<Trinity::RespawnDo>, GridTypeMapContainer > obj_worker(worker);
- cell.Visit(p, obj_worker, *me->GetMap());
+ cell.Visit(p, obj_worker, *me->GetMap(), *me, me->GetGridActivationRange());
}
+
void hyjalAI::WaypointReached(uint32 i)
{
if (i == 1 || (i == 0 && me->GetEntry() == THRALL))
@@ -994,7 +995,6 @@ void hyjalAI::WaypointReached(uint32 i)
//all alive guards walk near here
CellCoord pair(Trinity::ComputeCellCoord(me->GetPositionX(), me->GetPositionY()));
Cell cell(pair);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
// First get all creatures.
@@ -1005,7 +1005,7 @@ void hyjalAI::WaypointReached(uint32 i)
<Trinity::CreatureListSearcher<Trinity::AllFriendlyCreaturesInGrid>,
GridTypeMapContainer> creature_visitor(creature_searcher);
- cell.Visit(pair, creature_visitor, *(me->GetMap()));
+ cell.Visit(pair, creature_visitor, *(me->GetMap()), *me, me->GetGridActivationRange());
if (!creatures.empty())
{
@@ -1036,7 +1036,6 @@ void hyjalAI::DoOverrun(uint32 faction, const uint32 diff)
{
CellCoord pair(Trinity::ComputeCellCoord(me->GetPositionX(), me->GetPositionY()));
Cell cell(pair);
- cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
std::list<Creature*> creatures;
@@ -1046,7 +1045,7 @@ void hyjalAI::DoOverrun(uint32 faction, const uint32 diff)
<Trinity::CreatureListSearcher<Trinity::AllFriendlyCreaturesInGrid>,
GridTypeMapContainer> creature_visitor(creature_searcher);
- cell.Visit(pair, creature_visitor, *(me->GetMap()));
+ cell.Visit(pair, creature_visitor, *(me->GetMap()), *me, me->GetGridActivationRange());
if (!creatures.empty())
{