diff options
author | Reid <reidyaro@gmail.com> | 2012-01-30 15:27:30 +0100 |
---|---|---|
committer | Reid <reidyaro@gmail.com> | 2012-01-30 15:27:30 +0100 |
commit | 502a0a0163e702af7334979a2eabfc4826a94091 (patch) | |
tree | 5e80ef76585b1718d7e74a411117c725fe3cb0e9 /src/net/messagein.cpp | |
parent | 8dea62750ab3a44e0f35f2543bbb6ccf2a9470ce (diff) | |
parent | 193ea898e5f549c14c0e4cd0d060785de4fb4bcf (diff) | |
download | manaverse-502a0a0163e702af7334979a2eabfc4826a94091.tar.gz manaverse-502a0a0163e702af7334979a2eabfc4826a94091.tar.bz2 manaverse-502a0a0163e702af7334979a2eabfc4826a94091.tar.xz manaverse-502a0a0163e702af7334979a2eabfc4826a94091.zip |
Merge branch 'master' of gitorious.org:manaplus/manaplus
Diffstat (limited to 'src/net/messagein.cpp')
-rw-r--r-- | src/net/messagein.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp index 4fb61dc6a..0547ed337 100644 --- a/src/net/messagein.cpp +++ b/src/net/messagein.cpp @@ -241,7 +241,7 @@ std::string MessageIn::readRawString(int length) return str; } -char *MessageIn::readBytes(int length) +unsigned char *MessageIn::readBytes(int length) { // Get string length if (length < 0) @@ -255,13 +255,28 @@ char *MessageIn::readBytes(int length) return nullptr; } - char *buf = new char[length + 2]; + unsigned char *buf = new unsigned char[length + 2]; memcpy (buf, mData + mPos, length); buf[length] = 0; buf[length + 1] = 0; mPos += length; +#ifdef ENABLEDEBUGLOG + std::string str; + for (int f = 0; f < length; f ++) + str += strprintf ("%02x", (unsigned)buf[f]); + str += " "; + for (int f = 0; f < length; f ++) + { + if (buf[f]) + str += strprintf ("%c", buf[f]); + else + str += "_"; + } + logger->log("ReadBytes: " + str); +#endif + PacketCounters::incInBytes(length); return buf; } |