summaryrefslogtreecommitdiff
path: root/src/net/messagein.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-11-30 18:13:03 +0300
committerAndrei Karas <akaras@inbox.ru>2011-11-30 20:09:16 +0300
commit7c6621108b54fd66fbb7aa87be067a34abcc3ced (patch)
tree5859964db8917a35ebb244a0114d5d3cf6578ae0 /src/net/messagein.cpp
parent8871ef8ba38a11213de3cc7f35f5f9f0f3000dc0 (diff)
downloadmanaplus-7c6621108b54fd66fbb7aa87be067a34abcc3ced.tar.gz
manaplus-7c6621108b54fd66fbb7aa87be067a34abcc3ced.tar.bz2
manaplus-7c6621108b54fd66fbb7aa87be067a34abcc3ced.tar.xz
manaplus-7c6621108b54fd66fbb7aa87be067a34abcc3ced.zip
Add server side online players list support.
Diffstat (limited to 'src/net/messagein.cpp')
-rw-r--r--src/net/messagein.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp
index 0fbf7162b..19453b745 100644
--- a/src/net/messagein.cpp
+++ b/src/net/messagein.cpp
@@ -241,4 +241,29 @@ std::string MessageIn::readRawString(int length)
return str;
}
+char *MessageIn::readBytes(int length)
+{
+ // Get string length
+ if (length < 0)
+ length = readInt16();
+
+ // Make sure the string isn't erroneous
+ if (length < 0 || mPos + length > mLength)
+ {
+ mPos = mLength + 1;
+ DEBUGLOG("readBytesString error");
+ return nullptr;
+ }
+
+ char *buf = new char[length + 2];
+
+ memcpy (buf, mData + mPos, length);
+ buf[length] = 0;
+ buf[length + 1] = 0;
+ mPos += length;
+
+ PacketCounters::incInBytes(length);
+ return buf;
+}
+
}