summaryrefslogtreecommitdiff
path: root/src/net/messagein.cpp
diff options
context:
space:
mode:
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;
}
+
+}