summaryrefslogtreecommitdiff
path: root/src/net/eathena/messagein.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/eathena/messagein.cpp')
-rw-r--r--src/net/eathena/messagein.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/net/eathena/messagein.cpp b/src/net/eathena/messagein.cpp
index 7b21b7485..34edbe39d 100644
--- a/src/net/eathena/messagein.cpp
+++ b/src/net/eathena/messagein.cpp
@@ -95,6 +95,27 @@ int16_t MessageIn::readInt16(const char *const str)
return value;
}
+uint16_t MessageIn::readUInt16(const char *const str)
+{
+ uint16_t value = 0xffU;
+ if (mPos + 2 <= mLength)
+ {
+#if SDL_BYTEORDER == SDL_BIG_ENDIAN
+ uint16_t swap;
+ memcpy(&swap, mData + CAST_SIZE(mPos), sizeof(uint16_t));
+ value = SDL_Swap16(swap);
+#else
+ memcpy(&value, mData + CAST_SIZE(mPos), sizeof(uint16_t));
+#endif
+ }
+ DEBUGLOG2("readUInt16: " + toStringPrint(CAST_U32(
+ CAST_U16(value))),
+ mPos, str);
+ mPos += 2;
+ PacketCounters::incInBytes(2);
+ return value;
+}
+
int32_t MessageIn::readInt32(const char *const str)
{
int32_t value = -1;