summaryrefslogtreecommitdiff
path: root/src/net/tmwa/messageout.cpp
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2011-06-04 12:25:25 -0600
committerJared Adams <jaxad0127@gmail.com>2011-06-04 12:25:25 -0600
commite7e99051910a9a8739d8a50225be868e5dc286d6 (patch)
treea3b3cb91cc67da70be56934ce0904991a5b8b170 /src/net/tmwa/messageout.cpp
parent576dfc355cc06109da0bf07ac65fef7ab484a9cf (diff)
downloadmana-client-e7e99051910a9a8739d8a50225be868e5dc286d6.tar.gz
mana-client-e7e99051910a9a8739d8a50225be868e5dc286d6.tar.bz2
mana-client-e7e99051910a9a8739d8a50225be868e5dc286d6.tar.xz
mana-client-e7e99051910a9a8739d8a50225be868e5dc286d6.zip
Fix handling of 16- and 32-bit number in tmwAthena netcode
Diffstat (limited to 'src/net/tmwa/messageout.cpp')
-rw-r--r--src/net/tmwa/messageout.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/net/tmwa/messageout.cpp b/src/net/tmwa/messageout.cpp
index 7c3a3c61..705b9a96 100644
--- a/src/net/tmwa/messageout.cpp
+++ b/src/net/tmwa/messageout.cpp
@@ -47,18 +47,24 @@ void MessageOut::expand(size_t bytes)
void MessageOut::writeInt16(uint16_t value)
{
expand(2);
- mData[mPos] = value;
- mData[mPos + 1] = value >> 8;
+#if SDL_BYTEORDER == SDL_BIG_ENDIAN
+ uint16_t swap=SDL_Swap16(value);
+ memcpy(mData + mPos, &swap, sizeof(uint16_t));
+#else
+ memcpy(mData + mPos, &value, sizeof(uint16_t));
+#endif
mPos += 2;
}
void MessageOut::writeInt32(uint32_t value)
{
expand(4);
- mData[mPos] = value;
- mData[mPos + 1] = value >> 8;
- mData[mPos + 2] = value >> 16;
- mData[mPos + 3] = value >> 24;
+#if SDL_BYTEORDER == SDL_BIG_ENDIAN
+ uint32_t swap=SDL_Swap32(value);
+ memcpy(mData + mPos, &swap, sizeof(uint32_t));
+#else
+ memcpy(mData + mPos, &value, sizeof(uint32_t));
+#endif
mPos += 4;
}