diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-11-30 18:13:03 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-11-30 20:09:16 +0300 |
commit | 7c6621108b54fd66fbb7aa87be067a34abcc3ced (patch) | |
tree | 5859964db8917a35ebb244a0114d5d3cf6578ae0 /src/net/messagein.cpp | |
parent | 8871ef8ba38a11213de3cc7f35f5f9f0f3000dc0 (diff) | |
download | manaverse-7c6621108b54fd66fbb7aa87be067a34abcc3ced.tar.gz manaverse-7c6621108b54fd66fbb7aa87be067a34abcc3ced.tar.bz2 manaverse-7c6621108b54fd66fbb7aa87be067a34abcc3ced.tar.xz manaverse-7c6621108b54fd66fbb7aa87be067a34abcc3ced.zip |
Add server side online players list support.
Diffstat (limited to 'src/net/messagein.cpp')
-rw-r--r-- | src/net/messagein.cpp | 25 |
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; +} + } |