MessageIn Class Reference
[Core network layer]

#include <messagein.h>

List of all members.


Detailed Description

Used for parsing an incoming message.

Definition at line 33 of file messagein.h.


Public Member Functions

 MessageIn (const char *data, unsigned int length)
 Constructor.
int getId () const
 Returns the message ID.
unsigned int getLength () const
 Returns the message length.
unsigned int getUnreadLength () const
 Returns the length of unread data.
int readInt8 ()
 Reads a byte.
int readInt16 ()
 Reads a short.
int readInt32 ()
 Reads a long.
void readCoordinates (Uint16 &x, Uint16 &y)
 Reads a 3-byte block containing tile-based coordinates.
void readCoordinates (Uint16 &x, Uint16 &y, Uint8 &direction)
 Reads a special 3 byte block used by eAthena, containing x and y coordinates and direction.
void readCoordinatePair (Uint16 &srcX, Uint16 &srcY, Uint16 &dstX, Uint16 &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.

Constructor & Destructor Documentation

MessageIn::MessageIn ( const char *  data,
unsigned int  length 
)

Constructor.

Definition at line 35 of file messagein.cpp.


Member Function Documentation

int MessageIn::getId (  )  const [inline]

Returns the message ID.

Definition at line 44 of file messagein.h.

unsigned int MessageIn::getLength (  )  const [inline]

Returns the message length.

Definition at line 49 of file messagein.h.

unsigned int MessageIn::getUnreadLength (  )  const [inline]

Returns the length of unread data.

Definition at line 54 of file messagein.h.

int MessageIn::readInt8 (  ) 

Reads a byte.

Definition at line 44 of file messagein.cpp.

int MessageIn::readInt16 (  ) 

Reads a short.

Definition at line 55 of file messagein.cpp.

int MessageIn::readInt32 (  ) 

Reads a long.

Definition at line 76 of file messagein.cpp.

void MessageIn::readCoordinates ( Uint16 &  x,
Uint16 &  y 
)

Reads a 3-byte block containing tile-based coordinates.

Used by tmwserv.

Definition at line 97 of file messagein.cpp.

void MessageIn::readCoordinates ( Uint16 &  x,
Uint16 &  y,
Uint8 &  direction 
)

Reads a special 3 byte block used by eAthena, containing x and y coordinates and direction.

Definition at line 108 of file messagein.cpp.

void MessageIn::readCoordinatePair ( Uint16 &  srcX,
Uint16 &  srcY,
Uint16 &  dstX,
Uint16 &  dstY 
)

Reads a special 5 byte block used by eAthena, containing a source and destination coordinate pair.

Definition at line 157 of file messagein.cpp.

void MessageIn::skip ( unsigned int  length  ) 

Skips a given number of bytes.

Definition at line 179 of file messagein.cpp.

std::string 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 184 of file messagein.cpp.


Member Data Documentation

const char* MessageIn::mData [private]

The message data.

Definition at line 92 of file messagein.h.

unsigned int MessageIn::mLength [private]

The length of the data.

Definition at line 93 of file messagein.h.

unsigned short MessageIn::mId [private]

The message ID.

Definition at line 94 of file messagein.h.

unsigned int MessageIn::mPos [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 101 of file messagein.h.


The documentation for this class was generated from the following files:

Generated on Sun Apr 26 17:30:43 2009 for The Mana World by  doxygen 1.5.5