From 7152ddc82c8f103d354ff891875178ed41c204c9 Mon Sep 17 00:00:00 2001 From: Kitzunu <24550914+Kitzunu@users.noreply.github.com> Date: Thu, 3 Jun 2021 05:27:51 +0200 Subject: [PATCH] refactor(Core/Grids): Ported cmangos/mangos-wotlk@ea99457 (#6113) * refactor(Core/Grids): Ported cmangos/mangos-wotlk@ea99457 (cherry picked from commit https://github.com/TrinityCore/TrinityCore/commit/d6201e5dbb7fa7ca8b47ffa6c0d30fa38dceada5) Co-Authored-By: Shauren Co-Authored-By: SilverIce * Update CellImpl.h * w * more more brackets * ew * fix build --- src/server/game/AI/CoreAI/TotemAI.cpp | 2 +- .../game/AI/ScriptedAI/ScriptedCreature.cpp | 13 +-- .../game/AI/SmartScripts/SmartScript.cpp | 10 +- .../game/Achievements/AchievementMgr.cpp | 2 +- src/server/game/Battlefield/Battlefield.cpp | 2 +- src/server/game/Chat/Chat.cpp | 2 +- .../game/Entities/Creature/Creature.cpp | 74 +++--------- .../game/Entities/GameObject/GameObject.cpp | 14 +-- src/server/game/Entities/Object/Object.cpp | 37 ++---- src/server/game/Entities/Object/Object.h | 4 - src/server/game/Entities/Player/Player.cpp | 10 +- src/server/game/Entities/Unit/Unit.cpp | 18 +-- src/server/game/Grids/Cells/Cell.h | 12 +- src/server/game/Grids/Cells/CellImpl.h | 106 ++++++++++++++++-- src/server/game/Maps/Map.cpp | 22 ---- src/server/game/Maps/Map.h | 58 ---------- src/server/game/OutdoorPvP/OutdoorPvP.cpp | 2 +- .../game/Spells/Auras/SpellAuraEffects.cpp | 4 +- src/server/game/Spells/Auras/SpellAuras.cpp | 12 +- src/server/game/Spells/Spell.cpp | 13 +-- src/server/game/Spells/SpellEffects.cpp | 6 +- src/server/game/Texts/CreatureTextMgr.h | 2 +- src/server/scripts/Commands/cs_debug.cpp | 2 +- src/server/scripts/Commands/cs_misc.cpp | 4 +- src/server/scripts/Commands/cs_mmaps.cpp | 11 +- .../EasternKingdoms/ZulAman/boss_akilzon.cpp | 17 +-- .../EasternKingdoms/ZulAman/boss_janalai.cpp | 44 ++------ src/server/scripts/Events/brewfest.cpp | 2 +- src/server/scripts/Events/hallows_end.cpp | 2 +- src/server/scripts/Events/love_in_air.cpp | 2 +- .../BattleForMountHyjal/hyjalAI.cpp | 34 +----- .../Kalimdor/RazorfenDowns/razorfen_downs.cpp | 2 +- .../Kalimdor/ZulFarrak/instance_zulfarrak.cpp | 2 +- .../scripts/Kalimdor/zone_moonglade.cpp | 2 +- .../IcecrownCitadel/boss_the_lich_king.cpp | 2 +- .../boss_valithria_dreamwalker.cpp | 4 +- .../IcecrownCitadel/icecrown_citadel.cpp | 10 +- .../Naxxramas/instance_naxxramas.cpp | 2 +- .../Ulduar/Ulduar/boss_flame_leviathan.cpp | 2 +- .../scripts/Northrend/zone_dragonblight.cpp | 4 +- .../Outland/zone_blades_edge_mountains.cpp | 2 +- src/server/scripts/Pet/pet_dk.cpp | 2 +- src/server/scripts/Spells/spell_generic.cpp | 8 +- src/server/scripts/Spells/spell_hunter.cpp | 8 +- src/server/scripts/Spells/spell_quest.cpp | 2 +- src/server/scripts/World/go_scripts.cpp | 4 +- 46 files changed, 238 insertions(+), 361 deletions(-) diff --git a/src/server/game/AI/CoreAI/TotemAI.cpp b/src/server/game/AI/CoreAI/TotemAI.cpp index 7beb5f2c6..cbb1e99bb 100644 --- a/src/server/game/AI/CoreAI/TotemAI.cpp +++ b/src/server/game/AI/CoreAI/TotemAI.cpp @@ -73,7 +73,7 @@ void TotemAI::UpdateAI(uint32 /*diff*/) victim = nullptr; Acore::NearestAttackableUnitInObjectRangeCheck u_check(me, me, max_range); Acore::UnitLastSearcher checker(me, victim, u_check); - me->VisitNearbyObject(max_range, checker); + Cell::VisitAllObjects(me, checker, max_range); } if (!victim && me->GetCharmerOrOwnerOrSelf()->IsInCombat()) diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp index f6ce77958..c771fdf6c 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp @@ -381,7 +381,7 @@ Unit* ScriptedAI::DoSelectLowestHpFriendly(float range, uint32 minHPDiff) Unit* unit = nullptr; Acore::MostHPMissingInRange u_check(me, range, minHPDiff); Acore::UnitLastSearcher searcher(me, unit, u_check); - me->VisitNearbyObject(range, searcher); + Cell::VisitAllObjects(me, searcher, range); return unit; } @@ -391,7 +391,7 @@ std::list ScriptedAI::DoFindFriendlyCC(float range) std::list list; Acore::FriendlyCCedInRange u_check(me, range); Acore::CreatureListSearcher searcher(me, list, u_check); - me->VisitNearbyObject(range, searcher); + Cell::VisitAllObjects(me, searcher, range); return list; } @@ -400,7 +400,7 @@ std::list ScriptedAI::DoFindFriendlyMissingBuff(float range, uint32 u std::list list; Acore::FriendlyMissingBuffInRange u_check(me, range, uiSpellid); Acore::CreatureListSearcher searcher(me, list, u_check); - me->VisitNearbyObject(range, searcher); + Cell::VisitAllObjects(me, searcher, range); return list; } @@ -408,15 +408,10 @@ Player* ScriptedAI::GetPlayerAtMinimumRange(float minimumRange) { Player* player = nullptr; - CellCoord pair(Acore::ComputeCellCoord(me->GetPositionX(), me->GetPositionY())); - Cell cell(pair); - cell.SetNoCreate(); - Acore::PlayerAtMinimumRangeAway check(me, minimumRange); Acore::PlayerSearcher searcher(me, player, check); - TypeContainerVisitor, 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 bc62fc955..1091f1e18 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -3881,7 +3881,7 @@ ObjectList* SmartScript::GetWorldObjectsInDist(float dist) { Acore::AllWorldObjectsInRange u_check(obj, dist); Acore::WorldObjectListSearcher searcher(obj, *targets, u_check); - obj->VisitNearbyObject(dist, searcher); + Cell::VisitAllObjects(obj, searcher, dist); } return targets; } @@ -4864,7 +4864,7 @@ Unit* SmartScript::DoSelectLowestHpFriendly(float range, uint32 MinHPDiff) Acore::MostHPMissingInRange u_check(me, range, MinHPDiff); Acore::UnitLastSearcher searcher(me, unit, u_check); - me->VisitNearbyObject(range, searcher); + Cell::VisitGridObjects(me, searcher, range); return unit; } @@ -4875,7 +4875,7 @@ void SmartScript::DoFindFriendlyCC(std::list& _list, float range) Acore::FriendlyCCedInRange u_check(me, range); Acore::CreatureListSearcher searcher(me, _list, u_check); - me->VisitNearbyObject(range, searcher); + Cell::VisitGridObjects(me, searcher, range); } void SmartScript::DoFindFriendlyMissingBuff(std::list& list, float range, uint32 spellid) @@ -4885,7 +4885,7 @@ void SmartScript::DoFindFriendlyMissingBuff(std::list& list, float ra Acore::FriendlyMissingBuffInRange u_check(me, range, spellid); Acore::CreatureListSearcher searcher(me, list, u_check); - me->VisitNearbyObject(range, searcher); + Cell::VisitGridObjects(me, searcher, range); } Unit* SmartScript::DoFindClosestFriendlyInRange(float range, bool playerOnly) @@ -4896,7 +4896,7 @@ Unit* SmartScript::DoFindClosestFriendlyInRange(float range, bool playerOnly) Unit* unit = nullptr; Acore::AnyFriendlyNotSelfUnitInObjectRangeCheck u_check(me, me, range, playerOnly); Acore::UnitLastSearcher 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 8b9865c12..b5cb36c27 100644 --- a/src/server/game/Achievements/AchievementMgr.cpp +++ b/src/server/game/Achievements/AchievementMgr.cpp @@ -715,7 +715,7 @@ void AchievementMgr::SendAchievementEarned(AchievementEntry const* achievement) Acore::LocalizedPacketDo say_do(say_builder); Acore::PlayerDistWorker > say_worker(GetPlayer(), sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_SAY), say_do); TypeContainerVisitor >, WorldTypeMapContainer > message(say_worker); - cell.Visit(p, message, *GetPlayer()->GetMap(), *GetPlayer(), sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_SAY)); + Cell::VisitWorldObjects(GetPlayer(), say_worker, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_SAY)); } WorldPacket data(SMSG_ACHIEVEMENT_EARNED, 8 + 4 + 8); diff --git a/src/server/game/Battlefield/Battlefield.cpp b/src/server/game/Battlefield/Battlefield.cpp index 6f54807b3..be64bc35d 100644 --- a/src/server/game/Battlefield/Battlefield.cpp +++ b/src/server/game/Battlefield/Battlefield.cpp @@ -1005,7 +1005,7 @@ bool BfCapturePoint::Update(uint32 diff) std::list players; Acore::AnyPlayerInObjectRangeCheck checker(capturePoint, radius); Acore::PlayerListSearcher searcher(capturePoint, players, checker); - capturePoint->VisitNearbyWorldObject(radius, searcher); + Cell::VisitWorldObjects(capturePoint, searcher, radius); for (std::list::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 9b52eff90..9671946ac 100644 --- a/src/server/game/Chat/Chat.cpp +++ b/src/server/game/Chat/Chat.cpp @@ -888,7 +888,7 @@ GameObject* ChatHandler::GetNearbyGameObject() GameObject* obj = nullptr; Acore::NearestGameObjectCheck check(*pl); Acore::GameObjectLastSearcher 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/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 4a0dc9de5..c57e4b2b5 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -888,15 +888,10 @@ void Creature::DoFleeToGetAssistance() { Creature* creature = nullptr; - CellCoord p(Acore::ComputeCellCoord(GetPositionX(), GetPositionY())); - Cell cell(p); - cell.SetNoCreate(); Acore::NearestAssistCreatureInCreatureRangeCheck u_check(this, GetVictim(), radius); Acore::CreatureLastSearcher searcher(this, creature, u_check); - TypeContainerVisitor, GridTypeMapContainer > grid_creature_searcher(searcher); - - cell.Visit(p, grid_creature_searcher, *GetMap(), *this, radius); + Cell::VisitGridObjects(this, searcher, radius); SetNoSearchAssistance(true); UpdateSpeed(MOVE_RUN, false); @@ -2077,53 +2072,31 @@ 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(Acore::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_SEARCHER_DISTANCE; - - Acore::NearestHostileUnitCheck u_check(this, dist, playerOnly); - Acore::UnitLastSearcher searcher(this, target, u_check); - - TypeContainerVisitor, WorldTypeMapContainer > world_unit_searcher(searcher); - TypeContainerVisitor, GridTypeMapContainer > grid_unit_searcher(searcher); - - cell.Visit(p, world_unit_searcher, *GetMap(), *this, dist); - cell.Visit(p, grid_unit_searcher, *GetMap(), *this, dist); - } - + Acore::NearestHostileUnitCheck u_check(this, dist, playerOnly); + Acore::UnitLastSearcher 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(Acore::ComputeCellCoord(GetPositionX(), GetPositionY())); - Cell cell(p); - cell.SetNoCreate(); - - Unit* target = nullptr; - if (dist < ATTACK_DISTANCE) dist = ATTACK_DISTANCE; if (dist > MAX_SEARCHER_DISTANCE) dist = MAX_SEARCHER_DISTANCE; - { - Acore::NearestHostileUnitInAttackDistanceCheck u_check(this, dist); - Acore::UnitLastSearcher searcher(this, target, u_check); - - TypeContainerVisitor, WorldTypeMapContainer > world_unit_searcher(searcher); - TypeContainerVisitor, GridTypeMapContainer > grid_unit_searcher(searcher); - - cell.Visit(p, world_unit_searcher, *GetMap(), *this, dist); - cell.Visit(p, grid_unit_searcher, *GetMap(), *this, dist); - } + Unit* target = nullptr; + Acore::NearestHostileUnitInAttackDistanceCheck u_check(this, dist); + Acore::UnitLastSearcher searcher(this, target, u_check); + Cell::VisitAllObjects(this, searcher, std::max(dist, ATTACK_DISTANCE)); return target; } @@ -2154,18 +2127,9 @@ void Creature::CallAssistance() { std::list assistList; - { - CellCoord p(Acore::ComputeCellCoord(GetPositionX(), GetPositionY())); - Cell cell(p); - cell.SetNoCreate(); - - Acore::AnyAssistCreatureInRangeCheck u_check(this, GetVictim(), radius); - Acore::CreatureListSearcher searcher(this, assistList, u_check); - - TypeContainerVisitor, GridTypeMapContainer > grid_creature_searcher(searcher); - - cell.Visit(p, grid_creature_searcher, *GetMap(), *this, radius); - } + Acore::AnyAssistCreatureInRangeCheck u_check(this, GetVictim(), radius); + Acore::CreatureListSearcher searcher(this, assistList, u_check); + Cell::VisitGridObjects(this, searcher, radius); if (!assistList.empty()) { @@ -2187,16 +2151,10 @@ void Creature::CallForHelp(float radius) if (radius <= 0.0f || !GetVictim() || IsPet() || IsCharmed()) return; - CellCoord p(Acore::ComputeCellCoord(GetPositionX(), GetPositionY())); - Cell cell(p); - cell.SetNoCreate(); - Acore::CallOfHelpCreatureInRangeDo u_do(this, GetVictim(), radius); Acore::CreatureWorker worker(this, u_do); - TypeContainerVisitor, 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 diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 18386a186..82fbd6b96 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -610,9 +610,7 @@ void GameObject::Update(uint32 diff) { Acore::AnyUnfriendlyNoTotemUnitInObjectRangeCheck checker(this, owner, radius); Acore::UnitSearcher searcher(this, target, checker); - VisitNearbyGridObject(radius, searcher); - if (!target) - VisitNearbyWorldObject(radius, searcher); + Cell::VisitAllObjects(this, searcher, radius); } else // environmental trap { @@ -621,7 +619,7 @@ void GameObject::Update(uint32 diff) Player* player = nullptr; Acore::AnyPlayerInObjectRangeCheck checker(this, radius, true, true); Acore::PlayerSearcher searcher(this, player, checker); - VisitNearbyWorldObject(radius, searcher); + Cell::VisitWorldObjects(this, searcher, radius); target = player; } @@ -1209,14 +1207,10 @@ GameObject* GameObject::LookupFishingHoleAround(float range) { GameObject* ok = nullptr; - CellCoord p(Acore::ComputeCellCoord(GetPositionX(), GetPositionY())); - Cell cell(p); Acore::NearestGameObjectFishingHole u_check(*this, range); Acore::GameObjectSearcher checker(this, ok, u_check); - TypeContainerVisitor, GridTypeMapContainer > grid_object_checker(checker); - cell.Visit(p, grid_object_checker, *GetMap(), *this, range); - + Cell::VisitGridObjects(this, checker, range); return ok; } @@ -1978,7 +1972,7 @@ void GameObject::SendMessageToSetInRange(WorldPacket* data, float dist, bool /*s if (includeMargin) dist += VISIBILITY_COMPENSATION * 2.0f; // pussywizard: to ensure everyone receives all important packets Acore::MessageDistDeliverer notifier(this, data, dist, false, skipped_rcvr); - VisitNearbyWorldObject(dist, notifier); + Cell::VisitWorldObjects(this, notifier, dist); } void GameObject::EventInform(uint32 eventId) diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index c9cdcb8e7..2c2e33839 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -2073,7 +2073,7 @@ void WorldObject::SendMessageToSetInRange(WorldPacket* data, float dist, bool /* if (includeMargin) dist += VISIBILITY_COMPENSATION; // pussywizard: to ensure everyone receives all important packets Acore::MessageDistDeliverer notifier(this, data, dist, false, skipped_rcvr); - VisitNearbyWorldObject(dist, notifier); + Cell::VisitWorldObjects(this, notifier, dist); } void WorldObject::SendObjectDeSpawnAnim(ObjectGuid guid) @@ -2406,7 +2406,7 @@ Creature* WorldObject::FindNearestCreature(uint32 entry, float range, bool alive Creature* creature = nullptr; Acore::NearestCreatureEntryWithLiveStateInObjectRangeCheck checker(*this, entry, alive, range); Acore::CreatureLastSearcher searcher(this, creature, checker); - VisitNearbyObject(range, searcher); + Cell::VisitAllObjects(this, searcher, range); return creature; } @@ -2415,7 +2415,7 @@ GameObject* WorldObject::FindNearestGameObject(uint32 entry, float range) const GameObject* go = nullptr; Acore::NearestGameObjectEntryInObjectRangeCheck checker(*this, entry, range); Acore::GameObjectLastSearcher searcher(this, go, checker); - VisitNearbyGridObject(range, searcher); + Cell::VisitGridObjects(this, searcher, range); return go; } @@ -2424,7 +2424,7 @@ GameObject* WorldObject::FindNearestGameObjectOfType(GameobjectTypes type, float GameObject* go = nullptr; Acore::NearestGameObjectTypeInObjectRangeCheck checker(*this, type, range); Acore::GameObjectLastSearcher searcher(this, go, checker); - VisitNearbyGridObject(range, searcher); + Cell::VisitGridObjects(this, searcher, range); return go; } @@ -2434,35 +2434,23 @@ Player* WorldObject::SelectNearestPlayer(float distance) const Acore::NearestPlayerInObjectRangeCheck checker(this, distance); Acore::PlayerLastSearcher searcher(this, target, checker); - VisitNearbyObject(distance, searcher); + Cell::VisitWorldObjects(this, searcher, distance); return target; } void WorldObject::GetGameObjectListWithEntryInGrid(std::list& gameobjectList, uint32 entry, float maxSearchRange) const { - CellCoord pair(Acore::ComputeCellCoord(this->GetPositionX(), this->GetPositionY())); - Cell cell(pair); - cell.SetNoCreate(); - Acore::AllGameObjectsWithEntryInRange check(this, entry, maxSearchRange); Acore::GameObjectListSearcher searcher(this, gameobjectList, check); - TypeContainerVisitor, GridTypeMapContainer> visitor(searcher); - - cell.Visit(pair, visitor, *(this->GetMap()), *this, maxSearchRange); + Cell::VisitGridObjects(this, searcher, maxSearchRange); } void WorldObject::GetCreatureListWithEntryInGrid(std::list& creatureList, uint32 entry, float maxSearchRange) const { - CellCoord pair(Acore::ComputeCellCoord(this->GetPositionX(), this->GetPositionY())); - Cell cell(pair); - cell.SetNoCreate(); - Acore::AllCreaturesOfEntryInRange check(this, entry, maxSearchRange); Acore::CreatureListSearcher searcher(this, creatureList, check); - TypeContainerVisitor, GridTypeMapContainer> visitor(searcher); - - cell.Visit(pair, visitor, *(this->GetMap()), *this, maxSearchRange); + Cell::VisitGridObjects(this, searcher, maxSearchRange);; } /* @@ -2843,7 +2831,7 @@ void WorldObject::DestroyForNearbyPlayers() std::list targets; Acore::AnyPlayerInObjectRangeCheck check(this, GetVisibilityRange() + VISIBILITY_COMPENSATION, false); Acore::PlayerListSearcherWithSharedVision searcher(this, targets, check); - VisitNearbyWorldObject(GetVisibilityRange() + VISIBILITY_COMPENSATION, searcher); + Cell::VisitWorldObjects(this, searcher, GetVisibilityRange()); for (std::list::const_iterator iter = targets.begin(); iter != targets.end(); ++iter) { Player* player = (*iter); @@ -2866,7 +2854,7 @@ void WorldObject::UpdateObjectVisibility(bool /*forced*/, bool /*fromUpdate*/) { //updates object's visibility for nearby players Acore::VisibleChangesNotifier notifier(*this); - VisitNearbyWorldObject(GetVisibilityRange() + VISIBILITY_COMPENSATION, notifier); + Cell::VisitWorldObjects(this, notifier, GetVisibilityRange()); } void WorldObject::AddToNotify(uint16 f) @@ -2970,14 +2958,9 @@ struct WorldObjectChangeAccumulator void WorldObject::BuildUpdate(UpdateDataMapType& data_map, UpdatePlayerSet& player_set) { - CellCoord p = Acore::ComputeCellCoord(GetPositionX(), GetPositionY()); - Cell cell(p); - cell.SetNoCreate(); WorldObjectChangeAccumulator notifier(*this, data_map, player_set); - TypeContainerVisitor player_notifier(notifier); - Map& map = *GetMap(); //we must build packets for all visible players - cell.Visit(p, player_notifier, map, *this, GetVisibilityRange() + VISIBILITY_COMPENSATION); + 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 a4fadafbd..62a9dfb41 100644 --- a/src/server/game/Entities/Object/Object.h +++ b/src/server/game/Entities/Object/Object.h @@ -1002,10 +1002,6 @@ public: [[nodiscard]] bool IsPermanentWorldObject() const { return m_isWorldObject; } [[nodiscard]] bool IsWorldObject() const; - template void VisitNearbyObject(float const& radius, NOTIFIER& notifier) const { if (IsInWorld()) GetMap()->VisitAll(GetPositionX(), GetPositionY(), radius, notifier); } - template void VisitNearbyGridObject(float const& radius, NOTIFIER& notifier) const { if (IsInWorld()) GetMap()->VisitGrid(GetPositionX(), GetPositionY(), radius, notifier); } - template void VisitNearbyWorldObject(float const& radius, NOTIFIER& notifier) const { if (IsInWorld()) GetMap()->VisitWorld(GetPositionX(), GetPositionY(), radius, notifier); } - [[nodiscard]] bool IsInWintergrasp() const { return GetMapId() == 571 && GetPositionX() > 3733.33331f && GetPositionX() < 5866.66663f && GetPositionY() > 1599.99999f && GetPositionY() < 4799.99997f; diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index da21caab9..a8abb89e1 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -7066,7 +7066,7 @@ void Player::SendMessageToSetInRange(WorldPacket* data, float dist, bool self, b if (includeMargin) dist += VISIBILITY_COMPENSATION; // pussywizard: to ensure everyone receives all important packets Acore::MessageDistDeliverer notifier(this, data, dist, false, skipped_rcvr); - VisitNearbyWorldObject(dist, notifier); + Cell::VisitWorldObjects(this, notifier, dist); } // pussywizard! @@ -7076,7 +7076,7 @@ void Player::SendMessageToSetInRange_OwnTeam(WorldPacket* data, float dist, bool GetSession()->SendPacket(data); Acore::MessageDistDeliverer notifier(this, data, dist, true); - VisitNearbyWorldObject(dist, notifier); + Cell::VisitWorldObjects(this, notifier, dist); } void Player::SendDirectMessage(WorldPacket* data) @@ -21528,7 +21528,7 @@ void Player::TextEmote(const std::string& text) std::list players; Acore::AnyPlayerInObjectRangeCheck checker(this, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE)); Acore::PlayerListSearcher searcher(this, players, checker); - this->VisitNearbyWorldObject(sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE), searcher); + Cell::VisitWorldObjects(this, searcher, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE)); for (auto const& itr : players) { @@ -23681,10 +23681,10 @@ void Player::UpdateObjectVisibility(bool forced, bool fromUpdate) void Player::UpdateVisibilityForPlayer(bool mapChange) { Acore::VisibleNotifier notifierNoLarge(*this, mapChange, false); // visit only objects which are not large; default distance - m_seer->VisitNearbyObject(GetSightRange() + VISIBILITY_INC_FOR_GOBJECTS, notifierNoLarge); + Cell::VisitAllObjects(m_seer, notifierNoLarge, GetSightRange() + VISIBILITY_INC_FOR_GOBJECTS); notifierNoLarge.SendToSelf(); Acore::VisibleNotifier notifierLarge(*this, mapChange, true); // visit only large objects; maximum distance - m_seer->VisitNearbyObject(MAX_VISIBILITY_DISTANCE, notifierLarge); + Cell::VisitAllObjects(m_seer, notifierLarge, GetSightRange()); notifierLarge.SendToSelf(); if (mapChange) diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 3bcb7ee58..997d399f6 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -16296,7 +16296,7 @@ Unit* Unit::SelectNearbyTarget(Unit* exclude, float dist) const std::list targets; Acore::AnyUnfriendlyUnitInObjectRangeCheck u_check(this, this, dist); Acore::UnitListSearcher searcher(this, targets, u_check); - VisitNearbyObject(dist, searcher); + Cell::VisitAllObjects(this, searcher, dist); // remove current target if (GetVictim()) @@ -16331,7 +16331,7 @@ Unit* Unit::SelectNearbyNoTotemTarget(Unit* exclude, float dist) const std::list targets; Acore::AnyUnfriendlyNoTotemUnitInObjectRangeCheck u_check(this, this, dist); Acore::UnitListSearcher searcher(this, targets, u_check); - VisitNearbyObject(dist, searcher); + Cell::VisitAllObjects(this, searcher, dist); // remove current target if (GetVictim()) @@ -18371,7 +18371,7 @@ void Unit::UpdateObjectVisibility(bool forced, bool /*fromUpdate*/) { Acore::AIRelocationNotifier notifier(*this); float radius = 60.0f; - VisitNearbyObject(radius, notifier); + Cell::VisitAllObjects(this, notifier, radius); } } } @@ -19744,10 +19744,10 @@ void Unit::ExecuteDelayedUnitRelocationEvent() } Acore::PlayerRelocationNotifier relocateNoLarge(*player, false); // visit only objects which are not large; default distance - viewPoint->VisitNearbyObject(player->GetSightRange() + VISIBILITY_INC_FOR_GOBJECTS, relocateNoLarge); + Cell::VisitAllObjects(viewPoint, relocateNoLarge, player->GetSightRange() + VISIBILITY_INC_FOR_GOBJECTS); relocateNoLarge.SendToSelf(); Acore::PlayerRelocationNotifier relocateLarge(*player, true); // visit only large objects; maximum distance - viewPoint->VisitNearbyObject(MAX_VISIBILITY_DISTANCE, relocateLarge); + Cell::VisitAllObjects(viewPoint, relocateLarge, MAX_VISIBILITY_DISTANCE); relocateLarge.SendToSelf(); } @@ -19778,10 +19778,10 @@ void Unit::ExecuteDelayedUnitRelocationEvent() } Acore::PlayerRelocationNotifier relocateNoLarge(*player, false); // visit only objects which are not large; default distance - viewPoint->VisitNearbyObject(player->GetSightRange() + VISIBILITY_INC_FOR_GOBJECTS, relocateNoLarge); + Cell::VisitAllObjects(viewPoint, relocateNoLarge, player->GetSightRange() + VISIBILITY_INC_FOR_GOBJECTS); relocateNoLarge.SendToSelf(); Acore::PlayerRelocationNotifier relocateLarge(*player, true); // visit only large objects; maximum distance - viewPoint->VisitNearbyObject(MAX_VISIBILITY_DISTANCE, relocateLarge); + Cell::VisitAllObjects(viewPoint, relocateLarge, MAX_VISIBILITY_DISTANCE); relocateLarge.SendToSelf(); this->AddToNotify(NOTIFY_AI_RELOCATION); @@ -19802,7 +19802,7 @@ void Unit::ExecuteDelayedUnitRelocationEvent() unit->m_last_notify_position.Relocate(unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ()); Acore::CreatureRelocationNotifier relocate(*unit); - unit->VisitNearbyObject(unit->GetVisibilityRange() + VISIBILITY_COMPENSATION, relocate); + Cell::VisitAllObjects(unit, relocate, unit->GetVisibilityRange() + VISIBILITY_COMPENSATION); this->AddToNotify(NOTIFY_AI_RELOCATION); } @@ -19816,7 +19816,7 @@ void Unit::ExecuteDelayedUnitAINotifyEvent() Acore::AIRelocationNotifier notifier(*this); float radius = 60.0f; - this->VisitNearbyObject(radius, notifier); + Cell::VisitAllObjects(this, notifier, radius); } void Unit::SetInFront(WorldObject const* target) diff --git a/src/server/game/Grids/Cells/Cell.h b/src/server/game/Grids/Cells/Cell.h index 2f0783357..f0266fa2f 100644 --- a/src/server/game/Grids/Cells/Cell.h +++ b/src/server/game/Grids/Cells/Cell.h @@ -92,11 +92,19 @@ struct Cell uint32 All; } data; - template void Visit(CellCoord const&, TypeContainerVisitor& visitor, Map&, WorldObject const&, float) const; - template void Visit(CellCoord const&, TypeContainerVisitor& visitor, Map&, float, float, float) const; + template void Visit(CellCoord const&, TypeContainerVisitor& visitor, Map&, WorldObject const& obj, float radius) const; + template void Visit(CellCoord const&, TypeContainerVisitor& visitor, Map&, float x, float y, float radius) const; static CellArea CalculateCellArea(float x, float y, float radius); + template static void VisitGridObjects(WorldObject const* obj, T& visitor, float radius, bool dont_load = true); + template static void VisitWorldObjects(WorldObject const* obj, T& visitor, float radius, bool dont_load = true); + template static void VisitAllObjects(WorldObject const* obj, T& visitor, float radius, bool dont_load = true); + + template static void VisitGridObjects(float x, float y, Map* map, T& visitor, float radius, bool dont_load = true); + template static void VisitWorldObjects(float x, float y, Map* map, T& visitor, float radius, bool dont_load = true); + template static void VisitAllObjects(float x, float y, Map* map, T& visitor, float radius, bool dont_load = true); + private: template void VisitCircle(TypeContainerVisitor&, 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 0c9f0e10d..2e945258c 100644 --- a/src/server/game/Grids/Cells/CellImpl.h +++ b/src/server/game/Grids/Cells/CellImpl.h @@ -48,8 +48,15 @@ inline CellArea Cell::CalculateCellArea(float x, float y, float radius) } template -inline void Cell::Visit(CellCoord const& standing_cell, TypeContainerVisitor& visitor, Map& map, float radius, float x_off, float y_off) const +inline void Cell::Visit(CellCoord const& standing_cell, TypeContainerVisitor& 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.GetCombatReach()); +} + +template +inline void Cell::Visit(CellCoord const& standing_cell, TypeContainerVisitor& visitor, Map& map, float x_off, float y_off, float radius) const{ if (!standing_cell.IsCoordValid()) return; @@ -105,14 +112,6 @@ inline void Cell::Visit(CellCoord const& standing_cell, TypeContainerVisitor -inline void Cell::Visit(CellCoord const& standing_cell, TypeContainerVisitor& 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 inline void Cell::VisitCircle(TypeContainerVisitor& visitor, Map& map, CellCoord const& begin_cell, CellCoord const& end_cell) const { @@ -164,4 +163,93 @@ inline void Cell::VisitCircle(TypeContainerVisitor& visitor, Map& } } } + +template +inline void Cell::VisitGridObjects(WorldObject const* center_obj, T& visitor, float radius, bool dont_load /*= true*/) +{ + CellCoord p(Acore::ComputeCellCoord(center_obj->GetPositionX(), center_obj->GetPositionY())); + Cell cell(p); + if (dont_load) + { + cell.SetNoCreate(); + } + + TypeContainerVisitor gnotifier(visitor); + cell.Visit(p, gnotifier, *center_obj->GetMap(), *center_obj, radius); +} + +template +inline void Cell::VisitWorldObjects(WorldObject const* center_obj, T& visitor, float radius, bool dont_load /*= true*/) +{ + CellCoord p(Acore::ComputeCellCoord(center_obj->GetPositionX(), center_obj->GetPositionY())); + Cell cell(p); + if (dont_load) + { + cell.SetNoCreate(); + } + + TypeContainerVisitor wnotifier(visitor); + cell.Visit(p, wnotifier, *center_obj->GetMap(), *center_obj, radius); +} + +template +inline void Cell::VisitAllObjects(WorldObject const* center_obj, T& visitor, float radius, bool dont_load /*= true*/) +{ + CellCoord p(Acore::ComputeCellCoord(center_obj->GetPositionX(), center_obj->GetPositionY())); + Cell cell(p); + if (dont_load) + { + cell.SetNoCreate(); + } + + TypeContainerVisitor wnotifier(visitor); + cell.Visit(p, wnotifier, *center_obj->GetMap(), *center_obj, radius); + TypeContainerVisitor gnotifier(visitor); + cell.Visit(p, gnotifier, *center_obj->GetMap(), *center_obj, radius); +} + +template +inline void Cell::VisitGridObjects(float x, float y, Map* map, T& visitor, float radius, bool dont_load /*= true*/) +{ + CellCoord p(Acore::ComputeCellCoord(x, y)); + Cell cell(p); + if (dont_load) + { + cell.SetNoCreate(); + } + + TypeContainerVisitor gnotifier(visitor); + cell.Visit(p, gnotifier, *map, x, y, radius); +} + +template +inline void Cell::VisitWorldObjects(float x, float y, Map* map, T& visitor, float radius, bool dont_load /*= true*/) +{ + CellCoord p(Acore::ComputeCellCoord(x, y)); + Cell cell(p); + if (dont_load) + { + cell.SetNoCreate(); + } + + TypeContainerVisitor wnotifier(visitor); + cell.Visit(p, wnotifier, *map, x, y, radius); +} + +template +inline void Cell::VisitAllObjects(float x, float y, Map* map, T& visitor, float radius, bool dont_load /*= true*/) +{ + CellCoord p(Acore::ComputeCellCoord(x, y)); + Cell cell(p); + if (dont_load) + { + cell.SetNoCreate(); + } + + TypeContainerVisitor wnotifier(visitor); + cell.Visit(p, wnotifier, *map, x, y, radius); + TypeContainerVisitor gnotifier(visitor); + cell.Visit(p, gnotifier, *map, x, y, radius); +} + #endif diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index bc7e7342e..ef21cfb3b 100644 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -2344,28 +2344,6 @@ char const* Map::GetMapName() const return i_mapEntry ? i_mapEntry->name[sWorld->GetDefaultDbcLocale()] : "UNNAMEDMAP\x0"; } -void Map::UpdateObjectVisibility(WorldObject* obj, Cell cell, CellCoord cellpair) -{ - cell.SetNoCreate(); - Acore::VisibleChangesNotifier notifier(*obj); - TypeContainerVisitor player_notifier(notifier); - cell.Visit(cellpair, player_notifier, *this, *obj, obj->GetVisibilityRange()); -} - -void Map::UpdateObjectsVisibilityFor(Player* player, Cell cell, CellCoord cellpair) -{ - Acore::VisibleNotifier notifier(*player, false, false); - - cell.SetNoCreate(); - TypeContainerVisitor world_notifier(notifier); - TypeContainerVisitor 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) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) diff --git a/src/server/game/Maps/Map.h b/src/server/game/Maps/Map.h index ede8d6bff..0de8325bf 100644 --- a/src/server/game/Maps/Map.h +++ b/src/server/game/Maps/Map.h @@ -406,9 +406,6 @@ public: 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); } @@ -440,10 +437,6 @@ public: void RemoveFromActive(T* obj); template void SwitchGridContainers(T* obj, bool on); - template void VisitAll(const float& x, const float& y, float radius, NOTIFIER& notifier); - template void VisitFirstFound(const float& x, const float& y, float radius, NOTIFIER& notifier); - template void VisitWorld(const float& x, const float& y, float radius, NOTIFIER& notifier); - template void VisitGrid(const float& x, const float& y, float radius, NOTIFIER& notifier); CreatureGroupHolderType CreatureGroupHolder; void UpdateIteratorBack(Player* player); @@ -812,55 +805,4 @@ inline void Map::Visit(Cell const& cell, TypeContainerVisitor& vis } } -template -inline void Map::VisitAll(float const& x, float const& y, float radius, NOTIFIER& notifier) -{ - CellCoord p(Acore::ComputeCellCoord(x, y)); - Cell cell(p); - cell.SetNoCreate(); - - TypeContainerVisitor world_object_notifier(notifier); - cell.Visit(p, world_object_notifier, *this, radius, x, y); - TypeContainerVisitor 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 -inline void Map::VisitFirstFound(const float& x, const float& y, float radius, NOTIFIER& notifier) -{ - CellCoord p(Acore::ComputeCellCoord(x, y)); - Cell cell(p); - cell.SetNoCreate(); - - TypeContainerVisitor world_object_notifier(notifier); - cell.Visit(p, world_object_notifier, *this, radius, x, y); - if (!notifier.i_object) - { - TypeContainerVisitor grid_object_notifier(notifier); - cell.Visit(p, grid_object_notifier, *this, radius, x, y); - } -} - -template -inline void Map::VisitWorld(const float& x, const float& y, float radius, NOTIFIER& notifier) -{ - CellCoord p(Acore::ComputeCellCoord(x, y)); - Cell cell(p); - cell.SetNoCreate(); - - TypeContainerVisitor world_object_notifier(notifier); - cell.Visit(p, world_object_notifier, *this, radius, x, y); -} - -template -inline void Map::VisitGrid(const float& x, const float& y, float radius, NOTIFIER& notifier) -{ - CellCoord p(Acore::ComputeCellCoord(x, y)); - Cell cell(p); - cell.SetNoCreate(); - - TypeContainerVisitor 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 8248803f7..63ddc7038 100644 --- a/src/server/game/OutdoorPvP/OutdoorPvP.cpp +++ b/src/server/game/OutdoorPvP/OutdoorPvP.cpp @@ -304,7 +304,7 @@ bool OPvPCapturePoint::Update(uint32 diff) std::list players; Acore::AnyPlayerInObjectRangeCheck checker(m_capturePoint, radius); Acore::PlayerListSearcher searcher(m_capturePoint, players, checker); - m_capturePoint->VisitNearbyWorldObject(radius, searcher); + Cell::VisitWorldObjects(m_capturePoint, searcher, radius); for (std::list::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 9a7ed0b0a..4edc754d9 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -2399,7 +2399,7 @@ void AuraEffect::HandleFeignDeath(AuraApplication const* aurApp, uint8 mode, boo UnitList targets; Acore::AnyUnfriendlyUnitInObjectRangeCheck u_check(target, target, target->GetVisibilityRange()); // no VISIBILITY_COMPENSATION, distance is enough Acore::UnitListSearcher searcher(target, targets, u_check); - target->VisitNearbyObject(target->GetVisibilityRange(), searcher); // no VISIBILITY_COMPENSATION, distance is enough + Cell::VisitAllObjects(target, searcher, target->GetMap()->GetVisibilityRange()); for (UnitList::iterator iter = targets.begin(); iter != targets.end(); ++iter) { if (!(*iter)->HasUnitState(UNIT_STATE_CASTING)) @@ -5206,7 +5206,7 @@ void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool Player* player = nullptr; Acore::AnyPlayerInObjectRangeCheck checker(target, 10.0f); Acore::PlayerSearcher searcher(target, player, checker); - target->VisitNearbyWorldObject(10.0f, searcher); + Cell::VisitWorldObjects(target, searcher, 10.0f); if( player && player->GetGUID() != target->GetGUID() ) target->CastSpell(player, 52921, true); diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp index 34e84f8df..eaf10a188 100644 --- a/src/server/game/Spells/Auras/SpellAuras.cpp +++ b/src/server/game/Spells/Auras/SpellAuras.cpp @@ -2652,7 +2652,7 @@ void UnitAura::FillTargetMap(std::map& targets, Unit* caster) targetList.push_back(GetUnitOwner()); Acore::AnyGroupedUnitInObjectRangeCheck u_check(GetUnitOwner(), GetUnitOwner(), radius, GetSpellInfo()->Effects[effIndex].Effect == SPELL_EFFECT_APPLY_AREA_AURA_RAID); Acore::UnitListSearcher searcher(GetUnitOwner(), targetList, u_check); - GetUnitOwner()->VisitNearbyObject(radius, searcher); + Cell::VisitAllObjects(GetUnitOwner(), searcher, radius); break; } case SPELL_EFFECT_APPLY_AREA_AURA_FRIEND: @@ -2660,14 +2660,14 @@ void UnitAura::FillTargetMap(std::map& targets, Unit* caster) targetList.push_back(GetUnitOwner()); Acore::AnyFriendlyUnitInObjectRangeCheck u_check(GetUnitOwner(), GetUnitOwner(), radius); Acore::UnitListSearcher searcher(GetUnitOwner(), targetList, u_check); - GetUnitOwner()->VisitNearbyObject(radius, searcher); + Cell::VisitAllObjects(GetUnitOwner(), searcher, radius); break; } case SPELL_EFFECT_APPLY_AREA_AURA_ENEMY: { Acore::AnyAoETargetUnitInObjectRangeCheck u_check(GetUnitOwner(), GetUnitOwner(), radius); // No GetCharmer in searcher Acore::UnitListSearcher searcher(GetUnitOwner(), targetList, u_check); - GetUnitOwner()->VisitNearbyObject(radius, searcher); + Cell::VisitAllObjects(GetUnitOwner(), searcher, radius); break; } case SPELL_EFFECT_APPLY_AREA_AURA_PET: @@ -2728,7 +2728,7 @@ void DynObjAura::FillTargetMap(std::map& targets, Unit* /*caster*/ { Acore::AnyFriendlyUnitInObjectRangeCheck u_check(GetDynobjOwner(), dynObjOwnerCaster, radius); Acore::UnitListSearcher searcher(GetDynobjOwner(), targetList, u_check); - GetDynobjOwner()->VisitNearbyObject(radius, searcher); + Cell::VisitAllObjects(GetDynobjOwner(), searcher, radius); } // pussywizard: TARGET_DEST_DYNOBJ_NONE is supposed to search for both friendly and unfriendly targets, so for any unit // what about EffectImplicitTargetA? @@ -2736,13 +2736,13 @@ void DynObjAura::FillTargetMap(std::map& targets, Unit* /*caster*/ { Acore::AnyAttackableUnitExceptForOriginalCasterInObjectRangeCheck u_check(GetDynobjOwner(), dynObjOwnerCaster, radius); Acore::UnitListSearcher searcher(GetDynobjOwner(), targetList, u_check); - GetDynobjOwner()->VisitNearbyObject(radius, searcher); + Cell::VisitAllObjects(GetDynobjOwner(), searcher, radius); } else { Acore::AnyAoETargetUnitInObjectRangeCheck u_check(GetDynobjOwner(), dynObjOwnerCaster, radius); Acore::UnitListSearcher 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 3b5eabcef..c4ccb765f 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -1896,18 +1896,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 world_object_notifier(searcher); - cell.Visit(p, world_object_notifier, map, radius + SPELL_SEARCHER_COMPENSATION, x, y); - } + Cell::VisitWorldObjects(x, y, map, searcher, radius); + if (searchInGrid) - { - TypeContainerVisitor grid_object_notifier(searcher); - cell.Visit(p, grid_object_notifier, map, radius + SPELL_SEARCHER_COMPENSATION, x, y); - } + Cell::VisitGridObjects(x, y, map, searcher, radius); } } diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 2dcf44482..bcddd8226 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -4297,7 +4297,7 @@ void Spell::EffectSanctuary(SpellEffIndex /*effIndex*/) UnitList targets; Acore::AnyUnfriendlyUnitInObjectRangeCheck u_check(unitTarget, unitTarget, unitTarget->GetVisibilityRange()); // no VISIBILITY_COMPENSATION, distance is enough Acore::UnitListSearcher searcher(unitTarget, targets, u_check); - unitTarget->VisitNearbyObject(unitTarget->GetVisibilityRange(), searcher); // no VISIBILITY_COMPENSATION, distance is enough + Cell::VisitAllObjects(unitTarget, searcher, unitTarget->GetVisibilityRange()); for (UnitList::iterator iter = targets.begin(); iter != targets.end(); ++iter) { if (!(*iter)->HasUnitState(UNIT_STATE_CASTING)) @@ -4943,7 +4943,7 @@ void Spell::EffectForceDeselect(SpellEffIndex /*effIndex*/) float dist = m_caster->GetVisibilityRange() + VISIBILITY_COMPENSATION; Acore::MessageDistDelivererToHostile notifier(m_caster, &data, dist); - m_caster->VisitNearbyWorldObject(dist, notifier); + Cell::VisitWorldObjects(m_caster, notifier, dist); // xinef: we should also force pets to remove us from current target Unit::AttackerSet attackerSet; @@ -4968,7 +4968,7 @@ void Spell::EffectForceDeselect(SpellEffIndex /*effIndex*/) UnitList targets; Acore::AnyUnfriendlyUnitInObjectRangeCheck u_check(m_caster, m_caster, m_caster->GetVisibilityRange()); // no VISIBILITY_COMPENSATION, distance is enough Acore::UnitListSearcher searcher(m_caster, targets, u_check); - m_caster->VisitNearbyObject(m_caster->GetVisibilityRange(), searcher); // no VISIBILITY_COMPENSATION, distance is enough + Cell::VisitAllObjects(m_caster, searcher, m_caster->GetVisibilityRange()); for (UnitList::iterator iter = targets.begin(); iter != targets.end(); ++iter) { if (!(*iter)->HasUnitState(UNIT_STATE_CASTING)) diff --git a/src/server/game/Texts/CreatureTextMgr.h b/src/server/game/Texts/CreatureTextMgr.h index 9f1d2feb3..62f6f3e60 100644 --- a/src/server/game/Texts/CreatureTextMgr.h +++ b/src/server/game/Texts/CreatureTextMgr.h @@ -239,7 +239,7 @@ void CreatureTextMgr::SendChatPacket(WorldObject* source, Builder const& builder dist = 250.0f; Acore::PlayerDistWorker > worker(source, dist, localizer); - source->VisitNearbyWorldObject(dist, worker); + 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 7f136b2cd..d69aa3342 100644 --- a/src/server/scripts/Commands/cs_debug.cpp +++ b/src/server/scripts/Commands/cs_debug.cpp @@ -918,7 +918,7 @@ public: Creature* passenger = nullptr; Acore::AllCreaturesOfEntryInRange check(handler->GetSession()->GetPlayer(), entry, 20.0f); Acore::CreatureSearcher 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 ab3c67100..5542d9e35 100644 --- a/src/server/scripts/Commands/cs_misc.cpp +++ b/src/server/scripts/Commands/cs_misc.cpp @@ -2233,9 +2233,7 @@ public: Acore::RespawnDo u_do; Acore::WorldObjectWorker worker(player, u_do); - - TypeContainerVisitor, GridTypeMapContainer > obj_worker(worker); - cell.Visit(p, obj_worker, *player->GetMap(), *player, player->GetGridActivationRange()); + 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 fec8d14cf..b06becdfe 100644 --- a/src/server/scripts/Commands/cs_mmaps.cpp +++ b/src/server/scripts/Commands/cs_mmaps.cpp @@ -263,18 +263,11 @@ public: float radius = 40.0f; WorldObject* object = handler->GetSession()->GetPlayer(); - CellCoord pair(Acore::ComputeCellCoord(object->GetPositionX(), object->GetPositionY())); - Cell cell(pair); - cell.SetNoCreate(); - + // Get Creatures std::list creatureList; - Acore::AnyUnitInObjectRangeCheck go_check(object, radius); Acore::CreatureListSearcher go_search(object, creatureList, go_check); - TypeContainerVisitor, 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/ZulAman/boss_akilzon.cpp b/src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp index 7062ea71d..a1349a77f 100644 --- a/src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp +++ b/src/server/scripts/EasternKingdoms/ZulAman/boss_akilzon.cpp @@ -149,22 +149,11 @@ public: for (uint8 i = 2; i < StormCount; ++i) bp0 *= 2; - CellCoord p(Acore::ComputeCellCoord(me->GetPositionX(), me->GetPositionY())); - Cell cell(p); - cell.SetNoCreate(); - std::list tempUnitMap; - { - Acore::AnyAoETargetUnitInObjectRangeCheck u_check(me, me, SIZE_OF_GRIDS); - Acore::UnitListSearcher searcher(me, tempUnitMap, u_check); - - TypeContainerVisitor, WorldTypeMapContainer > world_unit_searcher(searcher); - TypeContainerVisitor, GridTypeMapContainer > grid_unit_searcher(searcher); - - cell.Visit(p, world_unit_searcher, *me->GetMap(), *me, SIZE_OF_GRIDS); - cell.Visit(p, grid_unit_searcher, *me->GetMap(), *me, SIZE_OF_GRIDS); - } + Acore::AnyAoETargetUnitInObjectRangeCheck u_check(me, me, SIZE_OF_GRIDS); + Acore::UnitListSearcher searcher(me, tempUnitMap, u_check); + Cell::VisitAllObjects(me, searcher, SIZE_OF_GRIDS); // deal damage for (std::list::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 ab5087464..2ea08e532 100644 --- a/src/server/scripts/EasternKingdoms/ZulAman/boss_janalai.cpp +++ b/src/server/scripts/EasternKingdoms/ZulAman/boss_janalai.cpp @@ -223,18 +223,9 @@ public: float x, y, z; me->GetPosition(x, y, z); - { - CellCoord pair(Acore::ComputeCellCoord(x, y)); - Cell cell(pair); - cell.SetNoCreate(); - - Acore::AllCreaturesOfEntryInRange check(me, NPC_EGG, 100); - Acore::CreatureListSearcher searcher(me, templist, check); - - TypeContainerVisitor, GridTypeMapContainer> cSearcher(searcher); - - cell.Visit(pair, cSearcher, *me->GetMap(), *me, me->GetGridActivationRange()); - } + Acore::AllCreaturesOfEntryInRange check(me, NPC_EGG, 100); + Acore::CreatureListSearcher searcher(me, templist, check); + Cell::VisitGridObjects(me, searcher, me->GetGridActivationRange()); //TC_LOG_ERROR("scripts", "Eggs %d at middle", templist.size()); if (templist.empty()) @@ -256,18 +247,10 @@ public: float x, y, z; me->GetPosition(x, y, z); - { - CellCoord pair(Acore::ComputeCellCoord(x, y)); - Cell cell(pair); - cell.SetNoCreate(); + Acore::AllCreaturesOfEntryInRange check(me, NPC_FIRE_BOMB, 100); + Acore::CreatureListSearcher searcher(me, templist, check); + Cell::VisitGridObjects(me, searcher, me->GetGridActivationRange()); - Acore::AllCreaturesOfEntryInRange check(me, NPC_FIRE_BOMB, 100); - Acore::CreatureListSearcher searcher(me, templist, check); - - TypeContainerVisitor, GridTypeMapContainer> cSearcher(searcher); - - cell.Visit(pair, cSearcher, *me->GetMap(), *me, me->GetGridActivationRange()); - } for (std::list::const_iterator i = templist.begin(); i != templist.end(); ++i) { (*i)->CastSpell(*i, SPELL_FIRE_BOMB_DAMAGE, true); @@ -517,18 +500,9 @@ public: float x, y, z; me->GetPosition(x, y, z); - { - CellCoord pair(Acore::ComputeCellCoord(x, y)); - Cell cell(pair); - cell.SetNoCreate(); - - Acore::AllCreaturesOfEntryInRange check(me, 23817, 50); - Acore::CreatureListSearcher searcher(me, templist, check); - - TypeContainerVisitor, GridTypeMapContainer> cSearcher(searcher); - - cell.Visit(pair, cSearcher, *(me->GetMap()), *me, me->GetGridActivationRange()); - } + Acore::AllCreaturesOfEntryInRange check(me, 23817, 50); + Acore::CreatureListSearcher searcher(me, templist, check); + Cell::VisitGridObjects(me, searcher, me->GetGridActivationRange()); //TC_LOG_ERROR("scripts", "Eggs %d at %d", templist.size(), side); diff --git a/src/server/scripts/Events/brewfest.cpp b/src/server/scripts/Events/brewfest.cpp index fbc4cfdc0..921c56252 100644 --- a/src/server/scripts/Events/brewfest.cpp +++ b/src/server/scripts/Events/brewfest.cpp @@ -1109,7 +1109,7 @@ public: Player* player = nullptr; Acore::AnyPlayerInObjectRangeCheck checker(me, 2.0f); Acore::PlayerSearcher searcher(me, player, checker); - me->VisitNearbyWorldObject(2.0f, searcher); + Cell::VisitWorldObjects(me, searcher, 2.0f); if (player) { player->CastSpell(player, SPELL_DRUNKEN_MASTER, true); diff --git a/src/server/scripts/Events/hallows_end.cpp b/src/server/scripts/Events/hallows_end.cpp index ac976f7d3..b2300deba 100644 --- a/src/server/scripts/Events/hallows_end.cpp +++ b/src/server/scripts/Events/hallows_end.cpp @@ -812,7 +812,7 @@ public: std::list players; Acore::AnyPlayerInObjectRangeCheck checker(me, radius); Acore::PlayerListSearcher searcher(me, players, checker); - me->VisitNearbyWorldObject(radius, searcher); + Cell::VisitWorldObjects(me, searcher, radius); for (std::list::const_iterator itr = players.begin(); itr != players.end(); ++itr) { diff --git a/src/server/scripts/Events/love_in_air.cpp b/src/server/scripts/Events/love_in_air.cpp index 2bc4ffc0d..caba2c2de 100644 --- a/src/server/scripts/Events/love_in_air.cpp +++ b/src/server/scripts/Events/love_in_air.cpp @@ -727,7 +727,7 @@ public: std::list playerList; Acore::AnyPlayerInObjectRangeCheck checker(target, INTERACTION_DISTANCE * 2); Acore::PlayerListSearcher searcher(target, playerList, checker); - target->VisitNearbyWorldObject(INTERACTION_DISTANCE * 2, searcher); + Cell::VisitWorldObjects(target, searcher, INTERACTION_DISTANCE * 2); for (std::list::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/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp index bb38d2872..b1c136941 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp @@ -888,17 +888,12 @@ void hyjalAI::JustDied(Unit* /*killer*/) void hyjalAI::HideNearPos(float x, float y) { - CellCoord pair(Acore::ComputeCellCoord(x, y)); - Cell cell(pair); - cell.SetNoCreate(); - // First get all creatures. std::list creatures; Acore::AllFriendlyCreaturesInGrid creature_check(me); Acore::CreatureListSearcher creature_searcher(me, creatures, creature_check); - TypeContainerVisitor , GridTypeMapContainer> creature_visitor(creature_searcher); - cell.Visit(pair, creature_visitor, *(me->GetMap()), *me, me->GetGridActivationRange()); + Cell::VisitGridObjects(x, y, me->GetMap(), creature_searcher, me->GetGridActivationRange()); if (!creatures.empty()) { @@ -912,14 +907,9 @@ void hyjalAI::HideNearPos(float x, float y) void hyjalAI::RespawnNearPos(float x, float y) { - CellCoord p(Acore::ComputeCellCoord(x, y)); - Cell cell(p); - cell.SetNoCreate(); - Acore::RespawnDo u_do; Acore::WorldObjectWorker worker(me, u_do); - TypeContainerVisitor, GridTypeMapContainer > obj_worker(worker); - cell.Visit(p, obj_worker, *me->GetMap(), *me, me->GetGridActivationRange()); + Cell::VisitGridObjects(x, y, me->GetMap(), worker, me->GetGridActivationRange()); } void hyjalAI::WaypointReached(uint32 waypointId) @@ -943,19 +933,11 @@ void hyjalAI::WaypointReached(uint32 waypointId) } //do some talking //all alive guards walk near here - CellCoord pair(Acore::ComputeCellCoord(me->GetPositionX(), me->GetPositionY())); - Cell cell(pair); - cell.SetNoCreate(); - // First get all creatures. std::list creatures; Acore::AllFriendlyCreaturesInGrid creature_check(me); Acore::CreatureListSearcher creature_searcher(me, creatures, creature_check); - TypeContainerVisitor - , - 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()) { @@ -984,18 +966,10 @@ void hyjalAI::DoOverrun(uint32 faction, const uint32 diff) { if (TeleportTimer <= diff) { - CellCoord pair(Acore::ComputeCellCoord(me->GetPositionX(), me->GetPositionY())); - Cell cell(pair); - cell.SetNoCreate(); - std::list creatures; Acore::AllFriendlyCreaturesInGrid creature_check(me); Acore::CreatureListSearcher creature_searcher(me, creatures, creature_check); - TypeContainerVisitor - , - 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/RazorfenDowns/razorfen_downs.cpp b/src/server/scripts/Kalimdor/RazorfenDowns/razorfen_downs.cpp index d0490c019..8d5ce5448 100644 --- a/src/server/scripts/Kalimdor/RazorfenDowns/razorfen_downs.cpp +++ b/src/server/scripts/Kalimdor/RazorfenDowns/razorfen_downs.cpp @@ -182,7 +182,7 @@ public: std::list ClusterList; Acore::AllWorldObjectsInRange objects(me, 50.0f); Acore::WorldObjectListSearcher searcher(me, ClusterList, objects); - me->VisitNearbyObject(50.0f, searcher); + Cell::VisitAllObjects(me, searcher, 50.0f); for (std::list::const_iterator itr = ClusterList.begin(); itr != ClusterList.end(); ++itr) { if (Player* player = (*itr)->ToPlayer()) diff --git a/src/server/scripts/Kalimdor/ZulFarrak/instance_zulfarrak.cpp b/src/server/scripts/Kalimdor/ZulFarrak/instance_zulfarrak.cpp index ab8800ddf..13515bbe3 100644 --- a/src/server/scripts/Kalimdor/ZulFarrak/instance_zulfarrak.cpp +++ b/src/server/scripts/Kalimdor/ZulFarrak/instance_zulfarrak.cpp @@ -141,7 +141,7 @@ public: std::list cagesList; Acore::AllWorldObjectsInRange objects(GetCaster(), 15.0f); Acore::WorldObjectListSearcher searcher(GetCaster(), cagesList, objects); - GetCaster()->VisitNearbyObject(15.0f, searcher); + Cell::VisitAllObjects(GetCaster(), searcher, 15.0f); for (std::list::const_iterator itr = cagesList.begin(); itr != cagesList.end(); ++itr) { if (GameObject* go = (*itr)->ToGameObject()) diff --git a/src/server/scripts/Kalimdor/zone_moonglade.cpp b/src/server/scripts/Kalimdor/zone_moonglade.cpp index 96d3b2b6c..0a36f8f71 100644 --- a/src/server/scripts/Kalimdor/zone_moonglade.cpp +++ b/src/server/scripts/Kalimdor/zone_moonglade.cpp @@ -313,7 +313,7 @@ public: std::list playerOnQuestList; Acore::AnyPlayerInObjectRangeCheck checker(me, 5.0f); Acore::PlayerListSearcher searcher(me, playerOnQuestList, checker); - me->VisitNearbyWorldObject(5.0f, searcher); + Cell::VisitWorldObjects(me, searcher, 5.0f); for (std::list::const_iterator itr = playerOnQuestList.begin(); itr != playerOnQuestList.end(); ++itr) { // Check if found player target has active quest 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 2076d3f7c..504f3b8cb 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp @@ -687,7 +687,7 @@ public: // Reset The Frozen Throne gameobjects FrozenThroneResetWorker reset; Acore::GameObjectWorker worker(me, reset); - me->VisitNearbyGridObject(333.0f, worker); + Cell::VisitGridObjects(me, worker, 333.0f); me->AddAura(SPELL_EMOTE_SIT_NO_SHEATH, me); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp index 67887ff95..0f50d8139 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp @@ -206,7 +206,7 @@ public: bool Execute(uint64 /*currTime*/, uint32 /*diff*/) override { Acore::CreatureWorker worker(_creature, *this); - _creature->VisitNearbyGridObject(333.0f, worker); + Cell::VisitGridObjects(_creature, worker, 333.0f); _creature->AI()->Reset(); _creature->setActive(false); return true; @@ -526,7 +526,7 @@ public: std::list archmages; RisenArchmageCheck check; Acore::CreatureListSearcher searcher(me, archmages, check); - me->VisitNearbyGridObject(100.0f, searcher); + Cell::VisitGridObjects(me, searcher, 100.0f); for (std::list::iterator itr = archmages.begin(); itr != archmages.end(); ++itr) (*itr)->AI()->DoAction(ACTION_ENTER_COMBAT); } diff --git a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp index b72d788a5..1261cfef3 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp @@ -841,7 +841,7 @@ public: std::list temp; FrostwingVrykulSearcher check(me, 150.0f); Acore::CreatureListSearcher searcher(me, temp, check); - me->VisitNearbyGridObject(150.0f, searcher); + Cell::VisitGridObjects(me, searcher, 150.0f); _aliveTrash.clear(); for (std::list::iterator itr = temp.begin(); itr != temp.end(); ++itr) @@ -886,14 +886,14 @@ public: Player* player = nullptr; Acore::AnyPlayerInObjectRangeCheck check(me, 140.0f); Acore::PlayerSearcher searcher(me, player, check); - me->VisitNearbyWorldObject(140.0f, searcher); + Cell::VisitWorldObjects(me, searcher, 140.0f); // wipe if (!player || me->GetExactDist(4357.0f, 2606.0f, 350.0f) > 125.0f) { //Talk(SAY_CROK_DEATH); FrostwingGauntletRespawner respawner; Acore::CreatureWorker worker(me, respawner); - me->VisitNearbyGridObject(333.0f, worker); + Cell::VisitGridObjects(me, worker, 333.0f); return; } } @@ -1363,7 +1363,7 @@ public: Creature* target = nullptr; Acore::MostHPMissingInRange u_check(me, 60.0f, 0); Acore::CreatureLastSearcher searcher(me, target, u_check); - me->VisitNearbyGridObject(60.0f, searcher); + Cell::VisitGridObjects(me, searcher, 60.0f); return target; } }; @@ -2333,7 +2333,7 @@ public: { FrostwingGauntletRespawner respawner; Acore::CreatureWorker worker(crok, respawner); - crok->VisitNearbyGridObject(333.0f, worker); + Cell::VisitGridObjects(crok, worker, 333.0f); return true; } else diff --git a/src/server/scripts/Northrend/Naxxramas/instance_naxxramas.cpp b/src/server/scripts/Northrend/Naxxramas/instance_naxxramas.cpp index c50c310fa..a6c46b526 100644 --- a/src/server/scripts/Northrend/Naxxramas/instance_naxxramas.cpp +++ b/src/server/scripts/Northrend/Naxxramas/instance_naxxramas.cpp @@ -1198,7 +1198,7 @@ public: Unit* target = nullptr; Acore::AnyUnfriendlyUnitInObjectRangeCheck u_check(me, me, 0.5f); Acore::UnitLastSearcher searcher(me, target, u_check); - me->VisitNearbyObject(1.5f, searcher); + Cell::VisitAllObjects(me, searcher, 1.5f); if (target) { me->CastSpell(me, SPELL_FROGGER_EXPLODE, true); 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 75543d884..7deae1dbd 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp @@ -1711,7 +1711,7 @@ public: std::list targetList; Acore::WorldObjectSpellAreaTargetCheck check(99, GetExplTargetDest(), GetCaster(), GetCaster(), GetSpellInfo(), TARGET_CHECK_DEFAULT, nullptr); Acore::WorldObjectListSearcher 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 = nullptr; for (std::list::iterator itr = targetList.begin(); itr != targetList.end(); ++itr) diff --git a/src/server/scripts/Northrend/zone_dragonblight.cpp b/src/server/scripts/Northrend/zone_dragonblight.cpp index f1c282bd6..3a413ae7e 100644 --- a/src/server/scripts/Northrend/zone_dragonblight.cpp +++ b/src/server/scripts/Northrend/zone_dragonblight.cpp @@ -774,7 +774,7 @@ public: go->Delete(); WretchedGhoulCleaner cleaner; Acore::CreatureWorker worker(me, cleaner); - me->VisitNearbyGridObject(150.0f, worker); + Cell::VisitGridObjects(me, worker, 150.0f); } void Reset() override @@ -988,7 +988,7 @@ public: { WretchedGhoulCleaner cleaner; Acore::CreatureWorker worker(me, cleaner); - me->VisitNearbyGridObject(150.0f, worker); + Cell::VisitGridObjects(me, worker, 150.0f); if (Creature* c = me->FindNearestCreature(NPC_SAC_LIGHTS_VENGEANCE, 150.0f, true)) if (Creature* v = me->FindNearestCreature(NPC_SAC_VEGARD_1, 50.0f, true)) diff --git a/src/server/scripts/Outland/zone_blades_edge_mountains.cpp b/src/server/scripts/Outland/zone_blades_edge_mountains.cpp index ed28fcbd9..f5e04a621 100644 --- a/src/server/scripts/Outland/zone_blades_edge_mountains.cpp +++ b/src/server/scripts/Outland/zone_blades_edge_mountains.cpp @@ -699,7 +699,7 @@ public: std::list ClusterList; Acore::AllWorldObjectsInRange objects(me, searchDistance); Acore::WorldObjectListSearcher searcher(me, ClusterList, objects); - me->VisitNearbyObject(searchDistance, searcher); + Cell::VisitAllObjects(me, searcher, searchDistance); for (std::list::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 15516e30a..b88f03018 100644 --- a/src/server/scripts/Pet/pet_dk.cpp +++ b/src/server/scripts/Pet/pet_dk.cpp @@ -157,7 +157,7 @@ public: std::list targets; Acore::AnyUnfriendlyUnitInObjectRangeCheck u_check(me, me, 50); Acore::UnitListSearcher searcher(me, targets, u_check); - me->VisitNearbyObject(50, searcher); + Cell::VisitAllObjects(me, searcher, 50.0f); for (std::list::const_iterator iter = targets.begin(); iter != targets.end(); ++iter) if ((*iter)->GetAura(SPELL_DK_SUMMON_GARGOYLE_1, me->GetOwnerGUID())) { diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index e801ecaa8..5533cb1af 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -1721,9 +1721,15 @@ public: // search for nearby enemy corpse in range Acore::AnyDeadUnitSpellTargetInRangeCheck check(caster, max_range, GetSpellInfo(), TARGET_CHECK_CORPSE); Acore::WorldObjectSearcher 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_hunter.cpp b/src/server/scripts/Spells/spell_hunter.cpp index 86e502c18..2f44fad97 100644 --- a/src/server/scripts/Spells/spell_hunter.cpp +++ b/src/server/scripts/Spells/spell_hunter.cpp @@ -979,9 +979,15 @@ public: // search for nearby enemy corpse in range Acore::AnyDeadUnitSpellTargetInRangeCheck check(caster, max_range, GetSpellInfo(), TARGET_CHECK_ENEMY); Acore::WorldObjectSearcher 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 f9b2ab9e8..49fde3a2a 100644 --- a/src/server/scripts/Spells/spell_quest.cpp +++ b/src/server/scripts/Spells/spell_quest.cpp @@ -2428,7 +2428,7 @@ public: std::list playerList; Acore::AnyPlayerInObjectRangeCheck checker(caster, 65.0f); Acore::PlayerListSearcher searcher(caster, playerList, checker); - caster->VisitNearbyWorldObject(65.0f, searcher); + Cell::VisitWorldObjects(caster, searcher, 65.0f); for (std::list::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)) diff --git a/src/server/scripts/World/go_scripts.cpp b/src/server/scripts/World/go_scripts.cpp index b25478a20..3163c714f 100644 --- a/src/server/scripts/World/go_scripts.cpp +++ b/src/server/scripts/World/go_scripts.cpp @@ -351,7 +351,7 @@ public: std::list players; Acore::AnyPlayerExactPositionInGameObjectRangeCheck checker(go, 0.3f); Acore::PlayerListSearcher searcher(go, players, checker); - go->VisitNearbyWorldObject(0.3f, searcher); + Cell::VisitWorldObjects(go, searcher, 0.3f); if (players.size() > 0) { @@ -398,7 +398,7 @@ public: std::list players; Acore::AnyPlayerExactPositionInGameObjectRangeCheck checker(go, 0.3f); Acore::PlayerListSearcher searcher(go, players, checker); - go->VisitNearbyWorldObject(0.3f, searcher); + Cell::VisitWorldObjects(go, searcher, 0.3f); if (players.size() > 0) {