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 <shauren.trinity@gmail.com>
Co-Authored-By: SilverIce <slifeleaf@gmail.com>

* Update CellImpl.h

* w

* more more brackets

* ew

* fix build
This commit is contained in:
Kitzunu
2021-06-03 05:27:51 +02:00
committed by GitHub
parent cc28cf6bf0
commit 7152ddc82c
46 changed files with 238 additions and 361 deletions
+1 -1
View File
@@ -73,7 +73,7 @@ void TotemAI::UpdateAI(uint32 /*diff*/)
victim = nullptr; victim = nullptr;
Acore::NearestAttackableUnitInObjectRangeCheck u_check(me, me, max_range); Acore::NearestAttackableUnitInObjectRangeCheck u_check(me, me, max_range);
Acore::UnitLastSearcher<Acore::NearestAttackableUnitInObjectRangeCheck> checker(me, victim, u_check); Acore::UnitLastSearcher<Acore::NearestAttackableUnitInObjectRangeCheck> checker(me, victim, u_check);
me->VisitNearbyObject(max_range, checker); Cell::VisitAllObjects(me, checker, max_range);
} }
if (!victim && me->GetCharmerOrOwnerOrSelf()->IsInCombat()) if (!victim && me->GetCharmerOrOwnerOrSelf()->IsInCombat())
@@ -381,7 +381,7 @@ Unit* ScriptedAI::DoSelectLowestHpFriendly(float range, uint32 minHPDiff)
Unit* unit = nullptr; Unit* unit = nullptr;
Acore::MostHPMissingInRange u_check(me, range, minHPDiff); Acore::MostHPMissingInRange u_check(me, range, minHPDiff);
Acore::UnitLastSearcher<Acore::MostHPMissingInRange> searcher(me, unit, u_check); Acore::UnitLastSearcher<Acore::MostHPMissingInRange> searcher(me, unit, u_check);
me->VisitNearbyObject(range, searcher); Cell::VisitAllObjects(me, searcher, range);
return unit; return unit;
} }
@@ -391,7 +391,7 @@ std::list<Creature*> ScriptedAI::DoFindFriendlyCC(float range)
std::list<Creature*> list; std::list<Creature*> list;
Acore::FriendlyCCedInRange u_check(me, range); Acore::FriendlyCCedInRange u_check(me, range);
Acore::CreatureListSearcher<Acore::FriendlyCCedInRange> searcher(me, list, u_check); Acore::CreatureListSearcher<Acore::FriendlyCCedInRange> searcher(me, list, u_check);
me->VisitNearbyObject(range, searcher); Cell::VisitAllObjects(me, searcher, range);
return list; return list;
} }
@@ -400,7 +400,7 @@ std::list<Creature*> ScriptedAI::DoFindFriendlyMissingBuff(float range, uint32 u
std::list<Creature*> list; std::list<Creature*> list;
Acore::FriendlyMissingBuffInRange u_check(me, range, uiSpellid); Acore::FriendlyMissingBuffInRange u_check(me, range, uiSpellid);
Acore::CreatureListSearcher<Acore::FriendlyMissingBuffInRange> searcher(me, list, u_check); Acore::CreatureListSearcher<Acore::FriendlyMissingBuffInRange> searcher(me, list, u_check);
me->VisitNearbyObject(range, searcher); Cell::VisitAllObjects(me, searcher, range);
return list; return list;
} }
@@ -408,15 +408,10 @@ Player* ScriptedAI::GetPlayerAtMinimumRange(float minimumRange)
{ {
Player* player = nullptr; Player* player = nullptr;
CellCoord pair(Acore::ComputeCellCoord(me->GetPositionX(), me->GetPositionY()));
Cell cell(pair);
cell.SetNoCreate();
Acore::PlayerAtMinimumRangeAway check(me, minimumRange); Acore::PlayerAtMinimumRangeAway check(me, minimumRange);
Acore::PlayerSearcher<Acore::PlayerAtMinimumRangeAway> searcher(me, player, check); Acore::PlayerSearcher<Acore::PlayerAtMinimumRangeAway> searcher(me, player, check);
TypeContainerVisitor<Acore::PlayerSearcher<Acore::PlayerAtMinimumRangeAway>, GridTypeMapContainer> visitor(searcher);
cell.Visit(pair, visitor, *me->GetMap(), *me, minimumRange); Cell::VisitWorldObjects(me, searcher, minimumRange);
return player; return player;
} }
@@ -3881,7 +3881,7 @@ ObjectList* SmartScript::GetWorldObjectsInDist(float dist)
{ {
Acore::AllWorldObjectsInRange u_check(obj, dist); Acore::AllWorldObjectsInRange u_check(obj, dist);
Acore::WorldObjectListSearcher<Acore::AllWorldObjectsInRange> searcher(obj, *targets, u_check); Acore::WorldObjectListSearcher<Acore::AllWorldObjectsInRange> searcher(obj, *targets, u_check);
obj->VisitNearbyObject(dist, searcher); Cell::VisitAllObjects(obj, searcher, dist);
} }
return targets; return targets;
} }
@@ -4864,7 +4864,7 @@ Unit* SmartScript::DoSelectLowestHpFriendly(float range, uint32 MinHPDiff)
Acore::MostHPMissingInRange u_check(me, range, MinHPDiff); Acore::MostHPMissingInRange u_check(me, range, MinHPDiff);
Acore::UnitLastSearcher<Acore::MostHPMissingInRange> searcher(me, unit, u_check); Acore::UnitLastSearcher<Acore::MostHPMissingInRange> searcher(me, unit, u_check);
me->VisitNearbyObject(range, searcher); Cell::VisitGridObjects(me, searcher, range);
return unit; return unit;
} }
@@ -4875,7 +4875,7 @@ void SmartScript::DoFindFriendlyCC(std::list<Creature*>& _list, float range)
Acore::FriendlyCCedInRange u_check(me, range); Acore::FriendlyCCedInRange u_check(me, range);
Acore::CreatureListSearcher<Acore::FriendlyCCedInRange> searcher(me, _list, u_check); Acore::CreatureListSearcher<Acore::FriendlyCCedInRange> searcher(me, _list, u_check);
me->VisitNearbyObject(range, searcher); Cell::VisitGridObjects(me, searcher, range);
} }
void SmartScript::DoFindFriendlyMissingBuff(std::list<Creature*>& list, float range, uint32 spellid) void SmartScript::DoFindFriendlyMissingBuff(std::list<Creature*>& list, float range, uint32 spellid)
@@ -4885,7 +4885,7 @@ void SmartScript::DoFindFriendlyMissingBuff(std::list<Creature*>& list, float ra
Acore::FriendlyMissingBuffInRange u_check(me, range, spellid); Acore::FriendlyMissingBuffInRange u_check(me, range, spellid);
Acore::CreatureListSearcher<Acore::FriendlyMissingBuffInRange> searcher(me, list, u_check); Acore::CreatureListSearcher<Acore::FriendlyMissingBuffInRange> searcher(me, list, u_check);
me->VisitNearbyObject(range, searcher); Cell::VisitGridObjects(me, searcher, range);
} }
Unit* SmartScript::DoFindClosestFriendlyInRange(float range, bool playerOnly) Unit* SmartScript::DoFindClosestFriendlyInRange(float range, bool playerOnly)
@@ -4896,7 +4896,7 @@ Unit* SmartScript::DoFindClosestFriendlyInRange(float range, bool playerOnly)
Unit* unit = nullptr; Unit* unit = nullptr;
Acore::AnyFriendlyNotSelfUnitInObjectRangeCheck u_check(me, me, range, playerOnly); Acore::AnyFriendlyNotSelfUnitInObjectRangeCheck u_check(me, me, range, playerOnly);
Acore::UnitLastSearcher<Acore::AnyFriendlyNotSelfUnitInObjectRangeCheck> searcher(me, unit, u_check); Acore::UnitLastSearcher<Acore::AnyFriendlyNotSelfUnitInObjectRangeCheck> searcher(me, unit, u_check);
me->VisitNearbyObject(range, searcher); Cell::VisitAllObjects(me, searcher, range);
return unit; return unit;
} }
@@ -715,7 +715,7 @@ void AchievementMgr::SendAchievementEarned(AchievementEntry const* achievement)
Acore::LocalizedPacketDo<Acore::AchievementChatBuilder> say_do(say_builder); Acore::LocalizedPacketDo<Acore::AchievementChatBuilder> say_do(say_builder);
Acore::PlayerDistWorker<Acore::LocalizedPacketDo<Acore::AchievementChatBuilder> > say_worker(GetPlayer(), sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_SAY), say_do); Acore::PlayerDistWorker<Acore::LocalizedPacketDo<Acore::AchievementChatBuilder> > say_worker(GetPlayer(), sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_SAY), say_do);
TypeContainerVisitor<Acore::PlayerDistWorker<Acore::LocalizedPacketDo<Acore::AchievementChatBuilder> >, WorldTypeMapContainer > message(say_worker); TypeContainerVisitor<Acore::PlayerDistWorker<Acore::LocalizedPacketDo<Acore::AchievementChatBuilder> >, 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); WorldPacket data(SMSG_ACHIEVEMENT_EARNED, 8 + 4 + 8);
+1 -1
View File
@@ -1005,7 +1005,7 @@ bool BfCapturePoint::Update(uint32 diff)
std::list<Player*> players; std::list<Player*> players;
Acore::AnyPlayerInObjectRangeCheck checker(capturePoint, radius); Acore::AnyPlayerInObjectRangeCheck checker(capturePoint, radius);
Acore::PlayerListSearcher<Acore::AnyPlayerInObjectRangeCheck> searcher(capturePoint, players, checker); Acore::PlayerListSearcher<Acore::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) for (std::list<Player*>::iterator itr = players.begin(); itr != players.end(); ++itr)
if ((*itr)->IsOutdoorPvPActive()) if ((*itr)->IsOutdoorPvPActive())
+1 -1
View File
@@ -888,7 +888,7 @@ GameObject* ChatHandler::GetNearbyGameObject()
GameObject* obj = nullptr; GameObject* obj = nullptr;
Acore::NearestGameObjectCheck check(*pl); Acore::NearestGameObjectCheck check(*pl);
Acore::GameObjectLastSearcher<Acore::NearestGameObjectCheck> searcher(pl, obj, check); Acore::GameObjectLastSearcher<Acore::NearestGameObjectCheck> searcher(pl, obj, check);
pl->VisitNearbyGridObject(SIZE_OF_GRIDS, searcher); Cell::VisitGridObjects(pl, searcher, SIZE_OF_GRIDS);
return obj; return obj;
} }
+10 -52
View File
@@ -888,15 +888,10 @@ void Creature::DoFleeToGetAssistance()
{ {
Creature* creature = nullptr; Creature* creature = nullptr;
CellCoord p(Acore::ComputeCellCoord(GetPositionX(), GetPositionY()));
Cell cell(p);
cell.SetNoCreate();
Acore::NearestAssistCreatureInCreatureRangeCheck u_check(this, GetVictim(), radius); Acore::NearestAssistCreatureInCreatureRangeCheck u_check(this, GetVictim(), radius);
Acore::CreatureLastSearcher<Acore::NearestAssistCreatureInCreatureRangeCheck> searcher(this, creature, u_check); Acore::CreatureLastSearcher<Acore::NearestAssistCreatureInCreatureRangeCheck> searcher(this, creature, u_check);
TypeContainerVisitor<Acore::CreatureLastSearcher<Acore::NearestAssistCreatureInCreatureRangeCheck>, GridTypeMapContainer > grid_creature_searcher(searcher); Cell::VisitGridObjects(this, searcher, radius);
cell.Visit(p, grid_creature_searcher, *GetMap(), *this, radius);
SetNoSearchAssistance(true); SetNoSearchAssistance(true);
UpdateSpeed(MOVE_RUN, false); 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). // select nearest hostile unit within the given distance (regardless of threat list).
Unit* Creature::SelectNearestTarget(float dist, bool playerOnly /* = false */) const Unit* Creature::SelectNearestTarget(float dist, bool playerOnly /* = false */) const
{ {
CellCoord p(Acore::ComputeCellCoord(GetPositionX(), GetPositionY())); if (dist == 0.0f)
Cell cell(p); {
cell.SetNoCreate(); dist = MAX_VISIBILITY_DISTANCE;
}
Unit* target = nullptr; Unit* target = nullptr;
{
if (dist == 0.0f)
dist = MAX_SEARCHER_DISTANCE;
Acore::NearestHostileUnitCheck u_check(this, dist, playerOnly); Acore::NearestHostileUnitCheck u_check(this, dist, playerOnly);
Acore::UnitLastSearcher<Acore::NearestHostileUnitCheck> searcher(this, target, u_check); Acore::UnitLastSearcher<Acore::NearestHostileUnitCheck> searcher(this, target, u_check);
Cell::VisitAllObjects(this, searcher, dist);
TypeContainerVisitor<Acore::UnitLastSearcher<Acore::NearestHostileUnitCheck>, WorldTypeMapContainer > world_unit_searcher(searcher);
TypeContainerVisitor<Acore::UnitLastSearcher<Acore::NearestHostileUnitCheck>, GridTypeMapContainer > grid_unit_searcher(searcher);
cell.Visit(p, world_unit_searcher, *GetMap(), *this, dist);
cell.Visit(p, grid_unit_searcher, *GetMap(), *this, dist);
}
return target; return target;
} }
// select nearest hostile unit within the given attack distance (i.e. distance is ignored if > than ATTACK_DISTANCE), regardless of threat list. // 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 Unit* Creature::SelectNearestTargetInAttackDistance(float dist) const
{ {
CellCoord p(Acore::ComputeCellCoord(GetPositionX(), GetPositionY()));
Cell cell(p);
cell.SetNoCreate();
Unit* target = nullptr;
if (dist < ATTACK_DISTANCE) if (dist < ATTACK_DISTANCE)
dist = ATTACK_DISTANCE; dist = ATTACK_DISTANCE;
if (dist > MAX_SEARCHER_DISTANCE) if (dist > MAX_SEARCHER_DISTANCE)
dist = MAX_SEARCHER_DISTANCE; dist = MAX_SEARCHER_DISTANCE;
{ Unit* target = nullptr;
Acore::NearestHostileUnitInAttackDistanceCheck u_check(this, dist); Acore::NearestHostileUnitInAttackDistanceCheck u_check(this, dist);
Acore::UnitLastSearcher<Acore::NearestHostileUnitInAttackDistanceCheck> searcher(this, target, u_check); Acore::UnitLastSearcher<Acore::NearestHostileUnitInAttackDistanceCheck> searcher(this, target, u_check);
Cell::VisitAllObjects(this, searcher, std::max(dist, ATTACK_DISTANCE));
TypeContainerVisitor<Acore::UnitLastSearcher<Acore::NearestHostileUnitInAttackDistanceCheck>, WorldTypeMapContainer > world_unit_searcher(searcher);
TypeContainerVisitor<Acore::UnitLastSearcher<Acore::NearestHostileUnitInAttackDistanceCheck>, GridTypeMapContainer > grid_unit_searcher(searcher);
cell.Visit(p, world_unit_searcher, *GetMap(), *this, dist);
cell.Visit(p, grid_unit_searcher, *GetMap(), *this, dist);
}
return target; return target;
} }
@@ -2154,18 +2127,9 @@ void Creature::CallAssistance()
{ {
std::list<Creature*> assistList; std::list<Creature*> assistList;
{
CellCoord p(Acore::ComputeCellCoord(GetPositionX(), GetPositionY()));
Cell cell(p);
cell.SetNoCreate();
Acore::AnyAssistCreatureInRangeCheck u_check(this, GetVictim(), radius); Acore::AnyAssistCreatureInRangeCheck u_check(this, GetVictim(), radius);
Acore::CreatureListSearcher<Acore::AnyAssistCreatureInRangeCheck> searcher(this, assistList, u_check); Acore::CreatureListSearcher<Acore::AnyAssistCreatureInRangeCheck> searcher(this, assistList, u_check);
Cell::VisitGridObjects(this, searcher, radius);
TypeContainerVisitor<Acore::CreatureListSearcher<Acore::AnyAssistCreatureInRangeCheck>, GridTypeMapContainer > grid_creature_searcher(searcher);
cell.Visit(p, grid_creature_searcher, *GetMap(), *this, radius);
}
if (!assistList.empty()) if (!assistList.empty())
{ {
@@ -2187,16 +2151,10 @@ void Creature::CallForHelp(float radius)
if (radius <= 0.0f || !GetVictim() || IsPet() || IsCharmed()) if (radius <= 0.0f || !GetVictim() || IsPet() || IsCharmed())
return; return;
CellCoord p(Acore::ComputeCellCoord(GetPositionX(), GetPositionY()));
Cell cell(p);
cell.SetNoCreate();
Acore::CallOfHelpCreatureInRangeDo u_do(this, GetVictim(), radius); Acore::CallOfHelpCreatureInRangeDo u_do(this, GetVictim(), radius);
Acore::CreatureWorker<Acore::CallOfHelpCreatureInRangeDo> worker(this, u_do); Acore::CreatureWorker<Acore::CallOfHelpCreatureInRangeDo> worker(this, u_do);
TypeContainerVisitor<Acore::CreatureWorker<Acore::CallOfHelpCreatureInRangeDo>, GridTypeMapContainer > grid_creature_searcher(worker); Cell::VisitGridObjects(this, worker, radius);
cell.Visit(p, grid_creature_searcher, *GetMap(), *this, radius);
} }
bool Creature::CanAssistTo(const Unit* u, const Unit* enemy, bool checkfaction /*= true*/) const bool Creature::CanAssistTo(const Unit* u, const Unit* enemy, bool checkfaction /*= true*/) const
@@ -610,9 +610,7 @@ void GameObject::Update(uint32 diff)
{ {
Acore::AnyUnfriendlyNoTotemUnitInObjectRangeCheck checker(this, owner, radius); Acore::AnyUnfriendlyNoTotemUnitInObjectRangeCheck checker(this, owner, radius);
Acore::UnitSearcher<Acore::AnyUnfriendlyNoTotemUnitInObjectRangeCheck> searcher(this, target, checker); Acore::UnitSearcher<Acore::AnyUnfriendlyNoTotemUnitInObjectRangeCheck> searcher(this, target, checker);
VisitNearbyGridObject(radius, searcher); Cell::VisitAllObjects(this, searcher, radius);
if (!target)
VisitNearbyWorldObject(radius, searcher);
} }
else // environmental trap else // environmental trap
{ {
@@ -621,7 +619,7 @@ void GameObject::Update(uint32 diff)
Player* player = nullptr; Player* player = nullptr;
Acore::AnyPlayerInObjectRangeCheck checker(this, radius, true, true); Acore::AnyPlayerInObjectRangeCheck checker(this, radius, true, true);
Acore::PlayerSearcher<Acore::AnyPlayerInObjectRangeCheck> searcher(this, player, checker); Acore::PlayerSearcher<Acore::AnyPlayerInObjectRangeCheck> searcher(this, player, checker);
VisitNearbyWorldObject(radius, searcher); Cell::VisitWorldObjects(this, searcher, radius);
target = player; target = player;
} }
@@ -1209,14 +1207,10 @@ GameObject* GameObject::LookupFishingHoleAround(float range)
{ {
GameObject* ok = nullptr; GameObject* ok = nullptr;
CellCoord p(Acore::ComputeCellCoord(GetPositionX(), GetPositionY()));
Cell cell(p);
Acore::NearestGameObjectFishingHole u_check(*this, range); Acore::NearestGameObjectFishingHole u_check(*this, range);
Acore::GameObjectSearcher<Acore::NearestGameObjectFishingHole> checker(this, ok, u_check); Acore::GameObjectSearcher<Acore::NearestGameObjectFishingHole> checker(this, ok, u_check);
TypeContainerVisitor<Acore::GameObjectSearcher<Acore::NearestGameObjectFishingHole>, GridTypeMapContainer > grid_object_checker(checker); Cell::VisitGridObjects(this, checker, range);
cell.Visit(p, grid_object_checker, *GetMap(), *this, range);
return ok; return ok;
} }
@@ -1978,7 +1972,7 @@ void GameObject::SendMessageToSetInRange(WorldPacket* data, float dist, bool /*s
if (includeMargin) if (includeMargin)
dist += VISIBILITY_COMPENSATION * 2.0f; // pussywizard: to ensure everyone receives all important packets dist += VISIBILITY_COMPENSATION * 2.0f; // pussywizard: to ensure everyone receives all important packets
Acore::MessageDistDeliverer notifier(this, data, dist, false, skipped_rcvr); Acore::MessageDistDeliverer notifier(this, data, dist, false, skipped_rcvr);
VisitNearbyWorldObject(dist, notifier); Cell::VisitWorldObjects(this, notifier, dist);
} }
void GameObject::EventInform(uint32 eventId) void GameObject::EventInform(uint32 eventId)
+10 -27
View File
@@ -2073,7 +2073,7 @@ void WorldObject::SendMessageToSetInRange(WorldPacket* data, float dist, bool /*
if (includeMargin) if (includeMargin)
dist += VISIBILITY_COMPENSATION; // pussywizard: to ensure everyone receives all important packets dist += VISIBILITY_COMPENSATION; // pussywizard: to ensure everyone receives all important packets
Acore::MessageDistDeliverer notifier(this, data, dist, false, skipped_rcvr); Acore::MessageDistDeliverer notifier(this, data, dist, false, skipped_rcvr);
VisitNearbyWorldObject(dist, notifier); Cell::VisitWorldObjects(this, notifier, dist);
} }
void WorldObject::SendObjectDeSpawnAnim(ObjectGuid guid) void WorldObject::SendObjectDeSpawnAnim(ObjectGuid guid)
@@ -2406,7 +2406,7 @@ Creature* WorldObject::FindNearestCreature(uint32 entry, float range, bool alive
Creature* creature = nullptr; Creature* creature = nullptr;
Acore::NearestCreatureEntryWithLiveStateInObjectRangeCheck checker(*this, entry, alive, range); Acore::NearestCreatureEntryWithLiveStateInObjectRangeCheck checker(*this, entry, alive, range);
Acore::CreatureLastSearcher<Acore::NearestCreatureEntryWithLiveStateInObjectRangeCheck> searcher(this, creature, checker); Acore::CreatureLastSearcher<Acore::NearestCreatureEntryWithLiveStateInObjectRangeCheck> searcher(this, creature, checker);
VisitNearbyObject(range, searcher); Cell::VisitAllObjects(this, searcher, range);
return creature; return creature;
} }
@@ -2415,7 +2415,7 @@ GameObject* WorldObject::FindNearestGameObject(uint32 entry, float range) const
GameObject* go = nullptr; GameObject* go = nullptr;
Acore::NearestGameObjectEntryInObjectRangeCheck checker(*this, entry, range); Acore::NearestGameObjectEntryInObjectRangeCheck checker(*this, entry, range);
Acore::GameObjectLastSearcher<Acore::NearestGameObjectEntryInObjectRangeCheck> searcher(this, go, checker); Acore::GameObjectLastSearcher<Acore::NearestGameObjectEntryInObjectRangeCheck> searcher(this, go, checker);
VisitNearbyGridObject(range, searcher); Cell::VisitGridObjects(this, searcher, range);
return go; return go;
} }
@@ -2424,7 +2424,7 @@ GameObject* WorldObject::FindNearestGameObjectOfType(GameobjectTypes type, float
GameObject* go = nullptr; GameObject* go = nullptr;
Acore::NearestGameObjectTypeInObjectRangeCheck checker(*this, type, range); Acore::NearestGameObjectTypeInObjectRangeCheck checker(*this, type, range);
Acore::GameObjectLastSearcher<Acore::NearestGameObjectTypeInObjectRangeCheck> searcher(this, go, checker); Acore::GameObjectLastSearcher<Acore::NearestGameObjectTypeInObjectRangeCheck> searcher(this, go, checker);
VisitNearbyGridObject(range, searcher); Cell::VisitGridObjects(this, searcher, range);
return go; return go;
} }
@@ -2434,35 +2434,23 @@ Player* WorldObject::SelectNearestPlayer(float distance) const
Acore::NearestPlayerInObjectRangeCheck checker(this, distance); Acore::NearestPlayerInObjectRangeCheck checker(this, distance);
Acore::PlayerLastSearcher<Acore::NearestPlayerInObjectRangeCheck> searcher(this, target, checker); Acore::PlayerLastSearcher<Acore::NearestPlayerInObjectRangeCheck> searcher(this, target, checker);
VisitNearbyObject(distance, searcher); Cell::VisitWorldObjects(this, searcher, distance);
return target; return target;
} }
void WorldObject::GetGameObjectListWithEntryInGrid(std::list<GameObject*>& gameobjectList, uint32 entry, float maxSearchRange) const void WorldObject::GetGameObjectListWithEntryInGrid(std::list<GameObject*>& 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::AllGameObjectsWithEntryInRange check(this, entry, maxSearchRange);
Acore::GameObjectListSearcher<Acore::AllGameObjectsWithEntryInRange> searcher(this, gameobjectList, check); Acore::GameObjectListSearcher<Acore::AllGameObjectsWithEntryInRange> searcher(this, gameobjectList, check);
TypeContainerVisitor<Acore::GameObjectListSearcher<Acore::AllGameObjectsWithEntryInRange>, GridTypeMapContainer> visitor(searcher); Cell::VisitGridObjects(this, searcher, maxSearchRange);
cell.Visit(pair, visitor, *(this->GetMap()), *this, maxSearchRange);
} }
void WorldObject::GetCreatureListWithEntryInGrid(std::list<Creature*>& creatureList, uint32 entry, float maxSearchRange) const void WorldObject::GetCreatureListWithEntryInGrid(std::list<Creature*>& 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::AllCreaturesOfEntryInRange check(this, entry, maxSearchRange);
Acore::CreatureListSearcher<Acore::AllCreaturesOfEntryInRange> searcher(this, creatureList, check); Acore::CreatureListSearcher<Acore::AllCreaturesOfEntryInRange> searcher(this, creatureList, check);
TypeContainerVisitor<Acore::CreatureListSearcher<Acore::AllCreaturesOfEntryInRange>, GridTypeMapContainer> visitor(searcher); Cell::VisitGridObjects(this, searcher, maxSearchRange);;
cell.Visit(pair, visitor, *(this->GetMap()), *this, maxSearchRange);
} }
/* /*
@@ -2843,7 +2831,7 @@ void WorldObject::DestroyForNearbyPlayers()
std::list<Player*> targets; std::list<Player*> targets;
Acore::AnyPlayerInObjectRangeCheck check(this, GetVisibilityRange() + VISIBILITY_COMPENSATION, false); Acore::AnyPlayerInObjectRangeCheck check(this, GetVisibilityRange() + VISIBILITY_COMPENSATION, false);
Acore::PlayerListSearcherWithSharedVision<Acore::AnyPlayerInObjectRangeCheck> searcher(this, targets, check); Acore::PlayerListSearcherWithSharedVision<Acore::AnyPlayerInObjectRangeCheck> searcher(this, targets, check);
VisitNearbyWorldObject(GetVisibilityRange() + VISIBILITY_COMPENSATION, searcher); Cell::VisitWorldObjects(this, searcher, GetVisibilityRange());
for (std::list<Player*>::const_iterator iter = targets.begin(); iter != targets.end(); ++iter) for (std::list<Player*>::const_iterator iter = targets.begin(); iter != targets.end(); ++iter)
{ {
Player* player = (*iter); Player* player = (*iter);
@@ -2866,7 +2854,7 @@ void WorldObject::UpdateObjectVisibility(bool /*forced*/, bool /*fromUpdate*/)
{ {
//updates object's visibility for nearby players //updates object's visibility for nearby players
Acore::VisibleChangesNotifier notifier(*this); Acore::VisibleChangesNotifier notifier(*this);
VisitNearbyWorldObject(GetVisibilityRange() + VISIBILITY_COMPENSATION, notifier); Cell::VisitWorldObjects(this, notifier, GetVisibilityRange());
} }
void WorldObject::AddToNotify(uint16 f) void WorldObject::AddToNotify(uint16 f)
@@ -2970,14 +2958,9 @@ struct WorldObjectChangeAccumulator
void WorldObject::BuildUpdate(UpdateDataMapType& data_map, UpdatePlayerSet& player_set) 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); WorldObjectChangeAccumulator notifier(*this, data_map, player_set);
TypeContainerVisitor<WorldObjectChangeAccumulator, WorldTypeMapContainer > player_notifier(notifier);
Map& map = *GetMap();
//we must build packets for all visible players //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); ClearUpdateMask(false);
} }
-4
View File
@@ -1002,10 +1002,6 @@ public:
[[nodiscard]] bool IsPermanentWorldObject() const { return m_isWorldObject; } [[nodiscard]] bool IsPermanentWorldObject() const { return m_isWorldObject; }
[[nodiscard]] bool IsWorldObject() const; [[nodiscard]] bool IsWorldObject() const;
template<class NOTIFIER> void VisitNearbyObject(float const& radius, NOTIFIER& notifier) const { if (IsInWorld()) GetMap()->VisitAll(GetPositionX(), GetPositionY(), radius, notifier); }
template<class NOTIFIER> void VisitNearbyGridObject(float const& radius, NOTIFIER& notifier) const { if (IsInWorld()) GetMap()->VisitGrid(GetPositionX(), GetPositionY(), radius, notifier); }
template<class NOTIFIER> void VisitNearbyWorldObject(float const& radius, NOTIFIER& notifier) const { if (IsInWorld()) GetMap()->VisitWorld(GetPositionX(), GetPositionY(), radius, notifier); }
[[nodiscard]] bool IsInWintergrasp() const [[nodiscard]] bool IsInWintergrasp() const
{ {
return GetMapId() == 571 && GetPositionX() > 3733.33331f && GetPositionX() < 5866.66663f && GetPositionY() > 1599.99999f && GetPositionY() < 4799.99997f; return GetMapId() == 571 && GetPositionX() > 3733.33331f && GetPositionX() < 5866.66663f && GetPositionY() > 1599.99999f && GetPositionY() < 4799.99997f;
+5 -5
View File
@@ -7066,7 +7066,7 @@ void Player::SendMessageToSetInRange(WorldPacket* data, float dist, bool self, b
if (includeMargin) if (includeMargin)
dist += VISIBILITY_COMPENSATION; // pussywizard: to ensure everyone receives all important packets dist += VISIBILITY_COMPENSATION; // pussywizard: to ensure everyone receives all important packets
Acore::MessageDistDeliverer notifier(this, data, dist, false, skipped_rcvr); Acore::MessageDistDeliverer notifier(this, data, dist, false, skipped_rcvr);
VisitNearbyWorldObject(dist, notifier); Cell::VisitWorldObjects(this, notifier, dist);
} }
// pussywizard! // pussywizard!
@@ -7076,7 +7076,7 @@ void Player::SendMessageToSetInRange_OwnTeam(WorldPacket* data, float dist, bool
GetSession()->SendPacket(data); GetSession()->SendPacket(data);
Acore::MessageDistDeliverer notifier(this, data, dist, true); Acore::MessageDistDeliverer notifier(this, data, dist, true);
VisitNearbyWorldObject(dist, notifier); Cell::VisitWorldObjects(this, notifier, dist);
} }
void Player::SendDirectMessage(WorldPacket* data) void Player::SendDirectMessage(WorldPacket* data)
@@ -21528,7 +21528,7 @@ void Player::TextEmote(const std::string& text)
std::list<Player*> players; std::list<Player*> players;
Acore::AnyPlayerInObjectRangeCheck checker(this, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE)); Acore::AnyPlayerInObjectRangeCheck checker(this, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE));
Acore::PlayerListSearcher<Acore::AnyPlayerInObjectRangeCheck> searcher(this, players, checker); Acore::PlayerListSearcher<Acore::AnyPlayerInObjectRangeCheck> 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) for (auto const& itr : players)
{ {
@@ -23681,10 +23681,10 @@ void Player::UpdateObjectVisibility(bool forced, bool fromUpdate)
void Player::UpdateVisibilityForPlayer(bool mapChange) void Player::UpdateVisibilityForPlayer(bool mapChange)
{ {
Acore::VisibleNotifier notifierNoLarge(*this, mapChange, false); // visit only objects which are not large; default distance 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(); notifierNoLarge.SendToSelf();
Acore::VisibleNotifier notifierLarge(*this, mapChange, true); // visit only large objects; maximum distance 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(); notifierLarge.SendToSelf();
if (mapChange) if (mapChange)
+9 -9
View File
@@ -16296,7 +16296,7 @@ Unit* Unit::SelectNearbyTarget(Unit* exclude, float dist) const
std::list<Unit*> targets; std::list<Unit*> targets;
Acore::AnyUnfriendlyUnitInObjectRangeCheck u_check(this, this, dist); Acore::AnyUnfriendlyUnitInObjectRangeCheck u_check(this, this, dist);
Acore::UnitListSearcher<Acore::AnyUnfriendlyUnitInObjectRangeCheck> searcher(this, targets, u_check); Acore::UnitListSearcher<Acore::AnyUnfriendlyUnitInObjectRangeCheck> searcher(this, targets, u_check);
VisitNearbyObject(dist, searcher); Cell::VisitAllObjects(this, searcher, dist);
// remove current target // remove current target
if (GetVictim()) if (GetVictim())
@@ -16331,7 +16331,7 @@ Unit* Unit::SelectNearbyNoTotemTarget(Unit* exclude, float dist) const
std::list<Unit*> targets; std::list<Unit*> targets;
Acore::AnyUnfriendlyNoTotemUnitInObjectRangeCheck u_check(this, this, dist); Acore::AnyUnfriendlyNoTotemUnitInObjectRangeCheck u_check(this, this, dist);
Acore::UnitListSearcher<Acore::AnyUnfriendlyNoTotemUnitInObjectRangeCheck> searcher(this, targets, u_check); Acore::UnitListSearcher<Acore::AnyUnfriendlyNoTotemUnitInObjectRangeCheck> searcher(this, targets, u_check);
VisitNearbyObject(dist, searcher); Cell::VisitAllObjects(this, searcher, dist);
// remove current target // remove current target
if (GetVictim()) if (GetVictim())
@@ -18371,7 +18371,7 @@ void Unit::UpdateObjectVisibility(bool forced, bool /*fromUpdate*/)
{ {
Acore::AIRelocationNotifier notifier(*this); Acore::AIRelocationNotifier notifier(*this);
float radius = 60.0f; 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 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(); relocateNoLarge.SendToSelf();
Acore::PlayerRelocationNotifier relocateLarge(*player, true); // visit only large objects; maximum distance 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(); relocateLarge.SendToSelf();
} }
@@ -19778,10 +19778,10 @@ void Unit::ExecuteDelayedUnitRelocationEvent()
} }
Acore::PlayerRelocationNotifier relocateNoLarge(*player, false); // visit only objects which are not large; default distance 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(); relocateNoLarge.SendToSelf();
Acore::PlayerRelocationNotifier relocateLarge(*player, true); // visit only large objects; maximum distance 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(); relocateLarge.SendToSelf();
this->AddToNotify(NOTIFY_AI_RELOCATION); this->AddToNotify(NOTIFY_AI_RELOCATION);
@@ -19802,7 +19802,7 @@ void Unit::ExecuteDelayedUnitRelocationEvent()
unit->m_last_notify_position.Relocate(unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ()); unit->m_last_notify_position.Relocate(unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ());
Acore::CreatureRelocationNotifier relocate(*unit); Acore::CreatureRelocationNotifier relocate(*unit);
unit->VisitNearbyObject(unit->GetVisibilityRange() + VISIBILITY_COMPENSATION, relocate); Cell::VisitAllObjects(unit, relocate, unit->GetVisibilityRange() + VISIBILITY_COMPENSATION);
this->AddToNotify(NOTIFY_AI_RELOCATION); this->AddToNotify(NOTIFY_AI_RELOCATION);
} }
@@ -19816,7 +19816,7 @@ void Unit::ExecuteDelayedUnitAINotifyEvent()
Acore::AIRelocationNotifier notifier(*this); Acore::AIRelocationNotifier notifier(*this);
float radius = 60.0f; float radius = 60.0f;
this->VisitNearbyObject(radius, notifier); Cell::VisitAllObjects(this, notifier, radius);
} }
void Unit::SetInFront(WorldObject const* target) void Unit::SetInFront(WorldObject const* target)
+10 -2
View File
@@ -92,11 +92,19 @@ struct Cell
uint32 All; uint32 All;
} data; } 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&, WorldObject const& obj, float radius) 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&, float x, float y, float radius) const;
static CellArea CalculateCellArea(float x, float y, float radius); 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: private:
template<class T, class CONTAINER> void VisitCircle(TypeContainerVisitor<T, CONTAINER>&, Map&, CellCoord const&, CellCoord const&) const; template<class T, class CONTAINER> void VisitCircle(TypeContainerVisitor<T, CONTAINER>&, Map&, CellCoord const&, CellCoord const&) const;
}; };
+97 -9
View File
@@ -48,8 +48,15 @@ inline CellArea Cell::CalculateCellArea(float x, float y, float radius)
} }
template<class T, class CONTAINER> 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.GetCombatReach());
}
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()) if (!standing_cell.IsCoordValid())
return; return;
@@ -105,14 +112,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> template<class T, class CONTAINER>
inline void Cell::VisitCircle(TypeContainerVisitor<T, CONTAINER>& visitor, Map& map, CellCoord const& begin_cell, CellCoord const& end_cell) const inline void Cell::VisitCircle(TypeContainerVisitor<T, CONTAINER>& visitor, Map& map, CellCoord const& begin_cell, CellCoord const& end_cell) const
{ {
@@ -164,4 +163,93 @@ 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 /*= true*/)
{
CellCoord p(Acore::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 /*= true*/)
{
CellCoord p(Acore::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);
}
template<class T>
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<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 /*= true*/)
{
CellCoord p(Acore::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 /*= true*/)
{
CellCoord p(Acore::ComputeCellCoord(x, y));
Cell cell(p);
if (dont_load)
{
cell.SetNoCreate();
}
TypeContainerVisitor<T, WorldTypeMapContainer> wnotifier(visitor);
cell.Visit(p, wnotifier, *map, x, y, radius);
}
template<class T>
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<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 #endif
-22
View File
@@ -2344,28 +2344,6 @@ char const* Map::GetMapName() const
return i_mapEntry ? i_mapEntry->name[sWorld->GetDefaultDbcLocale()] : "UNNAMEDMAP\x0"; 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<Acore::VisibleChangesNotifier, WorldTypeMapContainer > 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<Acore::VisibleNotifier, WorldTypeMapContainer > world_notifier(notifier);
TypeContainerVisitor<Acore::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) void Map::SendInitSelf(Player* player)
{ {
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
-58
View File
@@ -406,9 +406,6 @@ public:
void AddObjectToSwitchList(WorldObject* obj, bool on); void AddObjectToSwitchList(WorldObject* obj, bool on);
virtual void DelayedUpdate(const uint32 diff); 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(); } void resetMarkedCells() { marked_cells.reset(); }
bool isCellMarked(uint32 pCellId) { return marked_cells.test(pCellId); } bool isCellMarked(uint32 pCellId) { return marked_cells.test(pCellId); }
void markCell(uint32 pCellId) { marked_cells.set(pCellId); } void markCell(uint32 pCellId) { marked_cells.set(pCellId); }
@@ -440,10 +437,6 @@ public:
void RemoveFromActive(T* obj); void RemoveFromActive(T* obj);
template<class T> void SwitchGridContainers(T* obj, bool on); 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; CreatureGroupHolderType CreatureGroupHolder;
void UpdateIteratorBack(Player* player); void UpdateIteratorBack(Player* player);
@@ -812,55 +805,4 @@ inline void Map::Visit(Cell const& cell, TypeContainerVisitor<T, CONTAINER>& vis
} }
} }
template<class NOTIFIER>
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<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(Acore::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(Acore::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(Acore::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 #endif
+1 -1
View File
@@ -304,7 +304,7 @@ bool OPvPCapturePoint::Update(uint32 diff)
std::list<Player*> players; std::list<Player*> players;
Acore::AnyPlayerInObjectRangeCheck checker(m_capturePoint, radius); Acore::AnyPlayerInObjectRangeCheck checker(m_capturePoint, radius);
Acore::PlayerListSearcher<Acore::AnyPlayerInObjectRangeCheck> searcher(m_capturePoint, players, checker); Acore::PlayerListSearcher<Acore::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) for (std::list<Player*>::iterator itr = players.begin(); itr != players.end(); ++itr)
{ {
@@ -2399,7 +2399,7 @@ void AuraEffect::HandleFeignDeath(AuraApplication const* aurApp, uint8 mode, boo
UnitList targets; UnitList targets;
Acore::AnyUnfriendlyUnitInObjectRangeCheck u_check(target, target, target->GetVisibilityRange()); // no VISIBILITY_COMPENSATION, distance is enough Acore::AnyUnfriendlyUnitInObjectRangeCheck u_check(target, target, target->GetVisibilityRange()); // no VISIBILITY_COMPENSATION, distance is enough
Acore::UnitListSearcher<Acore::AnyUnfriendlyUnitInObjectRangeCheck> searcher(target, targets, u_check); Acore::UnitListSearcher<Acore::AnyUnfriendlyUnitInObjectRangeCheck> 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) for (UnitList::iterator iter = targets.begin(); iter != targets.end(); ++iter)
{ {
if (!(*iter)->HasUnitState(UNIT_STATE_CASTING)) if (!(*iter)->HasUnitState(UNIT_STATE_CASTING))
@@ -5206,7 +5206,7 @@ void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool
Player* player = nullptr; Player* player = nullptr;
Acore::AnyPlayerInObjectRangeCheck checker(target, 10.0f); Acore::AnyPlayerInObjectRangeCheck checker(target, 10.0f);
Acore::PlayerSearcher<Acore::AnyPlayerInObjectRangeCheck> searcher(target, player, checker); Acore::PlayerSearcher<Acore::AnyPlayerInObjectRangeCheck> searcher(target, player, checker);
target->VisitNearbyWorldObject(10.0f, searcher); Cell::VisitWorldObjects(target, searcher, 10.0f);
if( player && player->GetGUID() != target->GetGUID() ) if( player && player->GetGUID() != target->GetGUID() )
target->CastSpell(player, 52921, true); target->CastSpell(player, 52921, true);
+6 -6
View File
@@ -2652,7 +2652,7 @@ void UnitAura::FillTargetMap(std::map<Unit*, uint8>& targets, Unit* caster)
targetList.push_back(GetUnitOwner()); targetList.push_back(GetUnitOwner());
Acore::AnyGroupedUnitInObjectRangeCheck u_check(GetUnitOwner(), GetUnitOwner(), radius, GetSpellInfo()->Effects[effIndex].Effect == SPELL_EFFECT_APPLY_AREA_AURA_RAID); Acore::AnyGroupedUnitInObjectRangeCheck u_check(GetUnitOwner(), GetUnitOwner(), radius, GetSpellInfo()->Effects[effIndex].Effect == SPELL_EFFECT_APPLY_AREA_AURA_RAID);
Acore::UnitListSearcher<Acore::AnyGroupedUnitInObjectRangeCheck> searcher(GetUnitOwner(), targetList, u_check); Acore::UnitListSearcher<Acore::AnyGroupedUnitInObjectRangeCheck> searcher(GetUnitOwner(), targetList, u_check);
GetUnitOwner()->VisitNearbyObject(radius, searcher); Cell::VisitAllObjects(GetUnitOwner(), searcher, radius);
break; break;
} }
case SPELL_EFFECT_APPLY_AREA_AURA_FRIEND: case SPELL_EFFECT_APPLY_AREA_AURA_FRIEND:
@@ -2660,14 +2660,14 @@ void UnitAura::FillTargetMap(std::map<Unit*, uint8>& targets, Unit* caster)
targetList.push_back(GetUnitOwner()); targetList.push_back(GetUnitOwner());
Acore::AnyFriendlyUnitInObjectRangeCheck u_check(GetUnitOwner(), GetUnitOwner(), radius); Acore::AnyFriendlyUnitInObjectRangeCheck u_check(GetUnitOwner(), GetUnitOwner(), radius);
Acore::UnitListSearcher<Acore::AnyFriendlyUnitInObjectRangeCheck> searcher(GetUnitOwner(), targetList, u_check); Acore::UnitListSearcher<Acore::AnyFriendlyUnitInObjectRangeCheck> searcher(GetUnitOwner(), targetList, u_check);
GetUnitOwner()->VisitNearbyObject(radius, searcher); Cell::VisitAllObjects(GetUnitOwner(), searcher, radius);
break; break;
} }
case SPELL_EFFECT_APPLY_AREA_AURA_ENEMY: case SPELL_EFFECT_APPLY_AREA_AURA_ENEMY:
{ {
Acore::AnyAoETargetUnitInObjectRangeCheck u_check(GetUnitOwner(), GetUnitOwner(), radius); // No GetCharmer in searcher Acore::AnyAoETargetUnitInObjectRangeCheck u_check(GetUnitOwner(), GetUnitOwner(), radius); // No GetCharmer in searcher
Acore::UnitListSearcher<Acore::AnyAoETargetUnitInObjectRangeCheck> searcher(GetUnitOwner(), targetList, u_check); Acore::UnitListSearcher<Acore::AnyAoETargetUnitInObjectRangeCheck> searcher(GetUnitOwner(), targetList, u_check);
GetUnitOwner()->VisitNearbyObject(radius, searcher); Cell::VisitAllObjects(GetUnitOwner(), searcher, radius);
break; break;
} }
case SPELL_EFFECT_APPLY_AREA_AURA_PET: case SPELL_EFFECT_APPLY_AREA_AURA_PET:
@@ -2728,7 +2728,7 @@ void DynObjAura::FillTargetMap(std::map<Unit*, uint8>& targets, Unit* /*caster*/
{ {
Acore::AnyFriendlyUnitInObjectRangeCheck u_check(GetDynobjOwner(), dynObjOwnerCaster, radius); Acore::AnyFriendlyUnitInObjectRangeCheck u_check(GetDynobjOwner(), dynObjOwnerCaster, radius);
Acore::UnitListSearcher<Acore::AnyFriendlyUnitInObjectRangeCheck> searcher(GetDynobjOwner(), targetList, u_check); Acore::UnitListSearcher<Acore::AnyFriendlyUnitInObjectRangeCheck> 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 // pussywizard: TARGET_DEST_DYNOBJ_NONE is supposed to search for both friendly and unfriendly targets, so for any unit
// what about EffectImplicitTargetA? // what about EffectImplicitTargetA?
@@ -2736,13 +2736,13 @@ void DynObjAura::FillTargetMap(std::map<Unit*, uint8>& targets, Unit* /*caster*/
{ {
Acore::AnyAttackableUnitExceptForOriginalCasterInObjectRangeCheck u_check(GetDynobjOwner(), dynObjOwnerCaster, radius); Acore::AnyAttackableUnitExceptForOriginalCasterInObjectRangeCheck u_check(GetDynobjOwner(), dynObjOwnerCaster, radius);
Acore::UnitListSearcher<Acore::AnyAttackableUnitExceptForOriginalCasterInObjectRangeCheck> searcher(GetDynobjOwner(), targetList, u_check); Acore::UnitListSearcher<Acore::AnyAttackableUnitExceptForOriginalCasterInObjectRangeCheck> searcher(GetDynobjOwner(), targetList, u_check);
GetDynobjOwner()->VisitNearbyObject(radius, searcher); Cell::VisitAllObjects(GetDynobjOwner(), searcher, radius);
} }
else else
{ {
Acore::AnyAoETargetUnitInObjectRangeCheck u_check(GetDynobjOwner(), dynObjOwnerCaster, radius); Acore::AnyAoETargetUnitInObjectRangeCheck u_check(GetDynobjOwner(), dynObjOwnerCaster, radius);
Acore::UnitListSearcher<Acore::AnyAoETargetUnitInObjectRangeCheck> searcher(GetDynobjOwner(), targetList, u_check); Acore::UnitListSearcher<Acore::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) for (UnitList::iterator itr = targetList.begin(); itr != targetList.end(); ++itr)
+4 -9
View File
@@ -1896,18 +1896,13 @@ void Spell::SearchTargets(SEARCHER& searcher, uint32 containerMask, Unit* refere
Cell cell(p); Cell cell(p);
cell.SetNoCreate(); cell.SetNoCreate();
Map& map = *(referer->GetMap()); Map* map = referer->GetMap();
if (searchInWorld) if (searchInWorld)
{ Cell::VisitWorldObjects(x, y, map, searcher, radius);
TypeContainerVisitor<SEARCHER, WorldTypeMapContainer> world_object_notifier(searcher);
cell.Visit(p, world_object_notifier, map, radius + SPELL_SEARCHER_COMPENSATION, x, y);
}
if (searchInGrid) if (searchInGrid)
{ Cell::VisitGridObjects(x, y, map, searcher, radius);
TypeContainerVisitor<SEARCHER, GridTypeMapContainer > grid_object_notifier(searcher);
cell.Visit(p, grid_object_notifier, map, radius + SPELL_SEARCHER_COMPENSATION, x, y);
}
} }
} }
+3 -3
View File
@@ -4297,7 +4297,7 @@ void Spell::EffectSanctuary(SpellEffIndex /*effIndex*/)
UnitList targets; UnitList targets;
Acore::AnyUnfriendlyUnitInObjectRangeCheck u_check(unitTarget, unitTarget, unitTarget->GetVisibilityRange()); // no VISIBILITY_COMPENSATION, distance is enough Acore::AnyUnfriendlyUnitInObjectRangeCheck u_check(unitTarget, unitTarget, unitTarget->GetVisibilityRange()); // no VISIBILITY_COMPENSATION, distance is enough
Acore::UnitListSearcher<Acore::AnyUnfriendlyUnitInObjectRangeCheck> searcher(unitTarget, targets, u_check); Acore::UnitListSearcher<Acore::AnyUnfriendlyUnitInObjectRangeCheck> 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) for (UnitList::iterator iter = targets.begin(); iter != targets.end(); ++iter)
{ {
if (!(*iter)->HasUnitState(UNIT_STATE_CASTING)) if (!(*iter)->HasUnitState(UNIT_STATE_CASTING))
@@ -4943,7 +4943,7 @@ void Spell::EffectForceDeselect(SpellEffIndex /*effIndex*/)
float dist = m_caster->GetVisibilityRange() + VISIBILITY_COMPENSATION; float dist = m_caster->GetVisibilityRange() + VISIBILITY_COMPENSATION;
Acore::MessageDistDelivererToHostile notifier(m_caster, &data, dist); 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 // xinef: we should also force pets to remove us from current target
Unit::AttackerSet attackerSet; Unit::AttackerSet attackerSet;
@@ -4968,7 +4968,7 @@ void Spell::EffectForceDeselect(SpellEffIndex /*effIndex*/)
UnitList targets; UnitList targets;
Acore::AnyUnfriendlyUnitInObjectRangeCheck u_check(m_caster, m_caster, m_caster->GetVisibilityRange()); // no VISIBILITY_COMPENSATION, distance is enough Acore::AnyUnfriendlyUnitInObjectRangeCheck u_check(m_caster, m_caster, m_caster->GetVisibilityRange()); // no VISIBILITY_COMPENSATION, distance is enough
Acore::UnitListSearcher<Acore::AnyUnfriendlyUnitInObjectRangeCheck> searcher(m_caster, targets, u_check); Acore::UnitListSearcher<Acore::AnyUnfriendlyUnitInObjectRangeCheck> 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) for (UnitList::iterator iter = targets.begin(); iter != targets.end(); ++iter)
{ {
if (!(*iter)->HasUnitState(UNIT_STATE_CASTING)) if (!(*iter)->HasUnitState(UNIT_STATE_CASTING))
+1 -1
View File
@@ -239,7 +239,7 @@ void CreatureTextMgr::SendChatPacket(WorldObject* source, Builder const& builder
dist = 250.0f; dist = 250.0f;
Acore::PlayerDistWorker<CreatureTextLocalizer<Builder> > worker(source, dist, localizer); Acore::PlayerDistWorker<CreatureTextLocalizer<Builder> > worker(source, dist, localizer);
source->VisitNearbyWorldObject(dist, worker); Cell::VisitWorldObjects(source, worker, dist);
} }
#endif #endif
+1 -1
View File
@@ -918,7 +918,7 @@ public:
Creature* passenger = nullptr; Creature* passenger = nullptr;
Acore::AllCreaturesOfEntryInRange check(handler->GetSession()->GetPlayer(), entry, 20.0f); Acore::AllCreaturesOfEntryInRange check(handler->GetSession()->GetPlayer(), entry, 20.0f);
Acore::CreatureSearcher<Acore::AllCreaturesOfEntryInRange> searcher(handler->GetSession()->GetPlayer(), passenger, check); Acore::CreatureSearcher<Acore::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) if (!passenger || passenger == target)
return false; return false;
passenger->EnterVehicle(target, seatId); passenger->EnterVehicle(target, seatId);
+1 -3
View File
@@ -2233,9 +2233,7 @@ public:
Acore::RespawnDo u_do; Acore::RespawnDo u_do;
Acore::WorldObjectWorker<Acore::RespawnDo> worker(player, u_do); Acore::WorldObjectWorker<Acore::RespawnDo> worker(player, u_do);
Cell::VisitGridObjects(player, worker, player->GetGridActivationRange());
TypeContainerVisitor<Acore::WorldObjectWorker<Acore::RespawnDo>, GridTypeMapContainer > obj_worker(worker);
cell.Visit(p, obj_worker, *player->GetMap(), *player, player->GetGridActivationRange());
return true; return true;
} }
+2 -9
View File
@@ -263,18 +263,11 @@ public:
float radius = 40.0f; float radius = 40.0f;
WorldObject* object = handler->GetSession()->GetPlayer(); WorldObject* object = handler->GetSession()->GetPlayer();
CellCoord pair(Acore::ComputeCellCoord(object->GetPositionX(), object->GetPositionY())); // Get Creatures
Cell cell(pair);
cell.SetNoCreate();
std::list<Creature*> creatureList; std::list<Creature*> creatureList;
Acore::AnyUnitInObjectRangeCheck go_check(object, radius); Acore::AnyUnitInObjectRangeCheck go_check(object, radius);
Acore::CreatureListSearcher<Acore::AnyUnitInObjectRangeCheck> go_search(object, creatureList, go_check); Acore::CreatureListSearcher<Acore::AnyUnitInObjectRangeCheck> go_search(object, creatureList, go_check);
TypeContainerVisitor<Acore::CreatureListSearcher<Acore::AnyUnitInObjectRangeCheck>, GridTypeMapContainer> go_visit(go_search); Cell::VisitGridObjects(object, go_search, radius);
// Get Creatures
cell.Visit(pair, go_visit, *(object->GetMap()), *object, radius);
if (!creatureList.empty()) if (!creatureList.empty())
{ {
@@ -149,22 +149,11 @@ public:
for (uint8 i = 2; i < StormCount; ++i) for (uint8 i = 2; i < StormCount; ++i)
bp0 *= 2; bp0 *= 2;
CellCoord p(Acore::ComputeCellCoord(me->GetPositionX(), me->GetPositionY()));
Cell cell(p);
cell.SetNoCreate();
std::list<Unit*> tempUnitMap; std::list<Unit*> tempUnitMap;
{
Acore::AnyAoETargetUnitInObjectRangeCheck u_check(me, me, SIZE_OF_GRIDS); Acore::AnyAoETargetUnitInObjectRangeCheck u_check(me, me, SIZE_OF_GRIDS);
Acore::UnitListSearcher<Acore::AnyAoETargetUnitInObjectRangeCheck> searcher(me, tempUnitMap, u_check); Acore::UnitListSearcher<Acore::AnyAoETargetUnitInObjectRangeCheck> searcher(me, tempUnitMap, u_check);
Cell::VisitAllObjects(me, searcher, SIZE_OF_GRIDS);
TypeContainerVisitor<Acore::UnitListSearcher<Acore::AnyAoETargetUnitInObjectRangeCheck>, WorldTypeMapContainer > world_unit_searcher(searcher);
TypeContainerVisitor<Acore::UnitListSearcher<Acore::AnyAoETargetUnitInObjectRangeCheck>, 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);
}
// deal damage // deal damage
for (std::list<Unit*>::const_iterator i = tempUnitMap.begin(); i != tempUnitMap.end(); ++i) for (std::list<Unit*>::const_iterator i = tempUnitMap.begin(); i != tempUnitMap.end(); ++i)
@@ -223,18 +223,9 @@ public:
float x, y, z; float x, y, z;
me->GetPosition(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::AllCreaturesOfEntryInRange check(me, NPC_EGG, 100);
Acore::CreatureListSearcher<Acore::AllCreaturesOfEntryInRange> searcher(me, templist, check); Acore::CreatureListSearcher<Acore::AllCreaturesOfEntryInRange> searcher(me, templist, check);
Cell::VisitGridObjects(me, searcher, me->GetGridActivationRange());
TypeContainerVisitor<Acore::CreatureListSearcher<Acore::AllCreaturesOfEntryInRange>, GridTypeMapContainer> cSearcher(searcher);
cell.Visit(pair, cSearcher, *me->GetMap(), *me, me->GetGridActivationRange());
}
//TC_LOG_ERROR("scripts", "Eggs %d at middle", templist.size()); //TC_LOG_ERROR("scripts", "Eggs %d at middle", templist.size());
if (templist.empty()) if (templist.empty())
@@ -256,18 +247,10 @@ public:
float x, y, z; float x, y, z;
me->GetPosition(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::AllCreaturesOfEntryInRange check(me, NPC_FIRE_BOMB, 100);
Acore::CreatureListSearcher<Acore::AllCreaturesOfEntryInRange> searcher(me, templist, check); Acore::CreatureListSearcher<Acore::AllCreaturesOfEntryInRange> searcher(me, templist, check);
Cell::VisitGridObjects(me, searcher, me->GetGridActivationRange());
TypeContainerVisitor<Acore::CreatureListSearcher<Acore::AllCreaturesOfEntryInRange>, GridTypeMapContainer> cSearcher(searcher);
cell.Visit(pair, cSearcher, *me->GetMap(), *me, me->GetGridActivationRange());
}
for (std::list<Creature*>::const_iterator i = templist.begin(); i != templist.end(); ++i) for (std::list<Creature*>::const_iterator i = templist.begin(); i != templist.end(); ++i)
{ {
(*i)->CastSpell(*i, SPELL_FIRE_BOMB_DAMAGE, true); (*i)->CastSpell(*i, SPELL_FIRE_BOMB_DAMAGE, true);
@@ -517,18 +500,9 @@ public:
float x, y, z; float x, y, z;
me->GetPosition(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::AllCreaturesOfEntryInRange check(me, 23817, 50);
Acore::CreatureListSearcher<Acore::AllCreaturesOfEntryInRange> searcher(me, templist, check); Acore::CreatureListSearcher<Acore::AllCreaturesOfEntryInRange> searcher(me, templist, check);
Cell::VisitGridObjects(me, searcher, me->GetGridActivationRange());
TypeContainerVisitor<Acore::CreatureListSearcher<Acore::AllCreaturesOfEntryInRange>, GridTypeMapContainer> cSearcher(searcher);
cell.Visit(pair, cSearcher, *(me->GetMap()), *me, me->GetGridActivationRange());
}
//TC_LOG_ERROR("scripts", "Eggs %d at %d", templist.size(), side); //TC_LOG_ERROR("scripts", "Eggs %d at %d", templist.size(), side);
+1 -1
View File
@@ -1109,7 +1109,7 @@ public:
Player* player = nullptr; Player* player = nullptr;
Acore::AnyPlayerInObjectRangeCheck checker(me, 2.0f); Acore::AnyPlayerInObjectRangeCheck checker(me, 2.0f);
Acore::PlayerSearcher<Acore::AnyPlayerInObjectRangeCheck> searcher(me, player, checker); Acore::PlayerSearcher<Acore::AnyPlayerInObjectRangeCheck> searcher(me, player, checker);
me->VisitNearbyWorldObject(2.0f, searcher); Cell::VisitWorldObjects(me, searcher, 2.0f);
if (player) if (player)
{ {
player->CastSpell(player, SPELL_DRUNKEN_MASTER, true); player->CastSpell(player, SPELL_DRUNKEN_MASTER, true);
+1 -1
View File
@@ -812,7 +812,7 @@ public:
std::list<Player*> players; std::list<Player*> players;
Acore::AnyPlayerInObjectRangeCheck checker(me, radius); Acore::AnyPlayerInObjectRangeCheck checker(me, radius);
Acore::PlayerListSearcher<Acore::AnyPlayerInObjectRangeCheck> searcher(me, players, checker); Acore::PlayerListSearcher<Acore::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) for (std::list<Player*>::const_iterator itr = players.begin(); itr != players.end(); ++itr)
{ {
+1 -1
View File
@@ -727,7 +727,7 @@ public:
std::list<Player*> playerList; std::list<Player*> playerList;
Acore::AnyPlayerInObjectRangeCheck checker(target, INTERACTION_DISTANCE * 2); Acore::AnyPlayerInObjectRangeCheck checker(target, INTERACTION_DISTANCE * 2);
Acore::PlayerListSearcher<Acore::AnyPlayerInObjectRangeCheck> searcher(target, playerList, checker); Acore::PlayerListSearcher<Acore::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) 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) if ((*itr) != target && (*itr)->HasAura(GetId())) // && (*itr)->getStandState() == UNIT_STAND_STATE_SIT)
@@ -888,17 +888,12 @@ void hyjalAI::JustDied(Unit* /*killer*/)
void hyjalAI::HideNearPos(float x, float y) void hyjalAI::HideNearPos(float x, float y)
{ {
CellCoord pair(Acore::ComputeCellCoord(x, y));
Cell cell(pair);
cell.SetNoCreate();
// First get all creatures. // First get all creatures.
std::list<Creature*> creatures; std::list<Creature*> creatures;
Acore::AllFriendlyCreaturesInGrid creature_check(me); Acore::AllFriendlyCreaturesInGrid creature_check(me);
Acore::CreatureListSearcher<Acore::AllFriendlyCreaturesInGrid> creature_searcher(me, creatures, creature_check); Acore::CreatureListSearcher<Acore::AllFriendlyCreaturesInGrid> creature_searcher(me, creatures, creature_check);
TypeContainerVisitor <Acore::CreatureListSearcher<Acore::AllFriendlyCreaturesInGrid>, GridTypeMapContainer> creature_visitor(creature_searcher); Cell::VisitGridObjects(x, y, me->GetMap(), creature_searcher, me->GetGridActivationRange());
cell.Visit(pair, creature_visitor, *(me->GetMap()), *me, me->GetGridActivationRange());
if (!creatures.empty()) if (!creatures.empty())
{ {
@@ -912,14 +907,9 @@ void hyjalAI::HideNearPos(float x, float y)
void hyjalAI::RespawnNearPos(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::RespawnDo u_do;
Acore::WorldObjectWorker<Acore::RespawnDo> worker(me, u_do); Acore::WorldObjectWorker<Acore::RespawnDo> worker(me, u_do);
TypeContainerVisitor<Acore::WorldObjectWorker<Acore::RespawnDo>, GridTypeMapContainer > obj_worker(worker); Cell::VisitGridObjects(x, y, me->GetMap(), worker, me->GetGridActivationRange());
cell.Visit(p, obj_worker, *me->GetMap(), *me, me->GetGridActivationRange());
} }
void hyjalAI::WaypointReached(uint32 waypointId) void hyjalAI::WaypointReached(uint32 waypointId)
@@ -943,19 +933,11 @@ void hyjalAI::WaypointReached(uint32 waypointId)
} }
//do some talking //do some talking
//all alive guards walk near here //all alive guards walk near here
CellCoord pair(Acore::ComputeCellCoord(me->GetPositionX(), me->GetPositionY()));
Cell cell(pair);
cell.SetNoCreate();
// First get all creatures. // First get all creatures.
std::list<Creature*> creatures; std::list<Creature*> creatures;
Acore::AllFriendlyCreaturesInGrid creature_check(me); Acore::AllFriendlyCreaturesInGrid creature_check(me);
Acore::CreatureListSearcher<Acore::AllFriendlyCreaturesInGrid> creature_searcher(me, creatures, creature_check); Acore::CreatureListSearcher<Acore::AllFriendlyCreaturesInGrid> creature_searcher(me, creatures, creature_check);
TypeContainerVisitor Cell::VisitGridObjects(me, creature_searcher, me->GetGridActivationRange());
<Acore::CreatureListSearcher<Acore::AllFriendlyCreaturesInGrid>,
GridTypeMapContainer> creature_visitor(creature_searcher);
cell.Visit(pair, creature_visitor, *(me->GetMap()), *me, me->GetGridActivationRange());
if (!creatures.empty()) if (!creatures.empty())
{ {
@@ -984,18 +966,10 @@ void hyjalAI::DoOverrun(uint32 faction, const uint32 diff)
{ {
if (TeleportTimer <= diff) if (TeleportTimer <= diff)
{ {
CellCoord pair(Acore::ComputeCellCoord(me->GetPositionX(), me->GetPositionY()));
Cell cell(pair);
cell.SetNoCreate();
std::list<Creature*> creatures; std::list<Creature*> creatures;
Acore::AllFriendlyCreaturesInGrid creature_check(me); Acore::AllFriendlyCreaturesInGrid creature_check(me);
Acore::CreatureListSearcher<Acore::AllFriendlyCreaturesInGrid> creature_searcher(me, creatures, creature_check); Acore::CreatureListSearcher<Acore::AllFriendlyCreaturesInGrid> creature_searcher(me, creatures, creature_check);
TypeContainerVisitor Cell::VisitGridObjects(me, creature_searcher, me->GetGridActivationRange());
<Acore::CreatureListSearcher<Acore::AllFriendlyCreaturesInGrid>,
GridTypeMapContainer> creature_visitor(creature_searcher);
cell.Visit(pair, creature_visitor, *(me->GetMap()), *me, me->GetGridActivationRange());
if (!creatures.empty()) if (!creatures.empty())
{ {
@@ -182,7 +182,7 @@ public:
std::list<WorldObject*> ClusterList; std::list<WorldObject*> ClusterList;
Acore::AllWorldObjectsInRange objects(me, 50.0f); Acore::AllWorldObjectsInRange objects(me, 50.0f);
Acore::WorldObjectListSearcher<Acore::AllWorldObjectsInRange> searcher(me, ClusterList, objects); Acore::WorldObjectListSearcher<Acore::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) for (std::list<WorldObject*>::const_iterator itr = ClusterList.begin(); itr != ClusterList.end(); ++itr)
{ {
if (Player* player = (*itr)->ToPlayer()) if (Player* player = (*itr)->ToPlayer())
@@ -141,7 +141,7 @@ public:
std::list<WorldObject*> cagesList; std::list<WorldObject*> cagesList;
Acore::AllWorldObjectsInRange objects(GetCaster(), 15.0f); Acore::AllWorldObjectsInRange objects(GetCaster(), 15.0f);
Acore::WorldObjectListSearcher<Acore::AllWorldObjectsInRange> searcher(GetCaster(), cagesList, objects); Acore::WorldObjectListSearcher<Acore::AllWorldObjectsInRange> searcher(GetCaster(), cagesList, objects);
GetCaster()->VisitNearbyObject(15.0f, searcher); Cell::VisitAllObjects(GetCaster(), searcher, 15.0f);
for (std::list<WorldObject*>::const_iterator itr = cagesList.begin(); itr != cagesList.end(); ++itr) for (std::list<WorldObject*>::const_iterator itr = cagesList.begin(); itr != cagesList.end(); ++itr)
{ {
if (GameObject* go = (*itr)->ToGameObject()) if (GameObject* go = (*itr)->ToGameObject())
@@ -313,7 +313,7 @@ public:
std::list<Player*> playerOnQuestList; std::list<Player*> playerOnQuestList;
Acore::AnyPlayerInObjectRangeCheck checker(me, 5.0f); Acore::AnyPlayerInObjectRangeCheck checker(me, 5.0f);
Acore::PlayerListSearcher<Acore::AnyPlayerInObjectRangeCheck> searcher(me, playerOnQuestList, checker); Acore::PlayerListSearcher<Acore::AnyPlayerInObjectRangeCheck> searcher(me, playerOnQuestList, checker);
me->VisitNearbyWorldObject(5.0f, searcher); Cell::VisitWorldObjects(me, searcher, 5.0f);
for (std::list<Player*>::const_iterator itr = playerOnQuestList.begin(); itr != playerOnQuestList.end(); ++itr) for (std::list<Player*>::const_iterator itr = playerOnQuestList.begin(); itr != playerOnQuestList.end(); ++itr)
{ {
// Check if found player target has active quest // Check if found player target has active quest
@@ -687,7 +687,7 @@ public:
// Reset The Frozen Throne gameobjects // Reset The Frozen Throne gameobjects
FrozenThroneResetWorker reset; FrozenThroneResetWorker reset;
Acore::GameObjectWorker<FrozenThroneResetWorker> worker(me, reset); Acore::GameObjectWorker<FrozenThroneResetWorker> worker(me, reset);
me->VisitNearbyGridObject(333.0f, worker); Cell::VisitGridObjects(me, worker, 333.0f);
me->AddAura(SPELL_EMOTE_SIT_NO_SHEATH, me); me->AddAura(SPELL_EMOTE_SIT_NO_SHEATH, me);
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC);
@@ -206,7 +206,7 @@ public:
bool Execute(uint64 /*currTime*/, uint32 /*diff*/) override bool Execute(uint64 /*currTime*/, uint32 /*diff*/) override
{ {
Acore::CreatureWorker<ValithriaDespawner> worker(_creature, *this); Acore::CreatureWorker<ValithriaDespawner> worker(_creature, *this);
_creature->VisitNearbyGridObject(333.0f, worker); Cell::VisitGridObjects(_creature, worker, 333.0f);
_creature->AI()->Reset(); _creature->AI()->Reset();
_creature->setActive(false); _creature->setActive(false);
return true; return true;
@@ -526,7 +526,7 @@ public:
std::list<Creature*> archmages; std::list<Creature*> archmages;
RisenArchmageCheck check; RisenArchmageCheck check;
Acore::CreatureListSearcher<RisenArchmageCheck> searcher(me, archmages, check); Acore::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) for (std::list<Creature*>::iterator itr = archmages.begin(); itr != archmages.end(); ++itr)
(*itr)->AI()->DoAction(ACTION_ENTER_COMBAT); (*itr)->AI()->DoAction(ACTION_ENTER_COMBAT);
} }
@@ -841,7 +841,7 @@ public:
std::list<Creature*> temp; std::list<Creature*> temp;
FrostwingVrykulSearcher check(me, 150.0f); FrostwingVrykulSearcher check(me, 150.0f);
Acore::CreatureListSearcher<FrostwingVrykulSearcher> searcher(me, temp, check); Acore::CreatureListSearcher<FrostwingVrykulSearcher> searcher(me, temp, check);
me->VisitNearbyGridObject(150.0f, searcher); Cell::VisitGridObjects(me, searcher, 150.0f);
_aliveTrash.clear(); _aliveTrash.clear();
for (std::list<Creature*>::iterator itr = temp.begin(); itr != temp.end(); ++itr) for (std::list<Creature*>::iterator itr = temp.begin(); itr != temp.end(); ++itr)
@@ -886,14 +886,14 @@ public:
Player* player = nullptr; Player* player = nullptr;
Acore::AnyPlayerInObjectRangeCheck check(me, 140.0f); Acore::AnyPlayerInObjectRangeCheck check(me, 140.0f);
Acore::PlayerSearcher<Acore::AnyPlayerInObjectRangeCheck> searcher(me, player, check); Acore::PlayerSearcher<Acore::AnyPlayerInObjectRangeCheck> searcher(me, player, check);
me->VisitNearbyWorldObject(140.0f, searcher); Cell::VisitWorldObjects(me, searcher, 140.0f);
// wipe // wipe
if (!player || me->GetExactDist(4357.0f, 2606.0f, 350.0f) > 125.0f) if (!player || me->GetExactDist(4357.0f, 2606.0f, 350.0f) > 125.0f)
{ {
//Talk(SAY_CROK_DEATH); //Talk(SAY_CROK_DEATH);
FrostwingGauntletRespawner respawner; FrostwingGauntletRespawner respawner;
Acore::CreatureWorker<FrostwingGauntletRespawner> worker(me, respawner); Acore::CreatureWorker<FrostwingGauntletRespawner> worker(me, respawner);
me->VisitNearbyGridObject(333.0f, worker); Cell::VisitGridObjects(me, worker, 333.0f);
return; return;
} }
} }
@@ -1363,7 +1363,7 @@ public:
Creature* target = nullptr; Creature* target = nullptr;
Acore::MostHPMissingInRange u_check(me, 60.0f, 0); Acore::MostHPMissingInRange u_check(me, 60.0f, 0);
Acore::CreatureLastSearcher<Acore::MostHPMissingInRange> searcher(me, target, u_check); Acore::CreatureLastSearcher<Acore::MostHPMissingInRange> searcher(me, target, u_check);
me->VisitNearbyGridObject(60.0f, searcher); Cell::VisitGridObjects(me, searcher, 60.0f);
return target; return target;
} }
}; };
@@ -2333,7 +2333,7 @@ public:
{ {
FrostwingGauntletRespawner respawner; FrostwingGauntletRespawner respawner;
Acore::CreatureWorker<FrostwingGauntletRespawner> worker(crok, respawner); Acore::CreatureWorker<FrostwingGauntletRespawner> worker(crok, respawner);
crok->VisitNearbyGridObject(333.0f, worker); Cell::VisitGridObjects(crok, worker, 333.0f);
return true; return true;
} }
else else
@@ -1198,7 +1198,7 @@ public:
Unit* target = nullptr; Unit* target = nullptr;
Acore::AnyUnfriendlyUnitInObjectRangeCheck u_check(me, me, 0.5f); Acore::AnyUnfriendlyUnitInObjectRangeCheck u_check(me, me, 0.5f);
Acore::UnitLastSearcher<Acore::AnyUnfriendlyUnitInObjectRangeCheck> searcher(me, target, u_check); Acore::UnitLastSearcher<Acore::AnyUnfriendlyUnitInObjectRangeCheck> searcher(me, target, u_check);
me->VisitNearbyObject(1.5f, searcher); Cell::VisitAllObjects(me, searcher, 1.5f);
if (target) if (target)
{ {
me->CastSpell(me, SPELL_FROGGER_EXPLODE, true); me->CastSpell(me, SPELL_FROGGER_EXPLODE, true);
@@ -1711,7 +1711,7 @@ public:
std::list<WorldObject*> targetList; std::list<WorldObject*> targetList;
Acore::WorldObjectSpellAreaTargetCheck check(99, GetExplTargetDest(), GetCaster(), GetCaster(), GetSpellInfo(), TARGET_CHECK_DEFAULT, nullptr); Acore::WorldObjectSpellAreaTargetCheck check(99, GetExplTargetDest(), GetCaster(), GetCaster(), GetSpellInfo(), TARGET_CHECK_DEFAULT, nullptr);
Acore::WorldObjectListSearcher<Acore::WorldObjectSpellAreaTargetCheck> searcher(GetCaster(), targetList, check); Acore::WorldObjectListSearcher<Acore::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; float minDist = 99 * 99;
Unit* target = nullptr; Unit* target = nullptr;
for (std::list<WorldObject*>::iterator itr = targetList.begin(); itr != targetList.end(); ++itr) for (std::list<WorldObject*>::iterator itr = targetList.begin(); itr != targetList.end(); ++itr)
@@ -774,7 +774,7 @@ public:
go->Delete(); go->Delete();
WretchedGhoulCleaner cleaner; WretchedGhoulCleaner cleaner;
Acore::CreatureWorker<WretchedGhoulCleaner> worker(me, cleaner); Acore::CreatureWorker<WretchedGhoulCleaner> worker(me, cleaner);
me->VisitNearbyGridObject(150.0f, worker); Cell::VisitGridObjects(me, worker, 150.0f);
} }
void Reset() override void Reset() override
@@ -988,7 +988,7 @@ public:
{ {
WretchedGhoulCleaner cleaner; WretchedGhoulCleaner cleaner;
Acore::CreatureWorker<WretchedGhoulCleaner> worker(me, cleaner); Acore::CreatureWorker<WretchedGhoulCleaner> 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* c = me->FindNearestCreature(NPC_SAC_LIGHTS_VENGEANCE, 150.0f, true))
if (Creature* v = me->FindNearestCreature(NPC_SAC_VEGARD_1, 50.0f, true)) if (Creature* v = me->FindNearestCreature(NPC_SAC_VEGARD_1, 50.0f, true))
@@ -699,7 +699,7 @@ public:
std::list<WorldObject*> ClusterList; std::list<WorldObject*> ClusterList;
Acore::AllWorldObjectsInRange objects(me, searchDistance); Acore::AllWorldObjectsInRange objects(me, searchDistance);
Acore::WorldObjectListSearcher<Acore::AllWorldObjectsInRange> searcher(me, ClusterList, objects); Acore::WorldObjectListSearcher<Acore::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) for (std::list<WorldObject*>::const_iterator i = ClusterList.begin(); i != ClusterList.end(); ++i)
{ {
+1 -1
View File
@@ -157,7 +157,7 @@ public:
std::list<Unit*> targets; std::list<Unit*> targets;
Acore::AnyUnfriendlyUnitInObjectRangeCheck u_check(me, me, 50); Acore::AnyUnfriendlyUnitInObjectRangeCheck u_check(me, me, 50);
Acore::UnitListSearcher<Acore::AnyUnfriendlyUnitInObjectRangeCheck> searcher(me, targets, u_check); Acore::UnitListSearcher<Acore::AnyUnfriendlyUnitInObjectRangeCheck> searcher(me, targets, u_check);
me->VisitNearbyObject(50, searcher); Cell::VisitAllObjects(me, searcher, 50.0f);
for (std::list<Unit*>::const_iterator iter = targets.begin(); iter != targets.end(); ++iter) for (std::list<Unit*>::const_iterator iter = targets.begin(); iter != targets.end(); ++iter)
if ((*iter)->GetAura(SPELL_DK_SUMMON_GARGOYLE_1, me->GetOwnerGUID())) if ((*iter)->GetAura(SPELL_DK_SUMMON_GARGOYLE_1, me->GetOwnerGUID()))
{ {
+7 -1
View File
@@ -1721,9 +1721,15 @@ public:
// search for nearby enemy corpse in range // search for nearby enemy corpse in range
Acore::AnyDeadUnitSpellTargetInRangeCheck check(caster, max_range, GetSpellInfo(), TARGET_CHECK_CORPSE); Acore::AnyDeadUnitSpellTargetInRangeCheck check(caster, max_range, GetSpellInfo(), TARGET_CHECK_CORPSE);
Acore::WorldObjectSearcher<Acore::AnyDeadUnitSpellTargetInRangeCheck> searcher(caster, result, check); Acore::WorldObjectSearcher<Acore::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) if (!result)
{
Cell::VisitGridObjects(caster, searcher, max_range);
}
if (!result)
{
return SPELL_FAILED_NO_EDIBLE_CORPSES; return SPELL_FAILED_NO_EDIBLE_CORPSES;
}
return SPELL_CAST_OK; return SPELL_CAST_OK;
} }
+7 -1
View File
@@ -979,9 +979,15 @@ public:
// search for nearby enemy corpse in range // search for nearby enemy corpse in range
Acore::AnyDeadUnitSpellTargetInRangeCheck check(caster, max_range, GetSpellInfo(), TARGET_CHECK_ENEMY); Acore::AnyDeadUnitSpellTargetInRangeCheck check(caster, max_range, GetSpellInfo(), TARGET_CHECK_ENEMY);
Acore::WorldObjectSearcher<Acore::AnyDeadUnitSpellTargetInRangeCheck> searcher(caster, result, check); Acore::WorldObjectSearcher<Acore::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) if (!result)
{
Cell::VisitGridObjects(caster, searcher, max_range);
}
if (!result)
{
return SPELL_FAILED_NO_EDIBLE_CORPSES; return SPELL_FAILED_NO_EDIBLE_CORPSES;
}
return SPELL_CAST_OK; return SPELL_CAST_OK;
} }
+1 -1
View File
@@ -2428,7 +2428,7 @@ public:
std::list<Player*> playerList; std::list<Player*> playerList;
Acore::AnyPlayerInObjectRangeCheck checker(caster, 65.0f); Acore::AnyPlayerInObjectRangeCheck checker(caster, 65.0f);
Acore::PlayerListSearcher<Acore::AnyPlayerInObjectRangeCheck> searcher(caster, playerList, checker); Acore::PlayerListSearcher<Acore::AnyPlayerInObjectRangeCheck> searcher(caster, playerList, checker);
caster->VisitNearbyWorldObject(65.0f, searcher); Cell::VisitWorldObjects(caster, searcher, 65.0f);
for (std::list<Player*>::const_iterator itr = playerList.begin(); itr != playerList.end(); ++itr) 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 // 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)) if ((*itr)->HasAuraType(SPELL_AURA_FLY) || (*itr)->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED))
+2 -2
View File
@@ -351,7 +351,7 @@ public:
std::list<Player*> players; std::list<Player*> players;
Acore::AnyPlayerExactPositionInGameObjectRangeCheck checker(go, 0.3f); Acore::AnyPlayerExactPositionInGameObjectRangeCheck checker(go, 0.3f);
Acore::PlayerListSearcher<Acore::AnyPlayerExactPositionInGameObjectRangeCheck> searcher(go, players, checker); Acore::PlayerListSearcher<Acore::AnyPlayerExactPositionInGameObjectRangeCheck> searcher(go, players, checker);
go->VisitNearbyWorldObject(0.3f, searcher); Cell::VisitWorldObjects(go, searcher, 0.3f);
if (players.size() > 0) if (players.size() > 0)
{ {
@@ -398,7 +398,7 @@ public:
std::list<Player*> players; std::list<Player*> players;
Acore::AnyPlayerExactPositionInGameObjectRangeCheck checker(go, 0.3f); Acore::AnyPlayerExactPositionInGameObjectRangeCheck checker(go, 0.3f);
Acore::PlayerListSearcher<Acore::AnyPlayerExactPositionInGameObjectRangeCheck> searcher(go, players, checker); Acore::PlayerListSearcher<Acore::AnyPlayerExactPositionInGameObjectRangeCheck> searcher(go, players, checker);
go->VisitNearbyWorldObject(0.3f, searcher); Cell::VisitWorldObjects(go, searcher, 0.3f);
if (players.size() > 0) if (players.size() > 0)
{ {