2012-01-29 14:28:19 -05:00
|
|
|
|
|
|
|
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
|
|
|
|
|
2011-12-25 20:07:35 -05:00
|
|
|
#include "cPacket_PlayerListItem.h"
|
2012-01-27 09:04:28 -05:00
|
|
|
#include "../cChatColor.h"
|
2011-12-25 20:07:35 -05:00
|
|
|
|
2012-01-29 14:28:19 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-02-07 15:49:52 -05:00
|
|
|
cPacket_PlayerListItem::cPacket_PlayerListItem(const AString & a_PlayerName, bool a_Online, short a_Ping)
|
2011-12-25 21:35:49 -05:00
|
|
|
{
|
|
|
|
m_PacketID = E_PLAYER_LIST_ITEM;
|
|
|
|
m_PlayerName = a_PlayerName;
|
|
|
|
m_Online = a_Online;
|
|
|
|
m_Ping = a_Ping;
|
|
|
|
}
|
|
|
|
|
2012-02-07 15:49:52 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int cPacket_PlayerListItem::Parse(const char * a_Data, int a_Size)
|
2011-12-25 20:07:35 -05:00
|
|
|
{
|
2012-02-07 15:49:52 -05:00
|
|
|
int TotalBytes = 0;
|
|
|
|
HANDLE_PACKET_READ(ReadString16, m_PlayerName, TotalBytes);
|
|
|
|
HANDLE_PACKET_READ(ReadBool, m_Online, TotalBytes);
|
|
|
|
HANDLE_PACKET_READ(ReadShort, m_Ping, TotalBytes);
|
|
|
|
return TotalBytes;
|
2011-12-25 20:07:35 -05:00
|
|
|
}
|
|
|
|
|
2012-02-07 15:49:52 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void cPacket_PlayerListItem::Serialize(AString & a_Data) const
|
2011-12-25 20:07:35 -05:00
|
|
|
{
|
2012-02-07 15:49:52 -05:00
|
|
|
AString PlayerName(m_PlayerName);
|
|
|
|
if (PlayerName.length() > 16)
|
|
|
|
{
|
|
|
|
PlayerName.erase(16);
|
|
|
|
}
|
|
|
|
else if (PlayerName.length() <= 14)
|
|
|
|
{
|
|
|
|
PlayerName += cChatColor::White;
|
|
|
|
}
|
|
|
|
|
|
|
|
AppendByte (a_Data, m_PacketID);
|
|
|
|
AppendString16(a_Data, PlayerName);
|
|
|
|
AppendBool (a_Data, m_Online);
|
|
|
|
AppendShort (a_Data, m_Ping);
|
2011-12-25 20:07:35 -05:00
|
|
|
}
|
2012-02-07 15:49:52 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|