(cherry picked from commit 9299e9bde0)
This commit is contained in:
Shauren
2017-05-13 19:37:33 +02:00
committed by ariel-
parent 7874bee7bf
commit d6201e5dbb
57 changed files with 236 additions and 404 deletions

View File

@@ -1769,13 +1769,13 @@ void WorldObject::SendMessageToSet(WorldPacket const* data, bool self)
void WorldObject::SendMessageToSetInRange(WorldPacket const* data, float dist, bool /*self*/)
{
Trinity::MessageDistDeliverer notifier(this, data, dist);
VisitNearbyWorldObject(dist, notifier);
Cell::VisitWorldObjects(this, notifier, dist);
}
void WorldObject::SendMessageToSet(WorldPacket const* data, Player const* skipped_rcvr)
{
Trinity::MessageDistDeliverer notifier(this, data, GetVisibilityRange(), false, skipped_rcvr);
VisitNearbyWorldObject(GetVisibilityRange(), notifier);
Cell::VisitWorldObjects(this, notifier, GetVisibilityRange());
}
void WorldObject::SendObjectDeSpawnAnim(ObjectGuid guid)
@@ -1925,7 +1925,7 @@ TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropert
// call MoveInLineOfSight for nearby creatures
Trinity::AIRelocationNotifier notifier(*summon);
summon->VisitNearbyObject(GetVisibilityRange(), notifier);
Cell::VisitAllObjects(summon, notifier, GetVisibilityRange());
return summon;
}
@@ -2086,7 +2086,7 @@ Creature* WorldObject::FindNearestCreature(uint32 entry, float range, bool alive
Creature* creature = nullptr;
Trinity::NearestCreatureEntryWithLiveStateInObjectRangeCheck checker(*this, entry, alive, range);
Trinity::CreatureLastSearcher<Trinity::NearestCreatureEntryWithLiveStateInObjectRangeCheck> searcher(this, creature, checker);
VisitNearbyObject(range, searcher);
Cell::VisitAllObjects(this, searcher, range);
return creature;
}
@@ -2095,7 +2095,7 @@ GameObject* WorldObject::FindNearestGameObject(uint32 entry, float range) const
GameObject* go = nullptr;
Trinity::NearestGameObjectEntryInObjectRangeCheck checker(*this, entry, range);
Trinity::GameObjectLastSearcher<Trinity::NearestGameObjectEntryInObjectRangeCheck> searcher(this, go, checker);
VisitNearbyGridObject(range, searcher);
Cell::VisitGridObjects(this, searcher, range);
return go;
}
@@ -2104,7 +2104,7 @@ GameObject* WorldObject::FindNearestGameObjectOfType(GameobjectTypes type, float
GameObject* go = nullptr;
Trinity::NearestGameObjectTypeInObjectRangeCheck checker(*this, type, range);
Trinity::GameObjectLastSearcher<Trinity::NearestGameObjectTypeInObjectRangeCheck> searcher(this, go, checker);
VisitNearbyGridObject(range, searcher);
Cell::VisitGridObjects(this, searcher, range);
return go;
}
@@ -2114,7 +2114,7 @@ Player* WorldObject::SelectNearestPlayer(float distance) const
Trinity::NearestPlayerInObjectRangeCheck checker(this, distance);
Trinity::PlayerLastSearcher<Trinity::NearestPlayerInObjectRangeCheck> searcher(this, target, checker);
VisitNearbyObject(distance, searcher);
Cell::VisitWorldObjects(this, searcher, distance);
return target;
}
@@ -2123,28 +2123,17 @@ template <typename Container>
void WorldObject::GetGameObjectListWithEntryInGrid(Container& gameObjectContainer, uint32 entry, float maxSearchRange /*= 250.0f*/) const
{
CellCoord pair(Trinity::ComputeCellCoord(GetPositionX(), GetPositionY()));
Cell cell(pair);
cell.SetNoCreate();
Trinity::AllGameObjectsWithEntryInRange check(this, entry, maxSearchRange);
Trinity::GameObjectListSearcher<Trinity::AllGameObjectsWithEntryInRange> searcher(this, gameObjectContainer, check);
TypeContainerVisitor<Trinity::GameObjectListSearcher<Trinity::AllGameObjectsWithEntryInRange>, GridTypeMapContainer> visitor(searcher);
cell.Visit(pair, visitor, *GetMap(), *this, maxSearchRange);
Cell::VisitGridObjects(this, searcher, maxSearchRange);
}
template <typename Container>
void WorldObject::GetCreatureListWithEntryInGrid(Container& creatureContainer, uint32 entry, float maxSearchRange /*= 250.0f*/) const
{
CellCoord pair(Trinity::ComputeCellCoord(GetPositionX(), GetPositionY()));
Cell cell(pair);
cell.SetNoCreate();
Trinity::AllCreaturesOfEntryInRange check(this, entry, maxSearchRange);
Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange> searcher(this, creatureContainer, check);
TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange>, GridTypeMapContainer> visitor(searcher);
cell.Visit(pair, visitor, *GetMap(), *this, maxSearchRange);
Cell::VisitGridObjects(this, searcher, maxSearchRange);
}
template <typename Container>
@@ -2152,7 +2141,7 @@ void WorldObject::GetPlayerListInGrid(Container& playerContainer, float maxSearc
{
Trinity::AnyPlayerInObjectRangeCheck checker(this, maxSearchRange);
Trinity::PlayerListSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(this, playerContainer, checker);
VisitNearbyWorldObject(maxSearchRange, searcher);
Cell::VisitWorldObjects(this, searcher, maxSearchRange);
}
void WorldObject::GetNearPoint2D(float &x, float &y, float distance2d, float absAngle) const
@@ -2419,7 +2408,7 @@ void WorldObject::DestroyForNearbyPlayers()
std::list<Player*> targets;
Trinity::AnyPlayerInObjectRangeCheck check(this, GetVisibilityRange(), false);
Trinity::PlayerListSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(this, targets, check);
VisitNearbyWorldObject(GetVisibilityRange(), searcher);
Cell::VisitWorldObjects(this, searcher, GetVisibilityRange());
for (std::list<Player*>::const_iterator iter = targets.begin(); iter != targets.end(); ++iter)
{
Player* player = (*iter);
@@ -2446,7 +2435,7 @@ void WorldObject::UpdateObjectVisibility(bool /*forced*/)
{
//updates object's visibility for nearby players
Trinity::VisibleChangesNotifier notifier(*this);
VisitNearbyWorldObject(GetVisibilityRange(), notifier);
Cell::VisitWorldObjects(this, notifier, GetVisibilityRange());
}
struct WorldObjectChangeAccumulator
@@ -2521,14 +2510,9 @@ struct WorldObjectChangeAccumulator
void WorldObject::BuildUpdate(UpdateDataMapType& data_map)
{
CellCoord p = Trinity::ComputeCellCoord(GetPositionX(), GetPositionY());
Cell cell(p);
cell.SetNoCreate();
WorldObjectChangeAccumulator notifier(*this, data_map);
TypeContainerVisitor<WorldObjectChangeAccumulator, WorldTypeMapContainer > player_notifier(notifier);
Map& map = *GetMap();
//we must build packets for all visible players
cell.Visit(p, player_notifier, map, *this, GetVisibilityRange());
Cell::VisitWorldObjects(this, notifier, GetVisibilityRange());
ClearUpdateMask(false);
}