Mana
|
Used for parsing an incoming message from eAthena. More...
#include <messagein.h>
Public Member Functions | |
MessageIn (const char *data, unsigned int length) | |
uint16_t | getId () const |
Returns the message ID. | |
unsigned int | getLength () const |
Returns the message length. | |
unsigned int | getUnreadLength () const |
Returns the length of unread data. | |
uint8_t | readInt8 () |
Reads an unsigned 8-bit integer from the message. | |
uint16_t | readInt16 () |
Reads an unsigned 16-bit integer from the message. | |
uint32_t | readInt32 () |
Reads an unsigned 32-bit integer from the message. | |
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. | |
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. | |
void | skip (unsigned int length) |
Skips a given number of bytes. | |
std::string | readString (int length=-1) |
Reads a string. | |
Private Attributes | |
const char * | mData |
The message data. | |
unsigned int | mLength |
The length of the data. | |
unsigned short | mId |
The message ID. | |
unsigned int | mPos |
Actual position in the packet. | |
Used for parsing an incoming message from eAthena.
Definition at line 34 of file messagein.h.
TmwAthena::MessageIn::MessageIn | ( | const char * | data, |
unsigned int | length | ||
) |
Definition at line 37 of file messagein.cpp.
|
inline |
Returns the message ID.
Definition at line 42 of file messagein.h.
|
inline |
Returns the message length.
Definition at line 47 of file messagein.h.
|
inline |
Returns the length of unread data.
Definition at line 52 of file messagein.h.
void TmwAthena::MessageIn::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.
Definition at line 115 of file messagein.cpp.
void TmwAthena::MessageIn::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.
Definition at line 81 of file messagein.cpp.
uint16_t TmwAthena::MessageIn::readInt16 | ( | ) |
Reads an unsigned 16-bit integer from the message.
Definition at line 57 of file messagein.cpp.
uint32_t TmwAthena::MessageIn::readInt32 | ( | ) |
Reads an unsigned 32-bit integer from the message.
Definition at line 69 of file messagein.cpp.
uint8_t TmwAthena::MessageIn::readInt8 | ( | ) |
Reads an unsigned 8-bit integer from the message.
Definition at line 46 of file messagein.cpp.
std::string TmwAthena::MessageIn::readString | ( | int | length = -1 | ) |
Reads a string.
If a length is not given (-1), it is assumed that the length of the string is stored in a short at the start of the string.
Definition at line 142 of file messagein.cpp.
void TmwAthena::MessageIn::skip | ( | unsigned int | length | ) |
Skips a given number of bytes.
Definition at line 137 of file messagein.cpp.
|
private |
The message data.
Definition at line 98 of file messagein.h.
|
private |
The message ID.
Definition at line 100 of file messagein.h.
|
private |
The length of the data.
Definition at line 99 of file messagein.h.
|
private |
Actual position in the packet.
From 0 to packet->length. A value bigger than packet->length means EOP was reached when reading it.
Definition at line 107 of file messagein.h.