Skip to content

Commit

Permalink
[10201] Broadcast packets only if worldobject is in world
Browse files Browse the repository at this point in the history
There is no sense to do that for objects that not in world - those objects are unknown for clients
and their packets will be ignored

(based on SilverIce's repo commit 6305402)

Signed-off-by: VladimirMangos <vladimir@getmangos.com>
  • Loading branch information
SilverIce authored and VladimirMangos committed Jul 16, 2010
1 parent 45a4050 commit 407789d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
13 changes: 6 additions & 7 deletions src/game/Object.cpp
Expand Up @@ -1572,25 +1572,24 @@ void WorldObject::BuildMonsterChat(WorldPacket *data, uint8 msgtype, char const*
void WorldObject::SendMessageToSet(WorldPacket *data, bool /*bToSelf*/)
{
//if object is in world, map for it already created!
Map * _map = IsInWorld() ? GetMap() : sMapMgr.FindMap(GetMapId(), GetInstanceId());
if(_map)
_map->MessageBroadcast(this, data);
if (IsInWorld())
GetMap()->MessageBroadcast(this, data);
}

void WorldObject::SendMessageToSetInRange(WorldPacket *data, float dist, bool /*bToSelf*/)
{
//if object is in world, map for it already created!
if (Map * _map = IsInWorld() ? GetMap() : sMapMgr.FindMap(GetMapId(), GetInstanceId()))
_map->MessageDistBroadcast(this, data, dist);
if (IsInWorld())
GetMap()->MessageDistBroadcast(this, data, dist);
}

void WorldObject::SendMessageToSetExcept(WorldPacket *data, Player const* skipped_receiver)
{
//if object is in world, map for it already created!
if (Map * _map = IsInWorld() ? GetMap() : sMapMgr.FindMap(GetMapId(), GetInstanceId()))
if (IsInWorld())
{
MaNGOS::MessageDelivererExcept notifier(this, data, skipped_receiver);
Cell::VisitWorldObjects(this, notifier, _map->GetVisibilityDistance());
Cell::VisitWorldObjects(this, notifier, GetMap()->GetVisibilityDistance());
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/game/Player.cpp
Expand Up @@ -6068,8 +6068,8 @@ void Player::SaveRecallPosition()

void Player::SendMessageToSet(WorldPacket *data, bool self)
{
if (Map * _map = IsInWorld() ? GetMap() : sMapMgr.FindMap(GetMapId(), GetInstanceId()))
_map->MessageBroadcast(this, data, false);
if (IsInWorld())
GetMap()->MessageBroadcast(this, data, false);

//if player is not in world and map in not created/already destroyed
//no need to create one, just send packet for itself!
Expand All @@ -6079,17 +6079,17 @@ void Player::SendMessageToSet(WorldPacket *data, bool self)

void Player::SendMessageToSetInRange(WorldPacket *data, float dist, bool self)
{
if (Map * _map = IsInWorld() ? GetMap() : sMapMgr.FindMap(GetMapId(), GetInstanceId()))
_map->MessageDistBroadcast(this, data, dist, false);
if (IsInWorld())
GetMap()->MessageDistBroadcast(this, data, dist, false);

if (self)
GetSession()->SendPacket(data);
}

void Player::SendMessageToSetInRange(WorldPacket *data, float dist, bool self, bool own_team_only)
{
if (Map * _map = IsInWorld() ? GetMap() : sMapMgr.FindMap(GetMapId(), GetInstanceId()))
_map->MessageDistBroadcast(this, data, dist, false, own_team_only);
if (IsInWorld())
GetMap()->MessageDistBroadcast(this, data, dist, false, own_team_only);

if (self)
GetSession()->SendPacket(data);
Expand Down
2 changes: 1 addition & 1 deletion src/game/Unit.cpp
Expand Up @@ -8961,7 +8961,7 @@ void Unit::SetPower(Powers power, uint32 val)
data << GetPackGUID();
data << uint8(power);
data << uint32(val);
SendMessageToSet(&data, GetTypeId() == TYPEID_PLAYER ? true : false);
SendMessageToSet(&data, true);

// group update
if(GetTypeId() == TYPEID_PLAYER)
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "10200"
#define REVISION_NR "10201"
#endif // __REVISION_NR_H__

0 comments on commit 407789d

Please sign in to comment.