summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorBernd Wachter <bwachter-tmw@lart.info>2009-11-26 17:50:45 +0100
committerJared Adams <jaxad0127@gmail.com>2009-11-26 11:17:58 -0700
commitedf478e1eb7987e35d56df2777fbeb389dc915ec (patch)
tree6280ef3dbea8fddb2af2e2039c76ce59b0749353 /src/net
parentfcc940800c047322aea40da5a24d9d5c0fbd051e (diff)
downloadmana-edf478e1eb7987e35d56df2777fbeb389dc915ec.tar.gz
mana-edf478e1eb7987e35d56df2777fbeb389dc915ec.tar.bz2
mana-edf478e1eb7987e35d56df2777fbeb389dc915ec.tar.xz
mana-edf478e1eb7987e35d56df2777fbeb389dc915ec.zip
Fix memory alignment on little endian systems
Diffstat (limited to 'src/net')
-rw-r--r--src/net/ea/messagein.cpp8
-rw-r--r--src/net/ea/messageout.cpp4
2 files changed, 6 insertions, 6 deletions
diff --git a/src/net/ea/messagein.cpp b/src/net/ea/messagein.cpp
index 1cca786a..12da6bfb 100644
--- a/src/net/ea/messagein.cpp
+++ b/src/net/ea/messagein.cpp
@@ -39,7 +39,7 @@ MessageIn::MessageIn(const char *data, unsigned int length):
int MessageIn::readInt16()
{
- int value = -1;
+ Sint16 value = -1;
if (mPos + 2 <= mLength)
{
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
@@ -47,7 +47,7 @@ int MessageIn::readInt16()
memcpy(&swap, mData + mPos, sizeof(Sint16));
value = SDL_Swap16(swap);
#else
- value = (*(Sint16*)(mData + mPos));
+ memcpy(&value, mData + mPos, sizeof(Sint16));
#endif
}
mPos += 2;
@@ -56,7 +56,7 @@ int MessageIn::readInt16()
int MessageIn::readInt32()
{
- int value = -1;
+ Sint32 value = -1;
if (mPos + 4 <= mLength)
{
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
@@ -64,7 +64,7 @@ int MessageIn::readInt32()
memcpy(&swap, mData + mPos, sizeof(Sint32));
value = SDL_Swap32(swap);
#else
- value = (*(Sint32*)(mData + mPos));
+ memcpy(&value, mData + mPos, sizeof(Sint32));
#endif
}
mPos += 4;
diff --git a/src/net/ea/messageout.cpp b/src/net/ea/messageout.cpp
index 9493ee80..81fa917a 100644
--- a/src/net/ea/messageout.cpp
+++ b/src/net/ea/messageout.cpp
@@ -51,7 +51,7 @@ void MessageOut::writeInt16(Sint16 value)
Sint16 swap=SDL_Swap16(value);
memcpy(mData + mPos, &swap, sizeof(Sint16));
#else
- (*(Sint16 *)(mData + mPos)) = value;
+ memcpy(mData + mPos, &value, sizeof(Sint16));
#endif
mPos += 2;
}
@@ -63,7 +63,7 @@ void MessageOut::writeInt32(Sint32 value)
Sint32 swap=SDL_Swap32(value);
memcpy(mData + mPos, &swap, sizeof(Sint32));
#else
- (*(Sint32 *)(mData + mPos)) = value;
+ memcpy(mData + mPos, &value, sizeof(Sint32));
#endif
mPos += 4;
}