diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/game/GridNotifiers.h | 18 | ||||
-rw-r--r-- | src/game/Map.cpp | 24 | ||||
-rw-r--r-- | src/game/Map.h | 5 | ||||
-rw-r--r-- | src/game/Object.cpp | 12 | ||||
-rw-r--r-- | src/game/Player.cpp | 33 |
5 files changed, 19 insertions, 73 deletions
diff --git a/src/game/GridNotifiers.h b/src/game/GridNotifiers.h index 997f0806369..e11e1210ff5 100644 --- a/src/game/GridNotifiers.h +++ b/src/game/GridNotifiers.h @@ -110,11 +110,10 @@ namespace Trinity WorldPacket *i_message; uint32 i_phaseMask; float i_distSq; - bool self; uint32 team; - MessageDistDeliverer(WorldObject *src, WorldPacket *msg, float dist, bool to_self = true, bool own_team_only = false) + MessageDistDeliverer(WorldObject *src, WorldPacket *msg, float dist, bool own_team_only = false) : i_source(src), i_message(msg), i_distSq(dist * dist), i_phaseMask(src->GetPhaseMask()) - , self(to_self || src->GetTypeId() != TYPEID_PLAYER), team((own_team_only && src->GetTypeId() == TYPEID_PLAYER) ? ((Player*)src)->GetTeam() : 0) + , team((own_team_only && src->GetTypeId() == TYPEID_PLAYER) ? ((Player*)src)->GetTeam() : 0) { } void Visit(PlayerMapType &m); @@ -124,16 +123,9 @@ namespace Trinity void SendPacket(Player* plr) { - if(!self) - { - if(plr == i_source) - return; - } - else if(team) - { - if(plr->GetTeam() != team) - return; - } + // never send packet to self + if(plr == i_source || team && plr->GetTeam() != team) + return; plr->GetSession()->SendPacket(i_message); } diff --git a/src/game/Map.cpp b/src/game/Map.cpp index d2f1fe7c619..341cd59960f 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -486,30 +486,6 @@ Map::Add(T *obj) AddNotifier(obj); } -void Map::MessageBroadcast(Player *player, WorldPacket *msg, bool to_self) -{ - Trinity::MessageDistDeliverer post_man(player, msg, World::GetMaxVisibleDistance(), to_self); - VisitWorld(player->GetPositionX(), player->GetPositionY(), World::GetMaxVisibleDistance(), post_man); -} - -void Map::MessageBroadcast(WorldObject *obj, WorldPacket *msg) -{ - Trinity::MessageDistDeliverer post_man(obj, msg, World::GetMaxVisibleDistance()); - VisitWorld(obj->GetPositionX(), obj->GetPositionY(), World::GetMaxVisibleDistance(), post_man); -} - -void Map::MessageDistBroadcast(Player *player, WorldPacket *msg, float dist, bool to_self, bool own_team_only) -{ - Trinity::MessageDistDeliverer post_man(player, msg, dist, to_self, own_team_only); - VisitWorld(player->GetPositionX(), player->GetPositionY(), dist, post_man); -} - -void Map::MessageDistBroadcast(WorldObject *obj, WorldPacket *msg, float dist) -{ - Trinity::MessageDistDeliverer post_man(obj, msg, dist); - VisitWorld(obj->GetPositionX(), obj->GetPositionY(), dist, post_man); -} - bool Map::loaded(const GridPair &p) const { return ( getNGrid(p.x_coord, p.y_coord) && isGridObjectDataLoaded(p.x_coord, p.y_coord) ); diff --git a/src/game/Map.h b/src/game/Map.h index 6fd9bb1d9fb..eb2b1cbe553 100644 --- a/src/game/Map.h +++ b/src/game/Map.h @@ -282,11 +282,6 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>, public MaNGOS::Obj virtual void Update(const uint32&); - void MessageBroadcast(Player *, WorldPacket *, bool to_self); - void MessageBroadcast(WorldObject *, WorldPacket *); - void MessageDistBroadcast(Player *, WorldPacket *, float dist, bool to_self, bool own_team_only = false); - void MessageDistBroadcast(WorldObject *, WorldPacket *, float dist); - void PlayerRelocation(Player *, float x, float y, float z, float angl); void CreatureRelocation(Creature *creature, float x, float y, float, float); diff --git a/src/game/Object.cpp b/src/game/Object.cpp index 3b451bbbc51..edf7f949d26 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -1680,18 +1680,14 @@ void Unit::BuildHeartBeatMsg(WorldPacket *data) const void WorldObject::SendMessageToSet(WorldPacket *data, bool /*fake*/) { - //if object is in world, map for it already created! - Map * _map = IsInWorld() ? GetMap() : MapManager::Instance().FindMap(GetMapId(), GetInstanceId()); - if(_map) - _map->MessageBroadcast(this, data); + Trinity::MessageDistDeliverer notifier(this, data, World::GetMaxVisibleDistance()); + VisitNearbyWorldObject(World::GetMaxVisibleDistance(), notifier); } void WorldObject::SendMessageToSetInRange(WorldPacket *data, float dist, bool /*bToSelf*/) { - //if object is in world, map for it already created! - Map * _map = IsInWorld() ? GetMap() : MapManager::Instance().FindMap(GetMapId(), GetInstanceId()); - if(_map) - _map->MessageDistBroadcast(this, data, dist); + Trinity::MessageDistDeliverer notifier(this, data, dist); + VisitNearbyWorldObject(dist, notifier); } void WorldObject::SendObjectDeSpawnAnim(uint64 guid) diff --git a/src/game/Player.cpp b/src/game/Player.cpp index b43caaa3c40..4f41bb44cda 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -5813,43 +5813,30 @@ void Player::SaveRecallPosition() void Player::SendMessageToSet(WorldPacket *data, bool self) { - Map * _map = IsInWorld() ? GetMap() : MapManager::Instance().FindMap(GetMapId(), GetInstanceId()); - if(_map) - { - _map->MessageBroadcast(this, data, self); - return; - } - - //if player is not in world and map in not created/already destroyed - //no need to create one, just send packet for itself! if(self) GetSession()->SendPacket(data); + + // we use World::GetMaxVisibleDistance() because i cannot see why not use a distance + Trinity::MessageDistDeliverer notifier(this, data, World::GetMaxVisibleDistance()); + VisitNearbyWorldObject(World::GetMaxVisibleDistance(), notifier); } void Player::SendMessageToSetInRange(WorldPacket *data, float dist, bool self) { - Map * _map = IsInWorld() ? GetMap() : MapManager::Instance().FindMap(GetMapId(), GetInstanceId()); - if(_map) - { - _map->MessageDistBroadcast(this, data, dist, self); - return; - } - if(self) GetSession()->SendPacket(data); + + Trinity::MessageDistDeliverer notifier(this, data, dist); + VisitNearbyWorldObject(dist, notifier); } void Player::SendMessageToSetInRange(WorldPacket *data, float dist, bool self, bool own_team_only) { - Map * _map = IsInWorld() ? GetMap() : MapManager::Instance().FindMap(GetMapId(), GetInstanceId()); - if(_map) - { - _map->MessageDistBroadcast(this, data, dist, self, own_team_only); - return; - } - if(self) GetSession()->SendPacket(data); + + Trinity::MessageDistDeliverer notifier(this, data, dist, own_team_only); + VisitNearbyWorldObject(dist, notifier); } void Player::SendDirectMessage(WorldPacket *data) |