summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/net/messagein.cpp23
-rw-r--r--src/net/messagein.h2
2 files changed, 24 insertions, 1 deletions
diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp
index 1e0ac22db..1226102d7 100644
--- a/src/net/messagein.cpp
+++ b/src/net/messagein.cpp
@@ -180,6 +180,27 @@ int32_t MessageIn::readInt32(const char *const str)
memcpy(&value, mData + CAST_SIZE(mPos), sizeof(int32_t));
#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
}
+ DEBUGLOG2("readInt32: " + toStringPrint(CAST_S32(value)),
+ mPos, str);
+ mPos += 4;
+ PacketCounters::incInBytes(4);
+ return value;
+}
+
+uint32_t MessageIn::readUInt32(const char *const str)
+{
+ uint32_t value = -1;
+ if (mPos + 4 <= mLength)
+ {
+#if SDL_BYTEORDER == SDL_BIG_ENDIAN
+ uint32_t swap;
+ memcpy(&swap, mData + CAST_SIZE(mPos), sizeof(int32_t));
+ value = SDL_Swap32(swap);
+#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
+
+ memcpy(&value, mData + CAST_SIZE(mPos), sizeof(int32_t));
+#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
+ }
DEBUGLOG2("readInt32: " + toStringPrint(CAST_U32(value)),
mPos, str);
mPos += 4;
@@ -189,7 +210,7 @@ int32_t MessageIn::readInt32(const char *const str)
BeingId MessageIn::readBeingId(const char *const str)
{
- return fromInt(readInt32(str), BeingId);
+ return fromInt(readUInt32(str), BeingId);
}
int64_t MessageIn::readInt64(const char *const str)
diff --git a/src/net/messagein.h b/src/net/messagein.h
index e67dcbe8a..ea2caa499 100644
--- a/src/net/messagein.h
+++ b/src/net/messagein.h
@@ -78,6 +78,8 @@ class MessageIn notfinal
/**< Reads a long. */
int32_t readInt32(const char *const str);
+ uint32_t readUInt32(const char *const str);
+
int64_t readInt64(const char *const str);
BeingId readBeingId(const char *const str);