*Rewrite and simplify sendmessagetoset functions. This fixes the bug that player cannot see dummy aura is cancelled when puppet is far away.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-08-12 23:23:53 -05:00
parent 92769d3ffe
commit 7292420583
5 changed files with 19 additions and 73 deletions
+5 -13
View File
@@ -110,11 +110,10 @@ namespace Trinity
WorldPacket *i_message; WorldPacket *i_message;
uint32 i_phaseMask; uint32 i_phaseMask;
float i_distSq; float i_distSq;
bool self;
uint32 team; 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()) : 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); void Visit(PlayerMapType &m);
@@ -124,16 +123,9 @@ namespace Trinity
void SendPacket(Player* plr) void SendPacket(Player* plr)
{ {
if(!self) // never send packet to self
{ if(plr == i_source || team && plr->GetTeam() != team)
if(plr == i_source) return;
return;
}
else if(team)
{
if(plr->GetTeam() != team)
return;
}
plr->GetSession()->SendPacket(i_message); plr->GetSession()->SendPacket(i_message);
} }
-24
View File
@@ -486,30 +486,6 @@ Map::Add(T *obj)
AddNotifier(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 bool Map::loaded(const GridPair &p) const
{ {
return ( getNGrid(p.x_coord, p.y_coord) && isGridObjectDataLoaded(p.x_coord, p.y_coord) ); return ( getNGrid(p.x_coord, p.y_coord) && isGridObjectDataLoaded(p.x_coord, p.y_coord) );
-5
View File
@@ -282,11 +282,6 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>, public MaNGOS::Obj
virtual void Update(const uint32&); 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 PlayerRelocation(Player *, float x, float y, float z, float angl);
void CreatureRelocation(Creature *creature, float x, float y, float, float); void CreatureRelocation(Creature *creature, float x, float y, float, float);
+4 -8
View File
@@ -1680,18 +1680,14 @@ void Unit::BuildHeartBeatMsg(WorldPacket *data) const
void WorldObject::SendMessageToSet(WorldPacket *data, bool /*fake*/) void WorldObject::SendMessageToSet(WorldPacket *data, bool /*fake*/)
{ {
//if object is in world, map for it already created! Trinity::MessageDistDeliverer notifier(this, data, World::GetMaxVisibleDistance());
Map * _map = IsInWorld() ? GetMap() : MapManager::Instance().FindMap(GetMapId(), GetInstanceId()); VisitNearbyWorldObject(World::GetMaxVisibleDistance(), notifier);
if(_map)
_map->MessageBroadcast(this, data);
} }
void WorldObject::SendMessageToSetInRange(WorldPacket *data, float dist, bool /*bToSelf*/) void WorldObject::SendMessageToSetInRange(WorldPacket *data, float dist, bool /*bToSelf*/)
{ {
//if object is in world, map for it already created! Trinity::MessageDistDeliverer notifier(this, data, dist);
Map * _map = IsInWorld() ? GetMap() : MapManager::Instance().FindMap(GetMapId(), GetInstanceId()); VisitNearbyWorldObject(dist, notifier);
if(_map)
_map->MessageDistBroadcast(this, data, dist);
} }
void WorldObject::SendObjectDeSpawnAnim(uint64 guid) void WorldObject::SendObjectDeSpawnAnim(uint64 guid)
+10 -23
View File
@@ -5813,43 +5813,30 @@ void Player::SaveRecallPosition()
void Player::SendMessageToSet(WorldPacket *data, bool self) 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) if(self)
GetSession()->SendPacket(data); 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) 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) if(self)
GetSession()->SendPacket(data); 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) 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) if(self)
GetSession()->SendPacket(data); GetSession()->SendPacket(data);
Trinity::MessageDistDeliverer notifier(this, data, dist, own_team_only);
VisitNearbyWorldObject(dist, notifier);
} }
void Player::SendDirectMessage(WorldPacket *data) void Player::SendDirectMessage(WorldPacket *data)