summaryrefslogtreecommitdiff
path: root/src/net/messagein.cpp
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-11-03 10:18:25 -0700
committerJared Adams <jaxad0127@gmail.com>2009-11-03 10:18:25 -0700
commitacd557f9472c711fe92b9c158ec336abf688bf7b (patch)
tree2295d13589411ee88afe16f4997bea65b4ebba94 /src/net/messagein.cpp
parentc60d3a98dbbb20621742bfd82bbaaa6b7085a8ae (diff)
downloadmana-acd557f9472c711fe92b9c158ec336abf688bf7b.tar.gz
mana-acd557f9472c711fe92b9c158ec336abf688bf7b.tar.bz2
mana-acd557f9472c711fe92b9c158ec336abf688bf7b.tar.xz
mana-acd557f9472c711fe92b9c158ec336abf688bf7b.zip
Remove more _SUPPORT ifdefs and do some cleanup
Diffstat (limited to 'src/net/messagein.cpp')
-rw-r--r--src/net/messagein.cpp55
1 files changed, 4 insertions, 51 deletions
diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp
index 1e85133f..f659fcfc 100644
--- a/src/net/messagein.cpp
+++ b/src/net/messagein.cpp
@@ -21,24 +21,17 @@
#include "net/messagein.h"
-#ifdef MANASERV_SUPPORT
-#include <enet/enet.h>
-#else
-#include <SDL.h>
-#include <SDL_endian.h>
-#endif
-
#define MAKEWORD(low,high) \
((unsigned short)(((unsigned char)(low)) | \
((unsigned short)((unsigned char)(high))) << 8))
+namespace Net {
+
MessageIn::MessageIn(const char *data, unsigned int length):
mData(data),
mLength(length),
mPos(0)
{
- // Read the message ID
- mId = readInt16();
}
int MessageIn::readInt8()
@@ -52,48 +45,6 @@ int MessageIn::readInt8()
return value;
}
-int MessageIn::readInt16()
-{
- int value = -1;
- if (mPos + 2 <= mLength)
- {
-#ifdef MANASERV_SUPPORT
- uint16_t t;
- memcpy(&t, mData + mPos, 2);
- value = (unsigned short) ENET_NET_TO_HOST_16(t);
-#else
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- value = SDL_Swap16(*(Sint16*)(mData + mPos));
-#else
- value = (*(Sint16*)(mData + mPos));
-#endif
-#endif // MANASERV_SUPPORT
- }
- mPos += 2;
- return value;
-}
-
-int MessageIn::readInt32()
-{
- int value = -1;
- if (mPos + 4 <= mLength)
- {
-#ifdef MANASERV_SUPPORT
- uint32_t t;
- memcpy(&t, mData + mPos, 4);
- value = ENET_NET_TO_HOST_32(t);
-#else
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- value = SDL_Swap32(*(Sint32*)(mData + mPos));
-#else
- value = (*(Sint32*)(mData + mPos));
-#endif
-#endif // MANASERV_SUPPORT
- }
- mPos += 4;
- return value;
-}
-
void MessageIn::readCoordinates(Uint16 &x, Uint16 &y)
{
if (mPos + 3 <= mLength)
@@ -201,3 +152,5 @@ std::string MessageIn::readString(int length)
mPos += length;
return readString;
}
+
+}