diff options
author | Ben Longbons <b.r.longbons@gmail.com> | 2011-06-02 23:49:49 -0700 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2011-06-03 11:03:25 -0600 |
commit | 894038adf52a3e2b42542239a147d6c1cc1ad204 (patch) | |
tree | b881994e4605bcf0ba2d1df68068a78fb21ecf01 /src/net/tmwa/messagein.cpp | |
parent | d50f35d13e73b72eae1d744971657bd665aa1f33 (diff) | |
download | mana-894038adf52a3e2b42542239a147d6c1cc1ad204.tar.gz mana-894038adf52a3e2b42542239a147d6c1cc1ad204.tar.bz2 mana-894038adf52a3e2b42542239a147d6c1cc1ad204.tar.xz mana-894038adf52a3e2b42542239a147d6c1cc1ad204.zip |
Cleanup network code to use unsigned integers of the relevant size
Diffstat (limited to 'src/net/tmwa/messagein.cpp')
-rw-r--r-- | src/net/tmwa/messagein.cpp | 28 |
1 files changed, 6 insertions, 22 deletions
diff --git a/src/net/tmwa/messagein.cpp b/src/net/tmwa/messagein.cpp index 0074cfdd..1a860a25 100644 --- a/src/net/tmwa/messagein.cpp +++ b/src/net/tmwa/messagein.cpp @@ -24,10 +24,6 @@ #include <SDL.h> #include <SDL_endian.h> -#define MAKEWORD(low,high) \ - ((unsigned short)(((unsigned char)(low)) | \ - ((unsigned short)((unsigned char)(high))) << 8)) - namespace TmwAthena { MessageIn::MessageIn(const char *data, unsigned int length): @@ -37,35 +33,23 @@ MessageIn::MessageIn(const char *data, unsigned int length): mId = readInt16(); } -int MessageIn::readInt16() +Uint16 MessageIn::readInt16() { - Sint16 value = -1; + Uint16 value = 0; if (mPos + 2 <= mLength) { -#if SDL_BYTEORDER == SDL_BIG_ENDIAN - Sint16 swap; - memcpy(&swap, mData + mPos, sizeof(Sint16)); - value = SDL_Swap16(swap); -#else - memcpy(&value, mData + mPos, sizeof(Sint16)); -#endif + value = (mData[mPos + 1] << 8) | mData[mPos]; } mPos += 2; return value; } -int MessageIn::readInt32() +Uint32 MessageIn::readInt32() { - Sint32 value = -1; + Uint32 value = 0; if (mPos + 4 <= mLength) { -#if SDL_BYTEORDER == SDL_BIG_ENDIAN - Sint32 swap; - memcpy(&swap, mData + mPos, sizeof(Sint32)); - value = SDL_Swap32(swap); -#else - memcpy(&value, mData + mPos, sizeof(Sint32)); -#endif + value = (mData[mPos + 3] << 24) | (mData[mPos + 2] << 16) | (mData[mPos + 1] << 8) | mData[mPos]; } mPos += 4; return value; |