27#include <SDL_endian.h>
30#define MAKEWORD(low,high) \
31 ((unsigned short)(((unsigned char)(low)) | \
32 ((unsigned short)((unsigned char)(high))) << 8))
62 memcpy(&value,
mData +
mPos,
sizeof(uint16_t));
63 value = SDL_SwapLE16(value);
75 value = SDL_SwapLE32(value);
88 temp =
MAKEWORD(data[1] & 0x00c0, data[0] & 0x00ff);
90 temp =
MAKEWORD(data[2] & 0x00f0, data[1] & 0x003f);
93 direction = data[2] & 0x000f;
96 switch (
static_cast<DIR>(direction))
116 uint16_t &dstX, uint16_t &dstY)
123 temp =
MAKEWORD(data[3], data[2] & 0x000f);
126 dstY =
MAKEWORD(data[4], data[3] & 0x0003);
131 temp =
MAKEWORD(data[2], data[1] & 0x003f);
149 if (length < 0 || mPos + length >
mLength)
152 return std::string();
157 char const *stringEnd = (
char const *)memchr(stringBeg,
'\0', length);
159 stringEnd ? stringEnd - stringBeg : length);
std::string readString(int length=-1)
Reads a string.
void readCoordinates(uint16_t &x, uint16_t &y, uint8_t &direction)
Reads a special 3 byte block used by eAthena, containing x and y coordinates and direction.
const char * mData
The message data.
void skip(unsigned int length)
Skips a given number of bytes.
unsigned short mId
The message ID.
uint16_t readInt16()
Reads an unsigned 16-bit integer from the message.
uint8_t readInt8()
Reads an unsigned 8-bit integer from the message.
MessageIn(const char *data, unsigned int length)
void readCoordinatePair(uint16_t &srcX, uint16_t &srcY, uint16_t &dstX, uint16_t &dstY)
Reads a special 5 byte block used by eAthena, containing a source and destination coordinate pair.
unsigned int mPos
Actual position in the packet.
unsigned int mLength
The length of the data.
uint32_t readInt32()
Reads an unsigned 32-bit integer from the message.
Warning: buffers and other variables are shared, so there can be only one connection active at a time...
#define MAKEWORD(low, high)