Permalink
Browse files

Core/Battleground: Simplified Battleground::SendPacketToTeam

  • Loading branch information...
joschiwald committed Jan 12, 2018
1 parent 3d7af56 commit 61ce48e782e8cb5d980334d4e0bb4fcf0f5e9559
Showing with 7 additions and 13 deletions.
  1. +6 −12 src/server/game/Battlegrounds/Battleground.cpp
  2. +1 −1 src/server/game/Battlegrounds/Battleground.h
@@ -673,15 +673,13 @@ void Battleground::SendPacketToAll(WorldPacket const* packet) const
player->SendDirectMessage(packet);
}
void Battleground::SendPacketToTeam(uint32 TeamID, WorldPacket const* packet, Player* sender, bool self) const
void Battleground::SendPacketToTeam(uint32 teamId, WorldPacket const* packet, Player* except /*= nullptr*/) const
{
for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
{
if (Player* player = _GetPlayerForTeam(TeamID, itr, "SendPacketToTeam"))
{
if (self || sender != player)
if (Player* player = _GetPlayerForTeam(teamId, itr, "SendPacketToTeam"))
if (player != except)
player->SendDirectMessage(packet);
}
}
}
@@ -697,11 +695,7 @@ void Battleground::PlaySoundToAll(uint32 soundID)
void Battleground::PlaySoundToTeam(uint32 soundID, uint32 teamID)
{
for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
{
if (Player* player = _GetPlayerForTeam(teamID, itr, "PlaySoundToTeam"))
player->SendDirectMessage(WorldPackets::Misc::PlaySound(ObjectGuid::Empty, soundID).Write());
}
SendPacketToTeam(teamID, WorldPackets::Misc::PlaySound(ObjectGuid::Empty, soundID).Write());
}
void Battleground::CastSpellOnTeam(uint32 SpellID, uint32 TeamID)
@@ -1024,7 +1018,7 @@ void Battleground::RemovePlayerAtLeave(ObjectGuid guid, bool Transport, bool Sen
// Let others know
WorldPackets::Battleground::BattlegroundPlayerLeft playerLeft;
playerLeft.Guid = guid;
SendPacketToTeam(team, playerLeft.Write(), player, false);
SendPacketToTeam(team, playerLeft.Write(), player);
}
if (player)
@@ -1114,7 +1108,7 @@ void Battleground::AddPlayer(Player* player)
WorldPackets::Battleground::BattlegroundPlayerJoined playerJoined;
playerJoined.Guid = player->GetGUID();
SendPacketToTeam(team, playerJoined.Write(), player, false);
SendPacketToTeam(team, playerJoined.Write(), player);
// BG Status packet
BattlegroundQueueTypeId bgQueueTypeId = sBattlegroundMgr->BGQueueTypeId(m_TypeID, GetArenaType());
@@ -376,7 +376,7 @@ class TC_GAME_API Battleground
// Packet Transfer
// method that should fill worldpacket with actual world states (not yet implemented for all battlegrounds!)
virtual void FillInitialWorldStates(WorldPackets::WorldState::InitWorldStates& /*data*/) { }
void SendPacketToTeam(uint32 TeamID, WorldPacket const* packet, Player* sender = NULL, bool self = true) const;
void SendPacketToTeam(uint32 teamId, WorldPacket const* packet, Player* except = nullptr) const;
void SendPacketToAll(WorldPacket const* packet) const;
void SendChatMessage(Creature* source, uint8 textId, WorldObject* target = NULL);

0 comments on commit 61ce48e

Please sign in to comment.