Core/Battleground: Use a general solution for MSG_BATTLEGROUND_PLAYER_POSITIONS

This commit is contained in:
Spp
2011-09-29 10:21:33 +02:00
parent 9e517c963b
commit 8b820baa73
5 changed files with 49 additions and 62 deletions
@@ -25,7 +25,6 @@
#include "ArenaTeam.h"
#include "BattlegroundMgr.h"
#include "BattlegroundWS.h"
#include "Battleground.h"
#include "Chat.h"
#include "Language.h"
@@ -252,56 +251,42 @@ void WorldSession::HandleBattlegroundPlayerPositionsOpcode(WorldPacket & /*recv_
if (!bg) // can't be received if player not in battleground
return;
switch(bg->GetTypeID(true))
uint32 count = 0;
Player* aplr = NULL;
Player* hplr = NULL;
if (uint64 guid = bg->GetFlagPickerGUID(BG_TEAM_ALLIANCE))
{
case BATTLEGROUND_WS:
{
uint32 count = 0;
Player* aplr = ObjectAccessor::FindPlayer(((BattlegroundWS*)bg)->GetAllianceFlagPickerGUID());
if (aplr)
++count;
Player* hplr = ObjectAccessor::FindPlayer(((BattlegroundWS*)bg)->GetHordeFlagPickerGUID());
if (hplr)
++count;
WorldPacket data(MSG_BATTLEGROUND_PLAYER_POSITIONS, 4 + 4 + 16 * count);
data << 0;
data << count;
if (aplr)
{
data << uint64(aplr->GetGUID());
data << float(aplr->GetPositionX());
data << float(aplr->GetPositionY());
}
if (hplr)
{
data << uint64(hplr->GetGUID());
data << float(hplr->GetPositionX());
data << float(hplr->GetPositionY());
}
SendPacket(&data);
break;
}
case BATTLEGROUND_EY:
//TODO : fix me!
break;
case BATTLEGROUND_AB:
case BATTLEGROUND_AV:
{
WorldPacket data(MSG_BATTLEGROUND_PLAYER_POSITIONS, (4+4));
data << uint32(0);
data << uint32(0);
SendPacket(&data);
break;
}
default:
//maybe it is sent also in arena - do nothing
break;
aplr = ObjectAccessor::FindPlayer(guid);
if (aplr)
++count;
}
if (uint64 guid = bg->GetFlagPickerGUID(BG_TEAM_HORDE))
{
hplr = ObjectAccessor::FindPlayer(guid);
if (hplr)
++count;
}
WorldPacket data(MSG_BATTLEGROUND_PLAYER_POSITIONS, 4 + 4 + 16 * count);
data << 0;
data << count;
if (aplr)
{
data << uint64(aplr->GetGUID());
data << float(aplr->GetPositionX());
data << float(aplr->GetPositionY());
}
if (hplr)
{
data << uint64(hplr->GetGUID());
data << float(hplr->GetPositionX());
data << float(hplr->GetPositionY());
}
SendPacket(&data);
}
void WorldSession::HandlePVPLogDataOpcode(WorldPacket & /*recv_data*/)