aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2017-05-13 19:37:33 +0200
committerShauren <shauren.trinity@gmail.com>2017-05-13 19:37:33 +0200
commit9299e9bde087af7e5d777d5a55a3b79d2b63c48e (patch)
tree4d3e436ae21faf28154be8a70fd7d23c1b7692f0 /src
parent229c78b5a38dc58e14f4912de49437b68341452b (diff)
Core/Grids: Ported cmangos/mangos-wotlk@ea99457e50790acde8928aa0f3dc4a9c096b4a8c
Diffstat (limited to 'src')
-rw-r--r--src/server/game/AI/CoreAI/TotemAI.cpp2
-rw-r--r--src/server/game/AI/ScriptedAI/ScriptedCreature.cpp14
-rw-r--r--src/server/game/AI/SmartScripts/SmartScript.cpp32
-rw-r--r--src/server/game/Achievements/AchievementMgr.cpp4
-rw-r--r--src/server/game/Battlefield/Battlefield.cpp2
-rw-r--r--src/server/game/Chat/Chat.cpp2
-rw-r--r--src/server/game/Entities/AreaTrigger/AreaTrigger.cpp8
-rw-r--r--src/server/game/Entities/Creature/Creature.cpp88
-rw-r--r--src/server/game/Entities/GameObject/GameObject.cpp29
-rw-r--r--src/server/game/Entities/Object/Object.cpp41
-rw-r--r--src/server/game/Entities/Object/Object.h4
-rw-r--r--src/server/game/Entities/Player/Player.cpp8
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp10
-rw-r--r--src/server/game/Grids/Cells/Cell.h12
-rw-r--r--src/server/game/Grids/Cells/CellImpl.h95
-rw-r--r--src/server/game/Grids/Notifiers/GridNotifiers.cpp11
-rw-r--r--src/server/game/Handlers/LootHandler.cpp2
-rw-r--r--src/server/game/Maps/Map.cpp22
-rw-r--r--src/server/game/Maps/Map.h59
-rw-r--r--src/server/game/OutdoorPvP/OutdoorPvP.cpp2
-rw-r--r--src/server/game/Spells/Auras/SpellAuraEffects.cpp2
-rw-r--r--src/server/game/Spells/Auras/SpellAuras.cpp10
-rw-r--r--src/server/game/Spells/Spell.cpp13
-rw-r--r--src/server/game/Texts/CreatureTextMgr.h4
-rw-r--r--src/server/scripts/Commands/cs_debug.cpp2
-rw-r--r--src/server/scripts/Commands/cs_misc.cpp2
-rw-r--r--src/server/scripts/Commands/cs_mmaps.cpp11
-rw-r--r--src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp7
-rw-r--r--src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp35
-rw-r--r--src/server/scripts/Kalimdor/Firelands/boss_alysrazor.cpp4
-rw-r--r--src/server/scripts/Kalimdor/OnyxiasLair/boss_onyxia.cpp2
-rw-r--r--src/server/scripts/Kalimdor/OnyxiasLair/instance_onyxias_lair.cpp2
-rw-r--r--src/server/scripts/Kalimdor/RazorfenDowns/razorfen_downs.cpp2
-rw-r--r--src/server/scripts/Kalimdor/zone_azuremyst_isle.cpp2
-rw-r--r--src/server/scripts/Kalimdor/zone_bloodmyst_isle.cpp2
-rw-r--r--src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/boss_sartharion.cpp2
-rw-r--r--src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_twin_valkyr.cpp2
-rw-r--r--src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp4
-rw-r--r--src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp2
-rw-r--r--src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp6
-rw-r--r--src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp8
-rw-r--r--src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp2
-rw-r--r--src/server/scripts/Northrend/Ulduar/Ulduar/boss_hodir.cpp4
-rw-r--r--src/server/scripts/Outland/zone_blades_edge_mountains.cpp2
-rw-r--r--src/server/scripts/Pet/pet_dk.cpp2
-rw-r--r--src/server/scripts/Pet/pet_mage.cpp4
-rw-r--r--src/server/scripts/Spells/spell_generic.cpp4
-rw-r--r--src/server/scripts/Spells/spell_holiday.cpp2
-rw-r--r--src/server/scripts/Spells/spell_hunter.cpp4
-rw-r--r--src/server/scripts/Spells/spell_quest.cpp10
-rw-r--r--src/server/scripts/World/npcs_special.cpp2
-rw-r--r--src/server/shared/Realm/Realm.cpp2
-rw-r--r--src/server/worldserver/Main.cpp2
53 files changed, 227 insertions, 384 deletions
diff --git a/src/server/game/AI/CoreAI/TotemAI.cpp b/src/server/game/AI/CoreAI/TotemAI.cpp
index 6e8eee7a24c..38f49c9389f 100644
--- a/src/server/game/AI/CoreAI/TotemAI.cpp
+++ b/src/server/game/AI/CoreAI/TotemAI.cpp
@@ -74,7 +74,7 @@ void TotemAI::UpdateAI(uint32 /*diff*/)
victim = NULL;
Trinity::NearestAttackableUnitInObjectRangeCheck u_check(me, me, max_range);
Trinity::UnitLastSearcher<Trinity::NearestAttackableUnitInObjectRangeCheck> checker(me, victim, u_check);
- me->VisitNearbyObject(max_range, checker);
+ Cell::VisitAllObjects(me, checker, max_range);
}
// If have target
diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
index f4dbb0e128a..463d121bced 100644
--- a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
+++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
@@ -319,7 +319,7 @@ Unit* ScriptedAI::DoSelectLowestHpFriendly(float range, uint32 minHPDiff)
Unit* unit = nullptr;
Trinity::MostHPMissingInRange u_check(me, range, minHPDiff);
Trinity::UnitLastSearcher<Trinity::MostHPMissingInRange> searcher(me, unit, u_check);
- me->VisitNearbyObject(range, searcher);
+ Cell::VisitAllObjects(me, searcher, range);
return unit;
}
@@ -329,7 +329,7 @@ std::list<Creature*> ScriptedAI::DoFindFriendlyCC(float range)
std::list<Creature*> list;
Trinity::FriendlyCCedInRange u_check(me, range);
Trinity::CreatureListSearcher<Trinity::FriendlyCCedInRange> searcher(me, list, u_check);
- me->VisitNearbyObject(range, searcher);
+ Cell::VisitAllObjects(me, searcher, range);
return list;
}
@@ -339,7 +339,7 @@ std::list<Creature*> ScriptedAI::DoFindFriendlyMissingBuff(float range, uint32 u
std::list<Creature*> list;
Trinity::FriendlyMissingBuffInRange u_check(me, range, uiSpellid);
Trinity::CreatureListSearcher<Trinity::FriendlyMissingBuffInRange> searcher(me, list, u_check);
- me->VisitNearbyObject(range, searcher);
+ Cell::VisitAllObjects(me, searcher, range);
return list;
}
@@ -348,15 +348,9 @@ Player* ScriptedAI::GetPlayerAtMinimumRange(float minimumRange)
{
Player* player = nullptr;
- CellCoord pair(Trinity::ComputeCellCoord(me->GetPositionX(), me->GetPositionY()));
- Cell cell(pair);
- 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(), *me, minimumRange);
+ Cell::VisitWorldObjects(me, searcher, minimumRange);
return player;
}
diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp
index b13a3f255aa..b3dfb149562 100644
--- a/src/server/game/AI/SmartScripts/SmartScript.cpp
+++ b/src/server/game/AI/SmartScripts/SmartScript.cpp
@@ -2948,7 +2948,7 @@ ObjectList* SmartScript::GetWorldObjectsInDist(float dist)
{
Trinity::AllWorldObjectsInRange u_check(obj, dist);
Trinity::WorldObjectListSearcher<Trinity::AllWorldObjectsInRange> searcher(obj, *targets, u_check);
- obj->VisitNearbyObject(dist, searcher);
+ Cell::VisitAllObjects(obj, searcher, dist);
}
return targets;
}
@@ -3823,18 +3823,10 @@ Unit* SmartScript::DoSelectLowestHpFriendly(float range, uint32 MinHPDiff)
if (!me)
return nullptr;
- CellCoord p(Trinity::ComputeCellCoord(me->GetPositionX(), me->GetPositionY()));
- Cell cell(p);
- cell.SetNoCreate();
-
Unit* unit = nullptr;
-
Trinity::MostHPMissingInRange u_check(me, range, MinHPDiff);
Trinity::UnitLastSearcher<Trinity::MostHPMissingInRange> searcher(me, unit, u_check);
-
- TypeContainerVisitor<Trinity::UnitLastSearcher<Trinity::MostHPMissingInRange>, GridTypeMapContainer > grid_unit_searcher(searcher);
-
- cell.Visit(p, grid_unit_searcher, *me->GetMap(), *me, range);
+ Cell::VisitGridObjects(me, searcher, range);
return unit;
}
@@ -3843,16 +3835,9 @@ void SmartScript::DoFindFriendlyCC(std::list<Creature*>& _list, float range)
if (!me)
return;
- CellCoord p(Trinity::ComputeCellCoord(me->GetPositionX(), me->GetPositionY()));
- Cell cell(p);
- cell.SetNoCreate();
-
Trinity::FriendlyCCedInRange u_check(me, range);
Trinity::CreatureListSearcher<Trinity::FriendlyCCedInRange> searcher(me, _list, u_check);
-
- TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::FriendlyCCedInRange>, GridTypeMapContainer > grid_creature_searcher(searcher);
-
- cell.Visit(p, grid_creature_searcher, *me->GetMap(), *me, range);
+ Cell::VisitGridObjects(me, searcher, range);
}
void SmartScript::DoFindFriendlyMissingBuff(std::list<Creature*>& list, float range, uint32 spellid)
@@ -3860,16 +3845,9 @@ void SmartScript::DoFindFriendlyMissingBuff(std::list<Creature*>& list, float ra
if (!me)
return;
- CellCoord p(Trinity::ComputeCellCoord(me->GetPositionX(), me->GetPositionY()));
- Cell cell(p);
- cell.SetNoCreate();
-
Trinity::FriendlyMissingBuffInRange u_check(me, range, spellid);
Trinity::CreatureListSearcher<Trinity::FriendlyMissingBuffInRange> searcher(me, list, u_check);
-
- TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::FriendlyMissingBuffInRange>, GridTypeMapContainer > grid_creature_searcher(searcher);
-
- cell.Visit(p, grid_creature_searcher, *me->GetMap(), *me, range);
+ Cell::VisitGridObjects(me, searcher, range);
}
Unit* SmartScript::DoFindClosestFriendlyInRange(float range, bool playerOnly)
@@ -3880,7 +3858,7 @@ Unit* SmartScript::DoFindClosestFriendlyInRange(float range, bool playerOnly)
Unit* unit = nullptr;
Trinity::AnyFriendlyUnitInObjectRangeCheck u_check(me, me, range, playerOnly);
Trinity::UnitLastSearcher<Trinity::AnyFriendlyUnitInObjectRangeCheck> searcher(me, unit, u_check);
- me->VisitNearbyObject(range, searcher);
+ Cell::VisitAllObjects(me, searcher, range);
return unit;
}
diff --git a/src/server/game/Achievements/AchievementMgr.cpp b/src/server/game/Achievements/AchievementMgr.cpp
index fc6c722afed..429593fff47 100644
--- a/src/server/game/Achievements/AchievementMgr.cpp
+++ b/src/server/game/Achievements/AchievementMgr.cpp
@@ -599,8 +599,8 @@ void PlayerAchievementMgr::SendAchievementEarned(AchievementEntry const* achieve
{
Trinity::BroadcastTextBuilder _builder(_owner, CHAT_MSG_ACHIEVEMENT, BROADCAST_TEXT_ACHIEVEMENT_EARNED, _owner, achievement->ID);
Trinity::LocalizedPacketDo<Trinity::BroadcastTextBuilder> _localizer(_builder);
- Trinity::PlayerDistWorker<Trinity::LocalizedPacketDo<Trinity::BroadcastTextBuilder> > _worker(_owner, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_SAY), _localizer);
- _owner->VisitNearbyWorldObject(sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_SAY), _worker);
+ Trinity::PlayerDistWorker<Trinity::LocalizedPacketDo<Trinity::BroadcastTextBuilder>> _worker(_owner, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_SAY), _localizer);
+ Cell::VisitWorldObjects(_owner, _worker, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_SAY));
}
}
diff --git a/src/server/game/Battlefield/Battlefield.cpp b/src/server/game/Battlefield/Battlefield.cpp
index 3fbed11879d..533674ff156 100644
--- a/src/server/game/Battlefield/Battlefield.cpp
+++ b/src/server/game/Battlefield/Battlefield.cpp
@@ -1011,7 +1011,7 @@ bool BfCapturePoint::Update(uint32 diff)
std::list<Player*> players;
Trinity::AnyPlayerInObjectRangeCheck checker(capturePoint, radius);
Trinity::PlayerListSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(capturePoint, players, checker);
- capturePoint->VisitNearbyWorldObject(radius, searcher);
+ Cell::VisitWorldObjects(capturePoint, searcher, radius);
for (std::list<Player*>::iterator itr = players.begin(); itr != players.end(); ++itr)
if ((*itr)->IsOutdoorPvPActive())
diff --git a/src/server/game/Chat/Chat.cpp b/src/server/game/Chat/Chat.cpp
index 11b319e2c09..b935734a0f8 100644
--- a/src/server/game/Chat/Chat.cpp
+++ b/src/server/game/Chat/Chat.cpp
@@ -771,7 +771,7 @@ GameObject* ChatHandler::GetNearbyGameObject()
GameObject* obj = nullptr;
Trinity::NearestGameObjectCheck check(*pl);
Trinity::GameObjectLastSearcher<Trinity::NearestGameObjectCheck> searcher(pl, obj, check);
- pl->VisitNearbyGridObject(SIZE_OF_GRIDS, searcher);
+ Cell::VisitGridObjects(pl, searcher, SIZE_OF_GRIDS);
return obj;
}
diff --git a/src/server/game/Entities/AreaTrigger/AreaTrigger.cpp b/src/server/game/Entities/AreaTrigger/AreaTrigger.cpp
index 8caf45a59e4..99e343cc948 100644
--- a/src/server/game/Entities/AreaTrigger/AreaTrigger.cpp
+++ b/src/server/game/Entities/AreaTrigger/AreaTrigger.cpp
@@ -269,7 +269,7 @@ void AreaTrigger::SearchUnitInSphere(std::list<Unit*>& targetList)
Trinity::AnyUnitInObjectRangeCheck check(this, radius);
Trinity::UnitListSearcher<Trinity::AnyUnitInObjectRangeCheck> searcher(this, targetList, check);
- VisitNearbyObject(GetTemplate()->MaxSearchRadius, searcher);
+ Cell::VisitAllObjects(this, searcher, GetTemplate()->MaxSearchRadius);
}
void AreaTrigger::SearchUnitInBox(std::list<Unit*>& targetList)
@@ -280,7 +280,7 @@ void AreaTrigger::SearchUnitInBox(std::list<Unit*>& targetList)
Trinity::AnyUnitInObjectRangeCheck check(this, GetTemplate()->MaxSearchRadius, false);
Trinity::UnitListSearcher<Trinity::AnyUnitInObjectRangeCheck> searcher(this, targetList, check);
- VisitNearbyObject(GetTemplate()->MaxSearchRadius, searcher);
+ Cell::VisitAllObjects(this, searcher, GetTemplate()->MaxSearchRadius);
float halfExtentsX = extentsX / 2.0f;
float halfExtentsY = extentsY / 2.0f;
@@ -307,7 +307,7 @@ void AreaTrigger::SearchUnitInPolygon(std::list<Unit*>& targetList)
{
Trinity::AnyUnitInObjectRangeCheck check(this, GetTemplate()->MaxSearchRadius, false);
Trinity::UnitListSearcher<Trinity::AnyUnitInObjectRangeCheck> searcher(this, targetList, check);
- VisitNearbyObject(GetTemplate()->MaxSearchRadius, searcher);
+ Cell::VisitAllObjects(this, searcher, GetTemplate()->MaxSearchRadius);
float height = GetTemplate()->PolygonDatas.Height;
float minZ = GetPositionZ() - height;
@@ -325,7 +325,7 @@ void AreaTrigger::SearchUnitInCylinder(std::list<Unit*>& targetList)
{
Trinity::AnyUnitInObjectRangeCheck check(this, GetTemplate()->MaxSearchRadius, false);
Trinity::UnitListSearcher<Trinity::AnyUnitInObjectRangeCheck> searcher(this, targetList, check);
- VisitNearbyObject(GetTemplate()->MaxSearchRadius, searcher);
+ Cell::VisitAllObjects(this, searcher, GetTemplate()->MaxSearchRadius);
float height = GetTemplate()->CylinderDatas.Height;
float minZ = GetPositionZ() - height;
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp
index b701e0c1ac9..5a8275c2c7c 100644
--- a/src/server/game/Entities/Creature/Creature.cpp
+++ b/src/server/game/Entities/Creature/Creature.cpp
@@ -784,16 +784,9 @@ void Creature::DoFleeToGetAssistance()
if (radius >0)
{
Creature* creature = nullptr;
-
- CellCoord p(Trinity::ComputeCellCoord(GetPositionX(), GetPositionY()));
- Cell cell(p);
- cell.SetNoCreate();
Trinity::NearestAssistCreatureInCreatureRangeCheck u_check(this, GetVictim(), radius);
Trinity::CreatureLastSearcher<Trinity::NearestAssistCreatureInCreatureRangeCheck> searcher(this, creature, u_check);
-
- TypeContainerVisitor<Trinity::CreatureLastSearcher<Trinity::NearestAssistCreatureInCreatureRangeCheck>, GridTypeMapContainer > grid_creature_searcher(searcher);
-
- cell.Visit(p, grid_creature_searcher, *GetMap(), *this, radius);
+ Cell::VisitGridObjects(this, searcher, radius);
SetNoSearchAssistance(true);
UpdateSpeed(MOVE_RUN);
@@ -2018,55 +2011,29 @@ SpellInfo const* Creature::reachWithSpellCure(Unit* victim)
// select nearest hostile unit within the given distance (regardless of threat list).
Unit* Creature::SelectNearestTarget(float dist, bool playerOnly /* = false */) const
{
- CellCoord p(Trinity::ComputeCellCoord(GetPositionX(), GetPositionY()));
- Cell cell(p);
- cell.SetNoCreate();
+ if (dist == 0.0f)
+ dist = MAX_VISIBILITY_DISTANCE;
Unit* target = nullptr;
-
- {
- if (dist == 0.0f)
- dist = MAX_VISIBILITY_DISTANCE;
-
- Trinity::NearestHostileUnitCheck u_check(this, dist, playerOnly);
- Trinity::UnitLastSearcher<Trinity::NearestHostileUnitCheck> searcher(this, target, u_check);
-
- TypeContainerVisitor<Trinity::UnitLastSearcher<Trinity::NearestHostileUnitCheck>, WorldTypeMapContainer > world_unit_searcher(searcher);
- TypeContainerVisitor<Trinity::UnitLastSearcher<Trinity::NearestHostileUnitCheck>, GridTypeMapContainer > grid_unit_searcher(searcher);
-
- cell.Visit(p, world_unit_searcher, *GetMap(), *this, dist);
- cell.Visit(p, grid_unit_searcher, *GetMap(), *this, dist);
- }
-
+ Trinity::NearestHostileUnitCheck u_check(this, dist, playerOnly);
+ Trinity::UnitLastSearcher<Trinity::NearestHostileUnitCheck> searcher(this, target, u_check);
+ Cell::VisitAllObjects(this, searcher, dist);
return target;
}
// select nearest hostile unit within the given attack distance (i.e. distance is ignored if > than ATTACK_DISTANCE), regardless of threat list.
Unit* Creature::SelectNearestTargetInAttackDistance(float dist) const
{
- CellCoord p(Trinity::ComputeCellCoord(GetPositionX(), GetPositionY()));
- Cell cell(p);
- cell.SetNoCreate();
-
- Unit* target = nullptr;
-
if (dist > MAX_VISIBILITY_DISTANCE)
{
TC_LOG_ERROR("entities.unit", "Creature (%s) SelectNearestTargetInAttackDistance called with dist > MAX_VISIBILITY_DISTANCE. Distance set to ATTACK_DISTANCE.", GetGUID().ToString().c_str());
dist = ATTACK_DISTANCE;
}
- {
- Trinity::NearestHostileUnitInAttackDistanceCheck u_check(this, dist);
- Trinity::UnitLastSearcher<Trinity::NearestHostileUnitInAttackDistanceCheck> searcher(this, target, u_check);
-
- TypeContainerVisitor<Trinity::UnitLastSearcher<Trinity::NearestHostileUnitInAttackDistanceCheck>, WorldTypeMapContainer > world_unit_searcher(searcher);
- TypeContainerVisitor<Trinity::UnitLastSearcher<Trinity::NearestHostileUnitInAttackDistanceCheck>, GridTypeMapContainer > grid_unit_searcher(searcher);
-
- cell.Visit(p, world_unit_searcher, *GetMap(), *this, ATTACK_DISTANCE > dist ? ATTACK_DISTANCE : dist);
- cell.Visit(p, grid_unit_searcher, *GetMap(), *this, ATTACK_DISTANCE > dist ? ATTACK_DISTANCE : dist);
- }
-
+ Unit* target = nullptr;
+ Trinity::NearestHostileUnitInAttackDistanceCheck u_check(this, dist);
+ Trinity::UnitLastSearcher<Trinity::NearestHostileUnitInAttackDistanceCheck> searcher(this, target, u_check);
+ Cell::VisitAllObjects(this, searcher, std::max(dist, ATTACK_DISTANCE));
return target;
}
@@ -2076,7 +2043,7 @@ Player* Creature::SelectNearestPlayer(float distance) const
Trinity::NearestPlayerInObjectRangeCheck checker(this, distance);
Trinity::PlayerLastSearcher<Trinity::NearestPlayerInObjectRangeCheck> searcher(this, target, checker);
- VisitNearbyObject(distance, searcher);
+ Cell::VisitAllObjects(this, searcher, distance);
return target;
}
@@ -2104,19 +2071,9 @@ void Creature::CallAssistance()
if (radius > 0)
{
std::list<Creature*> assistList;
-
- {
- CellCoord p(Trinity::ComputeCellCoord(GetPositionX(), GetPositionY()));
- Cell cell(p);
- cell.SetNoCreate();
-
- Trinity::AnyAssistCreatureInRangeCheck u_check(this, GetVictim(), radius);
- Trinity::CreatureListSearcher<Trinity::AnyAssistCreatureInRangeCheck> searcher(this, assistList, u_check);
-
- TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::AnyAssistCreatureInRangeCheck>, GridTypeMapContainer > grid_creature_searcher(searcher);
-
- cell.Visit(p, grid_creature_searcher, *GetMap(), *this, radius);
- }
+ Trinity::AnyAssistCreatureInRangeCheck u_check(this, GetVictim(), radius);
+ Trinity::CreatureListSearcher<Trinity::AnyAssistCreatureInRangeCheck> searcher(this, assistList, u_check);
+ Cell::VisitGridObjects(this, searcher, radius);
if (!assistList.empty())
{
@@ -2138,16 +2095,9 @@ void Creature::CallForHelp(float radius)
if (radius <= 0.0f || !GetVictim() || IsPet() || IsCharmed())
return;
- CellCoord p(Trinity::ComputeCellCoord(GetPositionX(), GetPositionY()));
- Cell cell(p);
- cell.SetNoCreate();
-
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, radius);
+ Cell::VisitGridObjects(this, worker, radius);
}
bool Creature::CanAssistTo(const Unit* u, const Unit* enemy, bool checkfaction /*= true*/) const
@@ -2692,12 +2642,10 @@ Unit* Creature::SelectNearestHostileUnitInAggroRange(bool useLOS) const
Unit* target = NULL;
- {
- Trinity::NearestHostileUnitInAggroRangeCheck u_check(this, useLOS);
- Trinity::UnitSearcher<Trinity::NearestHostileUnitInAggroRangeCheck> searcher(this, target, u_check);
+ Trinity::NearestHostileUnitInAggroRangeCheck u_check(this, useLOS);
+ Trinity::UnitSearcher<Trinity::NearestHostileUnitInAggroRangeCheck> searcher(this, target, u_check);
- VisitNearbyGridObject(MAX_AGGRO_RADIUS, searcher);
- }
+ Cell::VisitGridObjects(this, searcher, MAX_AGGRO_RADIUS);
return target;
}
diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp
index ffbb13b42e1..cf9209699a9 100644
--- a/src/server/game/Entities/GameObject/GameObject.cpp
+++ b/src/server/game/Entities/GameObject/GameObject.cpp
@@ -560,9 +560,9 @@ void GameObject::Update(uint32 diff)
// Hunter trap: Search units which are unfriendly to the trap's owner
Trinity::AnyUnfriendlyNoTotemUnitInObjectRangeCheck checker(this, owner, radius);
Trinity::UnitSearcher<Trinity::AnyUnfriendlyNoTotemUnitInObjectRangeCheck> searcher(this, target, checker);
- VisitNearbyGridObject(radius, searcher);
+ Cell::VisitGridObjects(this, searcher, radius);
if (!target)
- VisitNearbyWorldObject(radius, searcher);
+ Cell::VisitWorldObjects(this, searcher, radius);
}
else
{
@@ -570,7 +570,7 @@ void GameObject::Update(uint32 diff)
Player* player = nullptr;
Trinity::AnyPlayerInObjectRangeCheck checker(this, radius);
Trinity::PlayerSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(this, player, checker);
- VisitNearbyWorldObject(radius, searcher);
+ Cell::VisitWorldObjects(this, searcher, radius);
target = player;
}
@@ -1162,17 +1162,10 @@ void GameObject::TriggeringLinkedGameObject(uint32 trapEntry, Unit* target)
// search nearest linked GO
GameObject* trapGO = nullptr;
- {
- // using original GO distance
- CellCoord p(Trinity::ComputeCellCoord(GetPositionX(), GetPositionY()));
- Cell cell(p);
-
- Trinity::NearestGameObjectEntryInObjectRangeCheck go_check(*target, trapEntry, range);
- Trinity::GameObjectLastSearcher<Trinity::NearestGameObjectEntryInObjectRangeCheck> checker(this, trapGO, go_check);
-
- TypeContainerVisitor<Trinity::GameObjectLastSearcher<Trinity::NearestGameObjectEntryInObjectRangeCheck>, GridTypeMapContainer > object_checker(checker);
- cell.Visit(p, object_checker, *GetMap(), *target, range);
- }
+ // using original GO distance
+ Trinity::NearestGameObjectEntryInObjectRangeCheck go_check(*target, trapEntry, range);
+ Trinity::GameObjectLastSearcher<Trinity::NearestGameObjectEntryInObjectRangeCheck> checker(this, trapGO, go_check);
+ Cell::VisitGridObjects(this, checker, range);
// found correct GO
if (trapGO)
@@ -1182,15 +1175,9 @@ void GameObject::TriggeringLinkedGameObject(uint32 trapEntry, Unit* target)
GameObject* GameObject::LookupFishingHoleAround(float range)
{
GameObject* ok = nullptr;
-
- CellCoord p(Trinity::ComputeCellCoord(GetPositionX(), GetPositionY()));
- Cell cell(p);
Trinity::NearestGameObjectFishingHole u_check(*this, range);
Trinity::GameObjectSearcher<Trinity::NearestGameObjectFishingHole> checker(this, ok, u_check);
-
- TypeContainerVisitor<Trinity::GameObjectSearcher<Trinity::NearestGameObjectFishingHole>, GridTypeMapContainer > grid_object_checker(checker);
- cell.Visit(p, grid_object_checker, *GetMap(), *this, range);
-
+ Cell::VisitGridObjects(this, checker, range);
return ok;
}
diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp
index 64cd60282cb..b1dc8e894bf 100644
--- a/src/server/game/Entities/Object/Object.cpp
+++ b/src/server/game/Entities/Object/Object.cpp
@@ -2267,13 +2267,13 @@ void WorldObject::SendMessageToSet(WorldPacket const* data, bool self)
void WorldObject::SendMessageToSetInRange(WorldPacket const* data, float dist, bool /*self*/)
{
Trinity::MessageDistDeliverer notifier(this, data, dist);
- VisitNearbyWorldObject(dist, notifier);
+ Cell::VisitWorldObjects(this, notifier, dist);
}
void WorldObject::SendMessageToSet(WorldPacket const* data, Player const* skipped_rcvr)
{
Trinity::MessageDistDeliverer notifier(this, data, GetVisibilityRange(), false, skipped_rcvr);
- VisitNearbyWorldObject(GetVisibilityRange(), notifier);
+ Cell::VisitWorldObjects(this, notifier, GetVisibilityRange());
}
void WorldObject::SetMap(Map* map)
@@ -2415,7 +2415,7 @@ TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropert
// call MoveInLineOfSight for nearby creatures
Trinity::AIRelocationNotifier notifier(*summon);
- summon->VisitNearbyObject(GetVisibilityRange(), notifier);
+ Cell::VisitAllObjects(summon, notifier, GetVisibilityRange());
return summon;
}
@@ -2582,7 +2582,7 @@ Creature* WorldObject::FindNearestCreature(uint32 entry, float range, bool alive
Creature* creature = NULL;
Trinity::NearestCreatureEntryWithLiveStateInObjectRangeCheck checker(*this, entry, alive, range);
Trinity::CreatureLastSearcher<Trinity::NearestCreatureEntryWithLiveStateInObjectRangeCheck> searcher(this, creature, checker);
- VisitNearbyObject(range, searcher);
+ Cell::VisitAllObjects(this, searcher, range);
return creature;
}
@@ -2591,7 +2591,7 @@ GameObject* WorldObject::FindNearestGameObject(uint32 entry, float range) const
GameObject* go = NULL;
Trinity::NearestGameObjectEntryInObjectRangeCheck checker(*this, entry, range);
Trinity::GameObjectLastSearcher<Trinity::NearestGameObjectEntryInObjectRangeCheck> searcher(this, go, checker);
- VisitNearbyGridObject(range, searcher);
+ Cell::VisitGridObjects(this, searcher, range);
return go;
}
@@ -2600,41 +2600,29 @@ GameObject* WorldObject::FindNearestGameObjectOfType(GameobjectTypes type, float
GameObject* go = NULL;
Trinity::NearestGameObjectTypeInObjectRangeCheck checker(*this, type, range);
Trinity::GameObjectLastSearcher<Trinity::NearestGameObjectTypeInObjectRangeCheck> searcher(this, go, checker);
- VisitNearbyGridObject(range, searcher);
+ Cell::VisitGridObjects(this, searcher, range);
return go;
}
void WorldObject::GetGameObjectListWithEntryInGrid(std::list<GameObject*>& gameobjectList, uint32 entry, float maxSearchRange) const
{
- CellCoord pair(Trinity::ComputeCellCoord(this->GetPositionX(), this->GetPositionY()));
- Cell cell(pair);
- cell.SetNoCreate();
-
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()), *this, maxSearchRange);
+ Cell::VisitGridObjects(this, searcher, maxSearchRange);
}
void WorldObject::GetCreatureListWithEntryInGrid(std::list<Creature*>& creatureList, uint32 entry, float maxSearchRange) const
{
- CellCoord pair(Trinity::ComputeCellCoord(this->GetPositionX(), this->GetPositionY()));
- Cell cell(pair);
- cell.SetNoCreate();
-
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()), *this, maxSearchRange);
+ Cell::VisitGridObjects(this, searcher, maxSearchRange);
}
void WorldObject::GetPlayerListInGrid(std::list<Player*>& playerList, float maxSearchRange) const
{
Trinity::AnyPlayerInObjectRangeCheck checker(this, maxSearchRange);
Trinity::PlayerListSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(this, playerList, checker);
- this->VisitNearbyWorldObject(maxSearchRange, searcher);
+ Cell::VisitWorldObjects(this, searcher, maxSearchRange);
}
/*
@@ -3118,7 +3106,7 @@ void WorldObject::DestroyForNearbyPlayers()
std::list<Player*> targets;
Trinity::AnyPlayerInObjectRangeCheck check(this, GetVisibilityRange(), false);
Trinity::PlayerListSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(this, targets, check);
- VisitNearbyWorldObject(GetVisibilityRange(), searcher);
+ Cell::VisitWorldObjects(this, searcher, GetVisibilityRange());
for (std::list<Player*>::const_iterator iter = targets.begin(); iter != targets.end(); ++iter)
{
Player* player = (*iter);
@@ -3141,7 +3129,7 @@ void WorldObject::UpdateObjectVisibility(bool /*forced*/)
{
//updates object's visibility for nearby players
Trinity::VisibleChangesNotifier notifier(*this);
- VisitNearbyWorldObject(GetVisibilityRange(), notifier);
+ Cell::VisitWorldObjects(this, notifier, GetVisibilityRange());
}
struct WorldObjectChangeAccumulator
@@ -3216,14 +3204,9 @@ struct WorldObjectChangeAccumulator
void WorldObject::BuildUpdate(UpdateDataMapType& data_map)
{
- CellCoord p = Trinity::ComputeCellCoord(GetPositionX(), GetPositionY());
- Cell cell(p);
- cell.SetNoCreate();
WorldObjectChangeAccumulator notifier(*this, data_map);
- TypeContainerVisitor<WorldObjectChangeAccumulator, WorldTypeMapContainer > player_notifier(notifier);
- Map& map = *GetMap();
//we must build packets for all visible players
- cell.Visit(p, player_notifier, map, *this, GetVisibilityRange());
+ Cell::VisitWorldObjects(this, notifier, GetVisibilityRange());
ClearUpdateMask(false);
}
diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h
index f1e0841f3ed..f3b4041db3c 100644
--- a/src/server/game/Entities/Object/Object.h
+++ b/src/server/game/Entities/Object/Object.h
@@ -700,10 +700,6 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation
bool IsPermanentWorldObject() const { return m_isWorldObject; }
bool IsWorldObject() const;
- template<class NOTIFIER> void VisitNearbyObject(float radius, NOTIFIER& notifier) const { if (IsInWorld()) GetMap()->VisitAll(GetPositionX(), GetPositionY(), radius, notifier); }
- template<class NOTIFIER> void VisitNearbyGridObject(float radius, NOTIFIER& notifier) const { if (IsInWorld()) GetMap()->VisitGrid(GetPositionX(), GetPositionY(), radius, notifier); }
- template<class NOTIFIER> void VisitNearbyWorldObject(float radius, NOTIFIER& notifier) const { if (IsInWorld()) GetMap()->VisitWorld(GetPositionX(), GetPositionY(), radius, notifier); }
-
uint32 LastUsedScriptID;
// Transports
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index a11b84e1dec..41af8b74013 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -5934,7 +5934,7 @@ void Player::SendMessageToSetInRange(WorldPacket const* data, float dist, bool s
GetSession()->SendPacket(data);
Trinity::MessageDistDeliverer notifier(this, data, dist);
- VisitNearbyWorldObject(dist, notifier);
+ Cell::VisitWorldObjects(this, notifier, dist);
}
void Player::SendMessageToSetInRange(WorldPacket const* data, float dist, bool self, bool own_team_only)
@@ -5943,7 +5943,7 @@ void Player::SendMessageToSetInRange(WorldPacket const* data, float dist, bool s
GetSession()->SendPacket(data);
Trinity::MessageDistDeliverer notifier(this, data, dist, own_team_only);
- VisitNearbyWorldObject(dist, notifier);
+ Cell::VisitWorldObjects(this, notifier, dist);
}
void Player::SendMessageToSet(WorldPacket const* data, Player const* skipped_rcvr)
@@ -5954,7 +5954,7 @@ void Player::SendMessageToSet(WorldPacket const* data, Player const* skipped_rcv
// we use World::GetMaxVisibleDistance() because i cannot see why not use a distance
// update: replaced by GetMap()->GetVisibilityDistance()
Trinity::MessageDistDeliverer notifier(this, data, GetVisibilityRange(), false, skipped_rcvr);
- VisitNearbyWorldObject(GetVisibilityRange(), notifier);
+ Cell::VisitWorldObjects(this, notifier, GetVisibilityRange());
}
void Player::SendDirectMessage(WorldPacket const* data) const
@@ -23215,7 +23215,7 @@ void Player::UpdateVisibilityForPlayer()
{
// updates visibility of all objects around point of view for current player
Trinity::VisibleNotifier notifier(*this);
- m_seer->VisitNearbyObject(GetSightRange(), notifier);
+ Cell::VisitAllObjects(m_seer, notifier, GetSightRange());
notifier.SendToSelf(); // send gathered data
}
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 2ef380df948..39c33b09c01 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -11011,7 +11011,7 @@ Unit* Unit::SelectNearbyTarget(Unit* exclude, float dist) const
std::list<Unit*> targets;
Trinity::AnyUnfriendlyUnitInObjectRangeCheck u_check(this, this, dist);
Trinity::UnitListSearcher<Trinity::AnyUnfriendlyUnitInObjectRangeCheck> searcher(this, targets, u_check);
- VisitNearbyObject(dist, searcher);
+ Cell::VisitAllObjects(this, searcher, dist);
// remove current target
if (GetVictim())
@@ -12877,7 +12877,7 @@ void Unit::UpdateObjectVisibility(bool forced)
WorldObject::UpdateObjectVisibility(true);
// call MoveInLineOfSight for nearby creatures
Trinity::AIRelocationNotifier notifier(*this);
- VisitNearbyObject(GetVisibilityRange(), notifier);
+ Cell::VisitAllObjects(this, notifier, GetVisibilityRange());
}
}
@@ -14798,7 +14798,7 @@ void Unit::Talk(std::string const& text, ChatMsg msgType, Language language, flo
Trinity::CustomChatTextBuilder builder(this, msgType, text, language, target);
Trinity::LocalizedPacketDo<Trinity::CustomChatTextBuilder> localizer(builder);
Trinity::PlayerDistWorker<Trinity::LocalizedPacketDo<Trinity::CustomChatTextBuilder> > worker(this, textRange, localizer);
- VisitNearbyWorldObject(textRange, worker);
+ Cell::VisitWorldObjects(this, worker, textRange);
}
void Unit::Say(std::string const& text, Language language, WorldObject const* target /*= nullptr*/)
@@ -14864,7 +14864,7 @@ void Unit::Talk(uint32 textId, ChatMsg msgType, float textRange, WorldObject con
Trinity::BroadcastTextBuilder builder(this, msgType, textId, target);
Trinity::LocalizedPacketDo<Trinity::BroadcastTextBuilder> localizer(builder);
Trinity::PlayerDistWorker<Trinity::LocalizedPacketDo<Trinity::BroadcastTextBuilder> > worker(this, textRange, localizer);
- VisitNearbyWorldObject(textRange, worker);
+ Cell::VisitWorldObjects(this, worker, textRange);
}
void Unit::Say(uint32 textId, WorldObject const* target /*= nullptr*/)
@@ -15034,7 +15034,7 @@ void CombatLogSender::Visit(DynamicObjectMapType& m)
void Unit::SendCombatLogMessage(WorldPackets::CombatLog::CombatLogServerPacket* combatLog) const
{
CombatLogSender notifier(this, combatLog, GetVisibilityRange());
- VisitNearbyWorldObject(GetVisibilityRange(), notifier);
+ Cell::VisitWorldObjects(this, notifier, GetVisibilityRange());
}
bool Unit::VisibleAuraSlotCompare::operator()(AuraApplication* left, AuraApplication* right) const
diff --git a/src/server/game/Grids/Cells/Cell.h b/src/server/game/Grids/Cells/Cell.h
index 27d454a8ed5..9d28ac86bd6 100644
--- a/src/server/game/Grids/Cells/Cell.h
+++ b/src/server/game/Grids/Cells/Cell.h
@@ -107,11 +107,19 @@ struct Cell
uint32 All;
} data;
- 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;
+ template<class T, class CONTAINER> void Visit(CellCoord const&, TypeContainerVisitor<T, CONTAINER>& visitor, Map&, WorldObject const& obj, float radius) const;
+ template<class T, class CONTAINER> void Visit(CellCoord const&, TypeContainerVisitor<T, CONTAINER>& visitor, Map&, float x, float y, float radius) const;
static CellArea CalculateCellArea(float x, float y, float radius);
+ template<class T> static void VisitGridObjects(WorldObject const* obj, T& visitor, float radius, bool dont_load = true);
+ template<class T> static void VisitWorldObjects(WorldObject const* obj, T& visitor, float radius, bool dont_load = true);
+ template<class T> static void VisitAllObjects(WorldObject const* obj, T& visitor, float radius, bool dont_load = true);
+
+ template<class T> static void VisitGridObjects(float x, float y, Map* map, T& visitor, float radius, bool dont_load = true);
+ template<class T> static void VisitWorldObjects(float x, float y, Map* map, T& visitor, float radius, bool dont_load = true);
+ template<class T> static void VisitAllObjects(float x, float y, Map* map, T& visitor, float radius, bool dont_load = true);
+
private:
template<class T, class CONTAINER> void VisitCircle(TypeContainerVisitor<T, CONTAINER> &, Map &, CellCoord const&, CellCoord const&) const;
};
diff --git a/src/server/game/Grids/Cells/CellImpl.h b/src/server/game/Grids/Cells/CellImpl.h
index 67fc6ead99a..8b6d5d30004 100644
--- a/src/server/game/Grids/Cells/CellImpl.h
+++ b/src/server/game/Grids/Cells/CellImpl.h
@@ -61,7 +61,15 @@ inline CellArea Cell::CalculateCellArea(float x, float y, float radius)
}
template<class T, class CONTAINER>
-inline void Cell::Visit(CellCoord const& standing_cell, TypeContainerVisitor<T, CONTAINER>& visitor, Map& map, float radius, float x_off, float y_off) 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(standing_cell, visitor, map, obj.GetPositionX(), obj.GetPositionY(), radius + obj.GetObjectSize());
+}
+
+template<class T, class CONTAINER>
+inline void Cell::Visit(CellCoord const& standing_cell, TypeContainerVisitor<T, CONTAINER>& visitor, Map& map, float x_off, float y_off, float radius) const
{
if (!standing_cell.IsCoordValid())
return;
@@ -119,14 +127,6 @@ inline void Cell::Visit(CellCoord const& standing_cell, TypeContainerVisitor<T,
}
template<class T, class CONTAINER>
-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(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& map, CellCoord const& begin_cell, CellCoord const& end_cell) const
{
//here is an algorithm for 'filling' circum-squared octagon
@@ -177,4 +177,81 @@ inline void Cell::VisitCircle(TypeContainerVisitor<T, CONTAINER>& visitor, Map&
}
}
}
+
+template<class T>
+inline void Cell::VisitGridObjects(WorldObject const* center_obj, T& visitor, float radius, bool dont_load)
+{
+ CellCoord p(Trinity::ComputeCellCoord(center_obj->GetPositionX(), center_obj->GetPositionY()));
+ Cell cell(p);
+ if (dont_load)
+ cell.SetNoCreate();
+
+ TypeContainerVisitor<T, GridTypeMapContainer> gnotifier(visitor);
+ cell.Visit(p, gnotifier, *center_obj->GetMap(), *center_obj, radius);
+}
+
+template<class T>
+inline void Cell::VisitWorldObjects(WorldObject const* center_obj, T& visitor, float radius, bool dont_load)
+{
+ CellCoord p(Trinity::ComputeCellCoord(center_obj->GetPositionX(), center_obj->GetPositionY()));
+ Cell cell(p);
+ if (dont_load)
+ cell.SetNoCreate();
+
+ TypeContainerVisitor<T, WorldTypeMapContainer> gnotifier(visitor);
+ cell.Visit(p, gnotifier, *center_obj->GetMap(), *center_obj, radius);
+}
+
+template<class T>
+inline void Cell::VisitAllObjects(WorldObject const* center_obj, T& visitor, float radius, bool dont_load)
+{
+ CellCoord p(Trinity::ComputeCellCoord(center_obj->GetPositionX(), center_obj->GetPositionY()));
+ Cell cell(p);
+ if (dont_load)
+ cell.SetNoCreate();
+
+ TypeContainerVisitor<T, WorldTypeMapContainer> wnotifier(visitor);
+ cell.Visit(p, wnotifier, *center_obj->GetMap(), *center_obj, radius);
+ TypeContainerVisitor<T, GridTypeMapContainer> gnotifier(visitor);
+ cell.Visit(p, gnotifier, *center_obj->GetMap(), *center_obj, radius);
+}
+
+template<class T>
+inline void Cell::VisitGridObjects(float x, float y, Map* map, T& visitor, float radius, bool dont_load)
+{
+ CellCoord p(Trinity::ComputeCellCoord(x, y));
+ Cell cell(p);
+ if (dont_load)
+ cell.SetNoCreate();
+
+ TypeContainerVisitor<T, GridTypeMapContainer> gnotifier(visitor);
+ cell.Visit(p, gnotifier, *map, x, y, radius);
+}
+
+template<class T>
+inline void Cell::VisitWorldObjects(float x, float y, Map* map, T& visitor, float radius, bool dont_load)
+{
+ CellCoord p(Trinity::ComputeCellCoord(x, y));
+ Cell cell(p);
+ if (dont_load)
+ cell.SetNoCreate();
+
+ TypeContainerVisitor<T, WorldTypeMapContainer> gnotifier(visitor);
+ cell.Visit(p, gnotifier, *map, x, y, radius);
+}
+
+template<class T>
+inline void Cell::VisitAllObjects(float x, float y, Map* map, T& visitor, float radius, bool dont_load)
+{
+ CellCoord p(Trinity::ComputeCellCoord(x, y));
+ Cell cell(p);
+ if (dont_load)
+ cell.SetNoCreate();
+
+ TypeContainerVisitor<T, WorldTypeMapContainer> wnotifier(visitor);
+ cell.Visit(p, wnotifier, *map, x, y, radius);
+ TypeContainerVisitor<T, GridTypeMapContainer> gnotifier(visitor);
+ cell.Visit(p, gnotifier, *map, x, y, radius);
+}
+
#endif
diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.cpp b/src/server/game/Grids/Notifiers/GridNotifiers.cpp
index 4f3f04b391e..ebf94bbbc5c 100644
--- a/src/server/game/Grids/Notifiers/GridNotifiers.cpp
+++ b/src/server/game/Grids/Notifiers/GridNotifiers.cpp
@@ -234,17 +234,8 @@ void DelayedUnitRelocation::Visit(PlayerMapType &m)
if (player != viewPoint && !viewPoint->IsPositionValid())
continue;
- CellCoord pair2(Trinity::ComputeCellCoord(viewPoint->GetPositionX(), viewPoint->GetPositionY()));
- Cell cell2(pair2);
- //cell.SetNoCreate(); need load cells around viewPoint or player, that's why its commented
-
PlayerRelocationNotifier relocate(*player);
- TypeContainerVisitor<PlayerRelocationNotifier, WorldTypeMapContainer > c2world_relocation(relocate);
- TypeContainerVisitor<PlayerRelocationNotifier, GridTypeMapContainer > c2grid_relocation(relocate);
-
- cell2.Visit(pair2, c2world_relocation, i_map, *viewPoint, i_radius);
- cell2.Visit(pair2, c2grid_relocation, i_map, *viewPoint, i_radius);
-
+ Cell::VisitAllObjects(viewPoint, relocate, i_radius, false);
relocate.SendToSelf();
}
}
diff --git a/src/server/game/Handlers/LootHandler.cpp b/src/server/game/Handlers/LootHandler.cpp
index 3896144bfef..b674180f9b7 100644
--- a/src/server/game/Handlers/LootHandler.cpp
+++ b/src/server/game/Handlers/LootHandler.cpp
@@ -272,7 +272,7 @@ void WorldSession::HandleLootOpcode(WorldPackets::Loot::LootUnit& packet)
std::list<Creature*> corpses;
AELootCreatureCheck check(_player, packet.Unit);
Trinity::CreatureListSearcher<AELootCreatureCheck> searcher(_player, corpses, check);
- _player->VisitNearbyGridObject(AELootCreatureCheck::LootDistance, searcher);
+ Cell::VisitGridObjects(_player, searcher, AELootCreatureCheck::LootDistance);
if (!corpses.empty())
SendPacket(WorldPackets::Loot::AELootTargets(uint32(corpses.size() + 1)).Write());
diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp
index 10fcd8288fc..ac2330e6f1e 100644
--- a/src/server/game/Maps/Map.cpp
+++ b/src/server/game/Maps/Map.cpp
@@ -2829,28 +2829,6 @@ char const* Map::GetMapName() const
return i_mapEntry ? i_mapEntry->MapName->Str[sWorld->GetDefaultDbcLocale()] : "UNNAMEDMAP\x0";
}
-void Map::UpdateObjectVisibility(WorldObject* obj, Cell cell, CellCoord cellpair)
-{
- cell.SetNoCreate();
- Trinity::VisibleChangesNotifier notifier(*obj);
- TypeContainerVisitor<Trinity::VisibleChangesNotifier, WorldTypeMapContainer > player_notifier(notifier);
- cell.Visit(cellpair, player_notifier, *this, *obj, obj->GetVisibilityRange());
-}
-
-void Map::UpdateObjectsVisibilityFor(Player* player, Cell cell, CellCoord cellpair)
-{
- Trinity::VisibleNotifier notifier(*player);
-
- cell.SetNoCreate();
- TypeContainerVisitor<Trinity::VisibleNotifier, WorldTypeMapContainer > world_notifier(notifier);
- TypeContainerVisitor<Trinity::VisibleNotifier, GridTypeMapContainer > grid_notifier(notifier);
- cell.Visit(cellpair, world_notifier, *this, *player->m_seer, player->GetSightRange());
- cell.Visit(cellpair, grid_notifier, *this, *player->m_seer, player->GetSightRange());
-
- // send data
- notifier.SendToSelf();
-}
-
void Map::SendInitSelf(Player* player)
{
TC_LOG_DEBUG("maps", "Creating player data for himself %s", player->GetGUID().ToString().c_str());
diff --git a/src/server/game/Maps/Map.h b/src/server/game/Maps/Map.h
index 0854090bc3f..263d65788e8 100644
--- a/src/server/game/Maps/Map.h
+++ b/src/server/game/Maps/Map.h
@@ -416,9 +416,6 @@ class TC_GAME_API Map : public GridRefManager<NGridType>
void AddObjectToSwitchList(WorldObject* obj, bool on);
virtual void DelayedUpdate(const uint32 diff);
- void UpdateObjectVisibility(WorldObject* obj, Cell cell, CellCoord cellpair);
- void UpdateObjectsVisibilityFor(Player* player, Cell cell, CellCoord cellpair);
-
void resetMarkedCells() { marked_cells.reset(); }
bool isCellMarked(uint32 pCellId) { return marked_cells.test(pCellId); }
void markCell(uint32 pCellId) { marked_cells.set(pCellId); }
@@ -448,10 +445,6 @@ class TC_GAME_API Map : public GridRefManager<NGridType>
void RemoveFromActive(T* obj);
template<class T> void SwitchGridContainers(T* obj, bool on);
- template<class NOTIFIER> void VisitAll(const float &x, const float &y, float radius, NOTIFIER &notifier);
- template<class NOTIFIER> void VisitFirstFound(const float &x, const float &y, float radius, NOTIFIER &notifier);
- template<class NOTIFIER> void VisitWorld(const float &x, const float &y, float radius, NOTIFIER &notifier);
- template<class NOTIFIER> void VisitGrid(const float &x, const float &y, float radius, NOTIFIER &notifier);
CreatureGroupHolderType CreatureGroupHolder;
void UpdateIteratorBack(Player* player);
@@ -835,56 +828,4 @@ inline void Map::Visit(Cell const& cell, TypeContainerVisitor<T, CONTAINER>& vis
getNGrid(x, y)->VisitGrid(cell_x, cell_y, visitor);
}
}
-
-template<class 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.SetNoCreate();
-
- TypeContainerVisitor<NOTIFIER, WorldTypeMapContainer> world_object_notifier(notifier);
- cell.Visit(p, world_object_notifier, *this, radius, x, y);
- TypeContainerVisitor<NOTIFIER, GridTypeMapContainer > grid_object_notifier(notifier);
- cell.Visit(p, grid_object_notifier, *this, radius, x, y);
-}
-
-// 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)
-{
- CellCoord p(Trinity::ComputeCellCoord(x, y));
- Cell cell(p);
- cell.SetNoCreate();
-
- TypeContainerVisitor<NOTIFIER, WorldTypeMapContainer> world_object_notifier(notifier);
- cell.Visit(p, world_object_notifier, *this, radius, x, y);
- if (!notifier.i_object)
- {
- TypeContainerVisitor<NOTIFIER, GridTypeMapContainer > grid_object_notifier(notifier);
- cell.Visit(p, grid_object_notifier, *this, radius, x, y);
- }
-}
-
-template<class 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.SetNoCreate();
-
- TypeContainerVisitor<NOTIFIER, WorldTypeMapContainer> world_object_notifier(notifier);
- cell.Visit(p, world_object_notifier, *this, radius, x, y);
-}
-
-template<class 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.SetNoCreate();
-
- TypeContainerVisitor<NOTIFIER, GridTypeMapContainer > grid_object_notifier(notifier);
- cell.Visit(p, grid_object_notifier, *this, radius, x, y);
-}
#endif
diff --git a/src/server/game/OutdoorPvP/OutdoorPvP.cpp b/src/server/game/OutdoorPvP/OutdoorPvP.cpp
index d245b6ff976..53c468b5df4 100644
--- a/src/server/game/OutdoorPvP/OutdoorPvP.cpp
+++ b/src/server/game/OutdoorPvP/OutdoorPvP.cpp
@@ -307,7 +307,7 @@ bool OPvPCapturePoint::Update(uint32 diff)
std::list<Player*> players;
Trinity::AnyPlayerInObjectRangeCheck checker(m_capturePoint, radius);
Trinity::PlayerListSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(m_capturePoint, players, checker);
- m_capturePoint->VisitNearbyWorldObject(radius, searcher);
+ Cell::VisitWorldObjects(m_capturePoint, searcher, radius);
for (std::list<Player*>::iterator itr = players.begin(); itr != players.end(); ++itr)
{
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
index 95935ec8fe2..9cd5f380c31 100644
--- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp
+++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
@@ -2054,7 +2054,7 @@ void AuraEffect::HandleFeignDeath(AuraApplication const* aurApp, uint8 mode, boo
UnitList targets;
Trinity::AnyUnfriendlyUnitInObjectRangeCheck u_check(target, target, target->GetMap()->GetVisibilityRange());
Trinity::UnitListSearcher<Trinity::AnyUnfriendlyUnitInObjectRangeCheck> searcher(target, targets, u_check);
- target->VisitNearbyObject(target->GetMap()->GetVisibilityRange(), searcher);
+ Cell::VisitAllObjects(target, searcher, target->GetMap()->GetVisibilityRange());
for (UnitList::iterator iter = targets.begin(); iter != targets.end(); ++iter)
{
if (!(*iter)->HasUnitState(UNIT_STATE_CASTING))
diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp
index 7eeb4188975..8371220280c 100644
--- a/src/server/game/Spells/Auras/SpellAuras.cpp
+++ b/src/server/game/Spells/Auras/SpellAuras.cpp
@@ -2252,7 +2252,7 @@ void UnitAura::FillTargetMap(std::map<Unit*, uint32> & targets, Unit* caster)
targetList.push_back(GetUnitOwner());
Trinity::AnyGroupedUnitInObjectRangeCheck u_check(GetUnitOwner(), GetUnitOwner(), radius, effect->Effect == SPELL_EFFECT_APPLY_AREA_AURA_RAID);
Trinity::UnitListSearcher<Trinity::AnyGroupedUnitInObjectRangeCheck> searcher(GetUnitOwner(), targetList, u_check);
- GetUnitOwner()->VisitNearbyObject(radius, searcher);
+ Cell::VisitAllObjects(GetUnitOwner(), searcher, radius);
break;
}
case SPELL_EFFECT_APPLY_AREA_AURA_FRIEND:
@@ -2260,14 +2260,14 @@ void UnitAura::FillTargetMap(std::map<Unit*, uint32> & targets, Unit* caster)
targetList.push_back(GetUnitOwner());
Trinity::AnyFriendlyUnitInObjectRangeCheck u_check(GetUnitOwner(), GetUnitOwner(), radius);
Trinity::UnitListSearcher<Trinity::AnyFriendlyUnitInObjectRangeCheck> searcher(GetUnitOwner(), targetList, u_check);
- GetUnitOwner()->VisitNearbyObject(radius, searcher);
+ Cell::VisitAllObjects(GetUnitOwner(), searcher, radius);
break;
}
case SPELL_EFFECT_APPLY_AREA_AURA_ENEMY:
{
Trinity::AnyAoETargetUnitInObjectRangeCheck u_check(GetUnitOwner(), GetUnitOwner(), radius); // No GetCharmer in searcher
Trinity::UnitListSearcher<Trinity::AnyAoETargetUnitInObjectRangeCheck> searcher(GetUnitOwner(), targetList, u_check);
- GetUnitOwner()->VisitNearbyObject(radius, searcher);
+ Cell::VisitAllObjects(GetUnitOwner(), searcher, radius);
break;
}
case SPELL_EFFECT_APPLY_AREA_AURA_PET:
@@ -2335,13 +2335,13 @@ void DynObjAura::FillTargetMap(std::map<Unit*, uint32> & targets, Unit* /*caster
{
Trinity::AnyFriendlyUnitInObjectRangeCheck u_check(GetDynobjOwner(), dynObjOwnerCaster, radius);
Trinity::UnitListSearcher<Trinity::AnyFriendlyUnitInObjectRangeCheck> searcher(GetDynobjOwner(), targetList, u_check);
- GetDynobjOwner()->VisitNearbyObject(radius, searcher);
+ Cell::VisitAllObjects(GetDynobjOwner(), searcher, radius);
}
else
{
Trinity::AnyAoETargetUnitInObjectRangeCheck u_check(GetDynobjOwner(), dynObjOwnerCaster, radius);
Trinity::UnitListSearcher<Trinity::AnyAoETargetUnitInObjectRangeCheck> searcher(GetDynobjOwner(), targetList, u_check);
- GetDynobjOwner()->VisitNearbyObject(radius, searcher);
+ Cell::VisitAllObjects(GetDynobjOwner(), searcher, radius);
}
for (UnitList::iterator itr = targetList.begin(); itr!= targetList.end();++itr)
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index d512a92466e..2a677dc50d1 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -1839,18 +1839,13 @@ void Spell::SearchTargets(SEARCHER& searcher, uint32 containerMask, Unit* refere
Cell cell(p);
cell.SetNoCreate();
- Map& map = *(referer->GetMap());
+ Map* map = referer->GetMap();
if (searchInWorld)
- {
- TypeContainerVisitor<SEARCHER, WorldTypeMapContainer> world_object_notifier(searcher);
- cell.Visit(p, world_object_notifier, map, radius, x, y);
- }
+ Cell::VisitWorldObjects(x, y, map, searcher, radius);
+
if (searchInGrid)
- {
- TypeContainerVisitor<SEARCHER, GridTypeMapContainer > grid_object_notifier(searcher);
- cell.Visit(p, grid_object_notifier, map, radius, x, y);
- }
+ Cell::VisitGridObjects(x, y, map, searcher, radius);
}
}
diff --git a/src/server/game/Texts/CreatureTextMgr.h b/src/server/game/Texts/CreatureTextMgr.h
index 943101c852e..7b4854de0ad 100644
--- a/src/server/game/Texts/CreatureTextMgr.h
+++ b/src/server/game/Texts/CreatureTextMgr.h
@@ -244,8 +244,8 @@ void CreatureTextMgr::SendChatPacket(WorldObject* source, Builder const& builder
}
float dist = GetRangeForChatType(msgType);
- Trinity::PlayerDistWorker<CreatureTextLocalizer<Builder> > worker(source, dist, localizer);
- source->VisitNearbyWorldObject(dist, worker);
+ Trinity::PlayerDistWorker<CreatureTextLocalizer<Builder>> worker(source, dist, localizer);
+ Cell::VisitWorldObjects(source, worker, dist);
}
#endif
diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp
index 1992235e257..1419a5b3b74 100644
--- a/src/server/scripts/Commands/cs_debug.cpp
+++ b/src/server/scripts/Commands/cs_debug.cpp
@@ -900,7 +900,7 @@ public:
Creature* passenger = NULL;
Trinity::AllCreaturesOfEntryInRange check(handler->GetSession()->GetPlayer(), entry, 20.0f);
Trinity::CreatureSearcher<Trinity::AllCreaturesOfEntryInRange> searcher(handler->GetSession()->GetPlayer(), passenger, check);
- handler->GetSession()->GetPlayer()->VisitNearbyObject(30.0f, searcher);
+ Cell::VisitAllObjects(handler->GetSession()->GetPlayer(), searcher, 30.0f);
if (!passenger || passenger == target)
return false;
passenger->EnterVehicle(target, seatId);
diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp
index 470119122fb..3a57c4ccd69 100644
--- a/src/server/scripts/Commands/cs_misc.cpp
+++ b/src/server/scripts/Commands/cs_misc.cpp
@@ -1985,7 +1985,7 @@ public:
Trinity::RespawnDo u_do;
Trinity::WorldObjectWorker<Trinity::RespawnDo> worker(player, u_do);
- player->VisitNearbyGridObject(player->GetGridActivationRange(), worker);
+ Cell::VisitGridObjects(player, worker, player->GetGridActivationRange());
return true;
}
diff --git a/src/server/scripts/Commands/cs_mmaps.cpp b/src/server/scripts/Commands/cs_mmaps.cpp
index f478cc6aa5e..c56114f0ebd 100644
--- a/src/server/scripts/Commands/cs_mmaps.cpp
+++ b/src/server/scripts/Commands/cs_mmaps.cpp
@@ -261,18 +261,11 @@ public:
float radius = 40.0f;
WorldObject* object = handler->GetSession()->GetPlayer();
- CellCoord pair(Trinity::ComputeCellCoord(object->GetPositionX(), object->GetPositionY()));
- Cell cell(pair);
- cell.SetNoCreate();
-
+ // Get Creatures
std::list<Creature*> creatureList;
-
Trinity::AnyUnitInObjectRangeCheck go_check(object, radius);
Trinity::CreatureListSearcher<Trinity::AnyUnitInObjectRangeCheck> go_search(object, creatureList, go_check);
- TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::AnyUnitInObjectRangeCheck>, GridTypeMapContainer> go_visit(go_search);
-
- // Get Creatures
- cell.Visit(pair, go_visit, *(object->GetMap()), *object, radius);
+ Cell::VisitGridObjects(object, go_search, radius);
if (!creatureList.empty())
{
diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp
index 53569bdce2a..6eaecffa2bb 100644
--- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp
+++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp
@@ -485,14 +485,9 @@ public:
float x, y, z;
me->GetPosition(x, y, z);
- CellCoord pair(Trinity::ComputeCellCoord(x, y));
- Cell cell(pair);
- 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()), *me, me->GetGridActivationRange());
+ Cell::VisitGridObjects(me, searcher, me->GetGridActivationRange());
for (std::list<Creature*>::const_iterator i = templist.begin(); i != templist.end(); ++i)
{
diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp
index 04bdd84cb54..9a9f0103e97 100644
--- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp
+++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp
@@ -906,17 +906,11 @@ void hyjalAI::JustDied(Unit* /*killer*/)
void hyjalAI::HideNearPos(float x, float y)
{
- CellCoord pair(Trinity::ComputeCellCoord(x, y));
- Cell cell(pair);
- 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);
- cell.Visit(pair, creature_visitor, *(me->GetMap()), *me, me->GetGridActivationRange());
+ Cell::VisitGridObjects(me, creature_searcher, me->GetGridActivationRange());
if (!creatures.empty())
{
@@ -930,14 +924,9 @@ void hyjalAI::HideNearPos(float x, float y)
void hyjalAI::RespawnNearPos(float x, float y)
{
- CellCoord p(Trinity::ComputeCellCoord(x, y));
- Cell cell(p);
- 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(), *me, me->GetGridActivationRange());
+ Cell::VisitGridObjects(me, worker, me->GetGridActivationRange());
}
void hyjalAI::WaypointReached(uint32 waypointId)
@@ -961,19 +950,11 @@ void hyjalAI::WaypointReached(uint32 waypointId)
}
//do some talking
//all alive guards walk near here
- CellCoord pair(Trinity::ComputeCellCoord(me->GetPositionX(), me->GetPositionY()));
- Cell cell(pair);
- 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);
-
- cell.Visit(pair, creature_visitor, *(me->GetMap()), *me, me->GetGridActivationRange());
+ Cell::VisitGridObjects(me, creature_searcher, me->GetGridActivationRange());
if (!creatures.empty())
{
@@ -1002,18 +983,10 @@ void hyjalAI::DoOverrun(uint32 faction, const uint32 diff)
{
if (TeleportTimer <= diff)
{
- CellCoord pair(Trinity::ComputeCellCoord(me->GetPositionX(), me->GetPositionY()));
- Cell cell(pair);
- cell.SetNoCreate();
-
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);
-
- cell.Visit(pair, creature_visitor, *(me->GetMap()), *me, me->GetGridActivationRange());
+ Cell::VisitGridObjects(me, creature_searcher, me->GetGridActivationRange());
if (!creatures.empty())
{
diff --git a/src/server/scripts/Kalimdor/Firelands/boss_alysrazor.cpp b/src/server/scripts/Kalimdor/Firelands/boss_alysrazor.cpp
index 3910789805a..d6933f03032 100644
--- a/src/server/scripts/Kalimdor/Firelands/boss_alysrazor.cpp
+++ b/src/server/scripts/Kalimdor/Firelands/boss_alysrazor.cpp
@@ -163,7 +163,7 @@ static void AlysrazorTrashEvaded(Creature* creature)
{
TrashRespawnWorker check;
Trinity::CreatureWorker<TrashRespawnWorker> worker(creature, check);
- creature->VisitNearbyGridObject(SIZE_OF_GRIDS, worker);
+ Cell::VisitGridObjects(creature, worker, SIZE_OF_GRIDS);
}
class npc_harbinger_of_flame : public CreatureScript
@@ -461,7 +461,7 @@ class npc_egg_pile : public CreatureScript
std::list<Creature*> eggs;
MoltenEggCheck check(me);
Trinity::CreatureListSearcher<MoltenEggCheck> searcher(me, eggs, check);
- me->VisitNearbyGridObject(20.0f, searcher);
+ Cell::VisitGridObjects(me, searcher, 20.0f);
if (!eggs.empty())
{
Creature* egg = Trinity::Containers::SelectRandomContainerElement(eggs);
diff --git a/src/server/scripts/Kalimdor/OnyxiasLair/boss_onyxia.cpp b/src/server/scripts/Kalimdor/OnyxiasLair/boss_onyxia.cpp
index 6f6660219b1..1da2fcb45c3 100644
--- a/src/server/scripts/Kalimdor/OnyxiasLair/boss_onyxia.cpp
+++ b/src/server/scripts/Kalimdor/OnyxiasLair/boss_onyxia.cpp
@@ -356,7 +356,7 @@ public:
GameObject* Floor = NULL;
Trinity::GameObjectInRangeCheck check(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 15);
Trinity::GameObjectLastSearcher<Trinity::GameObjectInRangeCheck> searcher(me, Floor, check);
- me->VisitNearbyGridObject(30, searcher);
+ Cell::VisitGridObjects(me, searcher, 30.0f);
if (Floor)
instance->SetGuidData(DATA_FLOOR_ERUPTION_GUID, Floor->GetGUID());
events.ScheduleEvent(EVENT_BELLOWING_ROAR, 30000);
diff --git a/src/server/scripts/Kalimdor/OnyxiasLair/instance_onyxias_lair.cpp b/src/server/scripts/Kalimdor/OnyxiasLair/instance_onyxias_lair.cpp
index 7845ce26f89..a0dfec7d722 100644
--- a/src/server/scripts/Kalimdor/OnyxiasLair/instance_onyxias_lair.cpp
+++ b/src/server/scripts/Kalimdor/OnyxiasLair/instance_onyxias_lair.cpp
@@ -118,7 +118,7 @@ public:
std::list<GameObject*> nearFloorList;
Trinity::GameObjectInRangeCheck check(floorEruption->GetPositionX(), floorEruption->GetPositionY(), floorEruption->GetPositionZ(), 15);
Trinity::GameObjectListSearcher<Trinity::GameObjectInRangeCheck> searcher(floorEruption, nearFloorList, check);
- floorEruption->VisitNearbyGridObject(999, searcher);
+ Cell::VisitGridObjects(floorEruption, searcher, SIZE_OF_GRIDS);
//remove all that are not present on FloorEruptionGUID[1] and update treeLen on each GUID
for (std::list<GameObject*>::const_iterator itr = nearFloorList.begin(); itr != nearFloorList.end(); ++itr)
{
diff --git a/src/server/scripts/Kalimdor/RazorfenDowns/razorfen_downs.cpp b/src/server/scripts/Kalimdor/RazorfenDowns/razorfen_downs.cpp
index 0c36843b6f2..24cb88a071c 100644
--- a/src/server/scripts/Kalimdor/RazorfenDowns/razorfen_downs.cpp
+++ b/src/server/scripts/Kalimdor/RazorfenDowns/razorfen_downs.cpp
@@ -208,7 +208,7 @@ public:
std::list<WorldObject*> ClusterList;
Trinity::AllWorldObjectsInRange objects(me, 50.0f);
Trinity::WorldObjectListSearcher<Trinity::AllWorldObjectsInRange> searcher(me, ClusterList, objects);
- me->VisitNearbyObject(50.0f, searcher);
+ Cell::VisitAllObjects(me, searcher, 50.0f);
for (std::list<WorldObject*>::const_iterator itr = ClusterList.begin(); itr != ClusterList.end(); ++itr)
{
if (Player* player = (*itr)->ToPlayer())
diff --git a/src/server/scripts/Kalimdor/zone_azuremyst_isle.cpp b/src/server/scripts/Kalimdor/zone_azuremyst_isle.cpp
index 244d084f218..0a7695eaf13 100644
--- a/src/server/scripts/Kalimdor/zone_azuremyst_isle.cpp
+++ b/src/server/scripts/Kalimdor/zone_azuremyst_isle.cpp
@@ -573,7 +573,7 @@ public:
std::list<Player*> players;
Trinity::AnyPlayerInObjectRangeCheck checker(me, radius);
Trinity::PlayerListSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(me, players, checker);
- me->VisitNearbyWorldObject(radius, searcher);
+ Cell::VisitWorldObjects(me, searcher, radius);
for (std::list<Player*>::const_iterator itr = players.begin(); itr != players.end(); ++itr)
if ((*itr)->GetQuestStatus(QUEST_TREES_COMPANY) == QUEST_STATUS_INCOMPLETE && (*itr)->HasAura(SPELL_TREE_DISGUISE))
diff --git a/src/server/scripts/Kalimdor/zone_bloodmyst_isle.cpp b/src/server/scripts/Kalimdor/zone_bloodmyst_isle.cpp
index 09770b58d65..04da6aa74aa 100644
--- a/src/server/scripts/Kalimdor/zone_bloodmyst_isle.cpp
+++ b/src/server/scripts/Kalimdor/zone_bloodmyst_isle.cpp
@@ -743,7 +743,7 @@ public:
Creature* sironas = NULL;
Trinity::AllCreaturesOfEntryInRange check(me, NPC_SIRONAS, SIZE_OF_GRIDS);
Trinity::CreatureSearcher<Trinity::AllCreaturesOfEntryInRange> searcher(me, sironas, check);
- me->VisitNearbyObject(SIZE_OF_GRIDS, searcher);
+ Cell::VisitAllObjects(me, searcher, SIZE_OF_GRIDS);
if (sironas)
{
diff --git a/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/boss_sartharion.cpp b/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/boss_sartharion.cpp
index d6ff08f3b1d..71487b5e048 100644
--- a/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/boss_sartharion.cpp
+++ b/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/boss_sartharion.cpp
@@ -396,7 +396,7 @@ public:
std::list<Creature*> fireCyclonesList;
Trinity::AllCreaturesOfEntryInRange checker(me, NPC_FIRE_CYCLONE, 200.0f);
Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange> searcher(me, fireCyclonesList, checker);
- me->VisitNearbyObject(200.0f, searcher);
+ Cell::VisitAllObjects(me, searcher, 200.0f);
if (fireCyclonesList.empty())
return;
diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_twin_valkyr.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_twin_valkyr.cpp
index 8981afc8bbe..7dadf497e10 100644
--- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_twin_valkyr.cpp
+++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_twin_valkyr.cpp
@@ -127,7 +127,7 @@ class OrbsDespawner : public BasicEvent
bool Execute(uint64 /*currTime*/, uint32 /*diff*/) override
{
Trinity::CreatureWorker<OrbsDespawner> worker(_creature, *this);
- _creature->VisitNearbyGridObject(5000.0f, worker);
+ Cell::VisitGridObjects(_creature, worker, SIZE_OF_GRIDS);
return true;
}
diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp
index e1afee40ccb..94009dd7c04 100644
--- a/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp
+++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp
@@ -1466,7 +1466,7 @@ struct npc_gunship_boarding_addAI : public gunship_npc_AI
std::list<Player*> players;
Trinity::UnitAuraCheck check(true, Instance->GetData(DATA_TEAM_IN_INSTANCE) == HORDE ? SPELL_ON_ORGRIMS_HAMMER_DECK : SPELL_ON_SKYBREAKER_DECK);
Trinity::PlayerListSearcher<Trinity::UnitAuraCheck> searcher(me, players, check);
- me->VisitNearbyWorldObject(200.0f, searcher);
+ Cell::VisitWorldObjects(me, searcher, 200.0f);
players.remove_if([this](Player* player)
{
@@ -1530,7 +1530,7 @@ struct npc_gunship_boarding_addAI : public gunship_npc_AI
std::list<Player*> players;
Trinity::UnitAuraCheck check(true, Instance->GetData(DATA_TEAM_IN_INSTANCE) == HORDE ? SPELL_ON_ORGRIMS_HAMMER_DECK : SPELL_ON_SKYBREAKER_DECK);
Trinity::PlayerListSearcher<Trinity::UnitAuraCheck> searcher(me, players, check);
- me->VisitNearbyWorldObject(200.0f, searcher);
+ Cell::VisitWorldObjects(me, searcher,200.0f );
players.remove_if([this](Player* player)
{
diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp
index 2449a14ece8..95e42ab8569 100644
--- a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp
+++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp
@@ -516,7 +516,7 @@ class boss_the_lich_king : public CreatureScript
// Reset The Frozen Throne gameobjects
FrozenThroneResetWorker reset;
Trinity::GameObjectWorker<FrozenThroneResetWorker> worker(me, reset);
- me->VisitNearbyGridObject(333.0f, worker);
+ Cell::VisitGridObjects(me, worker, 333.0f);
// Reset any light override
me->GetMap()->SetZoneOverrideLight(AREA_THE_FROZEN_THRONE, 0, 5000);
diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp
index f23adcb51e9..3ac7e714f36 100644
--- a/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp
+++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp
@@ -222,7 +222,7 @@ class ValithriaDespawner : public BasicEvent
bool Execute(uint64 /*currTime*/, uint32 /*diff*/) override
{
Trinity::CreatureWorker<ValithriaDespawner> worker(_creature, *this);
- _creature->VisitNearbyGridObject(333.0f, worker);
+ Cell::VisitGridObjects(_creature, worker, 333.0f);
return true;
}
@@ -719,7 +719,7 @@ class npc_risen_archmage : public CreatureScript
std::list<Creature*> archmages;
RisenArchmageCheck check;
Trinity::CreatureListSearcher<RisenArchmageCheck> searcher(me, archmages, check);
- me->VisitNearbyGridObject(100.0f, searcher);
+ Cell::VisitGridObjects(me, searcher, 100.0f);
for (std::list<Creature*>::iterator itr = archmages.begin(); itr != archmages.end(); ++itr)
(*itr)->AI()->DoAction(ACTION_ENTER_COMBAT);
@@ -1094,7 +1094,7 @@ class npc_dream_cloud : public CreatureScript
Player* player = NULL;
Trinity::AnyPlayerInObjectRangeCheck check(me, 5.0f);
Trinity::PlayerSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(me, player, check);
- me->VisitNearbyWorldObject(7.5f, searcher);
+ Cell::VisitWorldObjects(me, searcher, 7.5f);
_events.ScheduleEvent(player ? EVENT_EXPLODE : EVENT_CHECK_PLAYER, 1000);
break;
}
diff --git a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp
index e04de227806..04c5fa35875 100644
--- a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp
+++ b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp
@@ -1083,7 +1083,7 @@ class npc_crok_scourgebane : public CreatureScript
std::list<Creature*> temp;
FrostwingVrykulSearcher check(me, 80.0f);
Trinity::CreatureListSearcher<FrostwingVrykulSearcher> searcher(me, temp, check);
- me->VisitNearbyGridObject(80.0f, searcher);
+ Cell::VisitGridObjects(me, searcher, 80.0f);
_aliveTrash.clear();
for (std::list<Creature*>::iterator itr = temp.begin(); itr != temp.end(); ++itr)
@@ -1110,7 +1110,7 @@ class npc_crok_scourgebane : public CreatureScript
Player* player = NULL;
Trinity::AnyPlayerInObjectRangeCheck check(me, 60.0f);
Trinity::PlayerSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(me, player, check);
- me->VisitNearbyWorldObject(60.0f, searcher);
+ Cell::VisitWorldObjects(me, searcher, 60.0f);
// wipe
if (!player)
{
@@ -1119,7 +1119,7 @@ class npc_crok_scourgebane : public CreatureScript
{
FrostwingGauntletRespawner respawner;
Trinity::CreatureWorker<FrostwingGauntletRespawner> worker(me, respawner);
- me->VisitNearbyGridObject(333.0f, worker);
+ Cell::VisitGridObjects(me, worker, 333.0f);
Talk(SAY_CROK_DEATH);
}
return;
@@ -1424,7 +1424,7 @@ class npc_captain_arnath : public CreatureScript
Creature* target = NULL;
Trinity::MostHPMissingInRange u_check(me, 60.0f, 0);
Trinity::CreatureLastSearcher<Trinity::MostHPMissingInRange> searcher(me, target, u_check);
- me->VisitNearbyGridObject(60.0f, searcher);
+ Cell::VisitGridObjects(me, searcher, 60.0f);
return target;
}
};
diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp
index c3ba553af5d..ab9b636f153 100644
--- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp
+++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp
@@ -1750,7 +1750,7 @@ class spell_vehicle_throw_passenger : public SpellScriptLoader
std::list<WorldObject*> targetList;
Trinity::WorldObjectSpellAreaTargetCheck check(99, GetExplTargetDest(), GetCaster(), GetCaster(), GetSpellInfo(), TARGET_CHECK_DEFAULT, NULL);
Trinity::WorldObjectListSearcher<Trinity::WorldObjectSpellAreaTargetCheck> searcher(GetCaster(), targetList, check);
- GetCaster()->GetMap()->VisitAll(GetCaster()->m_positionX, GetCaster()->m_positionY, 99, searcher);
+ Cell::VisitAllObjects(GetCaster(), searcher, 99.0f);
float minDist = 99 * 99;
Unit* target = NULL;
for (std::list<WorldObject*>::iterator itr = targetList.begin(); itr != targetList.end(); ++itr)
diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_hodir.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_hodir.cpp
index 5ffa4508eb6..9e495bd6d08 100644
--- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_hodir.cpp
+++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_hodir.cpp
@@ -520,7 +520,7 @@ class boss_hodir : public CreatureScript
std::list<Unit*> TargetList;
Trinity::AnyUnfriendlyUnitInObjectRangeCheck checker(me, me, 100.0f);
Trinity::UnitListSearcher<Trinity::AnyUnfriendlyUnitInObjectRangeCheck> searcher(me, TargetList, checker);
- me->VisitNearbyObject(100.0f, searcher);
+ Cell::VisitAllObjects(me, searcher, 100.0f);
for (std::list<Unit*>::iterator itr = TargetList.begin(); itr != TargetList.end(); ++itr)
{
Unit* target = *itr;
@@ -694,7 +694,7 @@ class npc_hodir_priest : public CreatureScript
std::list<Unit*> TargetList;
Trinity::AnyFriendlyUnitInObjectRangeCheck checker(me, me, 30.0f);
Trinity::UnitListSearcher<Trinity::AnyFriendlyUnitInObjectRangeCheck> searcher(me, TargetList, checker);
- me->VisitNearbyObject(30.0f, searcher);
+ Cell::VisitAllObjects(me, searcher, 30.0f);
for (std::list<Unit*>::iterator itr = TargetList.begin(); itr != TargetList.end(); ++itr)
if ((*itr)->HasAura(SPELL_FREEZE))
DoCast(*itr, SPELL_DISPEL_MAGIC, true);
diff --git a/src/server/scripts/Outland/zone_blades_edge_mountains.cpp b/src/server/scripts/Outland/zone_blades_edge_mountains.cpp
index 7dc23670a13..84e2635d8a9 100644
--- a/src/server/scripts/Outland/zone_blades_edge_mountains.cpp
+++ b/src/server/scripts/Outland/zone_blades_edge_mountains.cpp
@@ -573,7 +573,7 @@ class npc_simon_bunny : public CreatureScript
std::list<WorldObject*> ClusterList;
Trinity::AllWorldObjectsInRange objects(me, searchDistance);
Trinity::WorldObjectListSearcher<Trinity::AllWorldObjectsInRange> searcher(me, ClusterList, objects);
- me->VisitNearbyObject(searchDistance, searcher);
+ Cell::VisitAllObjects(me, searcher, searchDistance);
for (std::list<WorldObject*>::const_iterator i = ClusterList.begin(); i != ClusterList.end(); ++i)
{
diff --git a/src/server/scripts/Pet/pet_dk.cpp b/src/server/scripts/Pet/pet_dk.cpp
index 8ddcaa96479..a17b9fd8b59 100644
--- a/src/server/scripts/Pet/pet_dk.cpp
+++ b/src/server/scripts/Pet/pet_dk.cpp
@@ -56,7 +56,7 @@ class npc_pet_dk_ebon_gargoyle : public CreatureScript
std::list<Unit*> targets;
Trinity::AnyUnfriendlyUnitInObjectRangeCheck u_check(me, me, 30.0f);
Trinity::UnitListSearcher<Trinity::AnyUnfriendlyUnitInObjectRangeCheck> searcher(me, targets, u_check);
- me->VisitNearbyObject(30.0f, searcher);
+ Cell::VisitAllObjects(me, searcher, 30.0f);
for (std::list<Unit*>::const_iterator iter = targets.begin(); iter != targets.end(); ++iter)
if ((*iter)->HasAura(SPELL_DK_SUMMON_GARGOYLE_1, ownerGuid))
{
diff --git a/src/server/scripts/Pet/pet_mage.cpp b/src/server/scripts/Pet/pet_mage.cpp
index 674edf47deb..ef1eb2a356e 100644
--- a/src/server/scripts/Pet/pet_mage.cpp
+++ b/src/server/scripts/Pet/pet_mage.cpp
@@ -60,7 +60,7 @@ class npc_pet_mage_mirror_image : public CreatureScript
std::list<Unit*> targets;
Trinity::AnyUnfriendlyUnitInObjectRangeCheck u_check(me, me, 30.0f);
Trinity::UnitListSearcher<Trinity::AnyUnfriendlyUnitInObjectRangeCheck> searcher(me, targets, u_check);
- me->VisitNearbyObject(40.0f, searcher);
+ Cell::VisitAllObjects(me, searcher, 40.0f);
Unit* highestThreatUnit = nullptr;
float highestThreat = 0.0f;
@@ -122,7 +122,7 @@ class npc_pet_mage_mirror_image : public CreatureScript
std::list<Unit*> targets;
Trinity::AnyUnfriendlyUnitInObjectRangeCheck u_check(me, me, 30.0f);
Trinity::UnitListSearcher<Trinity::AnyUnfriendlyUnitInObjectRangeCheck> searcher(me, targets, u_check);
- me->VisitNearbyObject(40.0f, searcher);
+ Cell::VisitAllObjects(me, searcher, 40.0f);
for (std::list<Unit*>::const_iterator iter = targets.begin(); iter != targets.end(); ++iter)
{
diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp
index 9d23f016a76..62408425efa 100644
--- a/src/server/scripts/Spells/spell_generic.cpp
+++ b/src/server/scripts/Spells/spell_generic.cpp
@@ -744,7 +744,9 @@ class spell_gen_cannibalize : public SpellScriptLoader
// search for nearby enemy corpse in range
Trinity::AnyDeadUnitSpellTargetInRangeCheck check(caster, max_range, GetSpellInfo(), TARGET_CHECK_ENEMY);
Trinity::WorldObjectSearcher<Trinity::AnyDeadUnitSpellTargetInRangeCheck> searcher(caster, result, check);
- caster->GetMap()->VisitFirstFound(caster->m_positionX, caster->m_positionY, max_range, searcher);
+ Cell::VisitWorldObjects(caster, searcher, max_range);
+ if (!result)
+ Cell::VisitGridObjects(caster, searcher, max_range);
if (!result)
return SPELL_FAILED_NO_EDIBLE_CORPSES;
return SPELL_CAST_OK;
diff --git a/src/server/scripts/Spells/spell_holiday.cpp b/src/server/scripts/Spells/spell_holiday.cpp
index 59b4e11d6c2..9ce05057f37 100644
--- a/src/server/scripts/Spells/spell_holiday.cpp
+++ b/src/server/scripts/Spells/spell_holiday.cpp
@@ -81,7 +81,7 @@ class spell_love_is_in_the_air_romantic_picnic : public SpellScriptLoader
std::list<Player*> playerList;
Trinity::AnyPlayerInObjectRangeCheck checker(target, INTERACTION_DISTANCE*2);
Trinity::PlayerListSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(target, playerList, checker);
- target->VisitNearbyWorldObject(INTERACTION_DISTANCE*2, searcher);
+ Cell::VisitWorldObjects(target, searcher, INTERACTION_DISTANCE * 2);
for (std::list<Player*>::const_iterator itr = playerList.begin(); itr != playerList.end(); ++itr)
{
if ((*itr) != target && (*itr)->HasAura(GetId())) // && (*itr)->GetStandState() == UNIT_STAND_STATE_SIT)
diff --git a/src/server/scripts/Spells/spell_hunter.cpp b/src/server/scripts/Spells/spell_hunter.cpp
index e3684578dbd..c26b0b47a59 100644
--- a/src/server/scripts/Spells/spell_hunter.cpp
+++ b/src/server/scripts/Spells/spell_hunter.cpp
@@ -507,7 +507,9 @@ class spell_hun_pet_carrion_feeder : public SpellScriptLoader
// search for nearby enemy corpse in range
Trinity::AnyDeadUnitSpellTargetInRangeCheck check(caster, max_range, GetSpellInfo(), TARGET_CHECK_ENEMY);
Trinity::WorldObjectSearcher<Trinity::AnyDeadUnitSpellTargetInRangeCheck> searcher(caster, result, check);
- caster->GetMap()->VisitFirstFound(caster->m_positionX, caster->m_positionY, max_range, searcher);
+ Cell::VisitWorldObjects(caster, searcher, max_range);
+ if (!result)
+ Cell::VisitGridObjects(caster, searcher, max_range);
if (!result)
return SPELL_FAILED_NO_EDIBLE_CORPSES;
return SPELL_CAST_OK;
diff --git a/src/server/scripts/Spells/spell_quest.cpp b/src/server/scripts/Spells/spell_quest.cpp
index a68c2bab31b..2959e50992e 100644
--- a/src/server/scripts/Spells/spell_quest.cpp
+++ b/src/server/scripts/Spells/spell_quest.cpp
@@ -1594,12 +1594,12 @@ class spell_q11010_q11102_q11023_choose_loc : public SpellScriptLoader
std::list<Player*> playerList;
Trinity::AnyPlayerInObjectRangeCheck checker(caster, 65.0f);
Trinity::PlayerListSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(caster, playerList, checker);
- caster->VisitNearbyWorldObject(65.0f, searcher);
- for (std::list<Player*>::const_iterator itr = playerList.begin(); itr != playerList.end(); ++itr)
+ Cell::VisitWorldObjects(caster, searcher, 65.0f);
+ for (std::list<Player*>::const_iterator itr = playerList.begin(); itr != playerList.end(); ++itr)
// Check if found player target is on fly mount or using flying form
- if ((*itr)->HasAuraType(SPELL_AURA_FLY) || (*itr)->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED))
- // Summom Fel Cannon (bunny version) at found player
- caster->SummonCreature(NPC_FEL_CANNON2, (*itr)->GetPositionX(), (*itr)->GetPositionY(), (*itr)->GetPositionZ());
+ if ((*itr)->HasAuraType(SPELL_AURA_FLY) || (*itr)->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED))
+ // Summom Fel Cannon (bunny version) at found player
+ caster->SummonCreature(NPC_FEL_CANNON2, (*itr)->GetPositionX(), (*itr)->GetPositionY(), (*itr)->GetPositionZ());
}
void Register() override
diff --git a/src/server/scripts/World/npcs_special.cpp b/src/server/scripts/World/npcs_special.cpp
index 6bfd65c6fe2..c568929c28f 100644
--- a/src/server/scripts/World/npcs_special.cpp
+++ b/src/server/scripts/World/npcs_special.cpp
@@ -561,7 +561,7 @@ public:
std::list<Player*> players;
Trinity::UnitAuraCheck check(true, SPELL_RIBBON_DANCE_COSMETIC);
Trinity::PlayerListSearcher<Trinity::UnitAuraCheck> searcher(me, players, check);
- me->VisitNearbyWorldObject(10.0f, searcher);
+ Cell::VisitWorldObjects(me, searcher, 10.0f);
return players.empty();
}
diff --git a/src/server/shared/Realm/Realm.cpp b/src/server/shared/Realm/Realm.cpp
index 2754fa60581..ebdcdc4ac8e 100644
--- a/src/server/shared/Realm/Realm.cpp
+++ b/src/server/shared/Realm/Realm.cpp
@@ -18,6 +18,8 @@
#include "Realm.h"
#include "StringFormat.h"
#include <boost/asio/ip/address.hpp>
+#include <algorithm>
+#include <cctype>
void Realm::SetName(std::string name)
{
diff --git a/src/server/worldserver/Main.cpp b/src/server/worldserver/Main.cpp
index af1311f3b62..363e3a8ce64 100644
--- a/src/server/worldserver/Main.cpp
+++ b/src/server/worldserver/Main.cpp
@@ -330,7 +330,7 @@ extern int main(int argc, char** argv)
if (int coreStuckTime = sConfigMgr->GetIntDefault("MaxCoreStuckTime", 0))
{
freezeDetector = std::make_shared<FreezeDetector>(*ioService, coreStuckTime * 1000);
- freezeDetector->Start(freezeDetector);
+ FreezeDetector::Start(freezeDetector);
TC_LOG_INFO("server.worldserver", "Starting up anti-freeze thread (%u seconds max stuck time)...", coreStuckTime);
}