summaryrefslogtreecommitdiff
path: root/src/net/messagein.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/messagein.cpp')
-rw-r--r--src/net/messagein.cpp19
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;
}