summaryrefslogtreecommitdiff
path: root/src/net/tmwa
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-09-16 13:52:36 +0300
committerAndrei Karas <akaras@inbox.ru>2014-09-16 13:52:36 +0300
commit65a5155d584c7c41bbcd767b4b7b6722b6ea4f23 (patch)
treea94c2cf74067bbac07df9a4619a1f794d1247cc7 /src/net/tmwa
parent97b04a152a7c16c192269e26e5c20ca3983e959d (diff)
downloadmv-65a5155d584c7c41bbcd767b4b7b6722b6ea4f23.tar.gz
mv-65a5155d584c7c41bbcd767b4b7b6722b6ea4f23.tar.bz2
mv-65a5155d584c7c41bbcd767b4b7b6722b6ea4f23.tar.xz
mv-65a5155d584c7c41bbcd767b4b7b6722b6ea4f23.zip
add support for reading int64 from server.
Diffstat (limited to 'src/net/tmwa')
-rw-r--r--src/net/tmwa/messagein.cpp19
-rw-r--r--src/net/tmwa/messagein.h2
2 files changed, 21 insertions, 0 deletions
diff --git a/src/net/tmwa/messagein.cpp b/src/net/tmwa/messagein.cpp
index d467048d7..8fe50249a 100644
--- a/src/net/tmwa/messagein.cpp
+++ b/src/net/tmwa/messagein.cpp
@@ -85,4 +85,23 @@ int32_t MessageIn::readInt32(const char *const str)
return value;
}
+int64_t MessageIn::readInt64(const char *const str)
+{
+ int32_t value = -1;
+ if (mPos + 8 <= mLength)
+ {
+#if SDL_BYTEORDER == SDL_BIG_ENDIAN
+ int64_t swap;
+ memcpy(&swap, mData + static_cast<size_t>(mPos), sizeof(int64_t));
+ value = SDL_Swap64(swap);
+#else
+ memcpy(&value, mData + static_cast<size_t>(mPos), sizeof(int64_t));
+#endif
+ }
+ DEBUGLOG2("readInt64: " + toStringPrint(value), mPos, str);
+ mPos += 8;
+ PacketCounters::incInBytes(8);
+ return value;
+}
+
} // namespace TmwAthena
diff --git a/src/net/tmwa/messagein.h b/src/net/tmwa/messagein.h
index 26ce4612c..f0645ddda 100644
--- a/src/net/tmwa/messagein.h
+++ b/src/net/tmwa/messagein.h
@@ -51,6 +51,8 @@ class MessageIn final : public Net::MessageIn
int16_t readInt16(const char *const str = nullptr);
/**< Reads a long. */
int32_t readInt32(const char *const str = nullptr);
+
+ int64_t readInt64(const char *const str = nullptr);
};
} // namespace TmwAthena