summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authormtilden@gmail.com <mtilden@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2011-12-27 20:01:00 +0100
committermtilden@gmail.com <mtilden@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2011-12-27 20:01:00 +0100
commitdf33f6821c634c4afbada27c0e2723053d74ce35 (patch)
tree1674882ff9fb033034ec748d9d3bb67f73141df1 /source
parentI'll lower my frequency of commits.. 1000 default ends up sent more often than calc'd packets. (diff)
downloadcuberite-df33f6821c634c4afbada27c0e2723053d74ce35.tar
cuberite-df33f6821c634c4afbada27c0e2723053d74ce35.tar.gz
cuberite-df33f6821c634c4afbada27c0e2723053d74ce35.tar.bz2
cuberite-df33f6821c634c4afbada27c0e2723053d74ce35.tar.lz
cuberite-df33f6821c634c4afbada27c0e2723053d74ce35.tar.xz
cuberite-df33f6821c634c4afbada27c0e2723053d74ce35.tar.zst
cuberite-df33f6821c634c4afbada27c0e2723053d74ce35.zip
Diffstat (limited to 'source')
-rw-r--r--source/packets/cPacket_PlayerListItem.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/source/packets/cPacket_PlayerListItem.cpp b/source/packets/cPacket_PlayerListItem.cpp
index 669f5705b..e19dd902c 100644
--- a/source/packets/cPacket_PlayerListItem.cpp
+++ b/source/packets/cPacket_PlayerListItem.cpp
@@ -1,4 +1,5 @@
#include "cPacket_PlayerListItem.h"
+#include "cChatColor.h"
cPacket_PlayerListItem::cPacket_PlayerListItem(std::string a_PlayerName, bool a_Online, short a_Ping)
{
@@ -19,7 +20,12 @@ bool cPacket_PlayerListItem::Parse( cSocket & a_Socket )
bool cPacket_PlayerListItem::Send( cSocket & a_Socket )
{
- m_PlayerName = m_PlayerName.substr(0,16);
+ int len = m_PlayerName.length();
+ int end = (len <= 16) ? len : 16;
+ m_PlayerName = m_PlayerName.substr(0, end);
+ if (len <= 14)
+ m_PlayerName += cChatColor::MakeColor((char)cChatColor::White.c_str());
+
unsigned int TotalSize = c_Size + m_PlayerName.size()*sizeof(short);
char* Message = new char[TotalSize];