Mana
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
TmwAthena::MessageIn Class Reference

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.
 

Detailed Description

Used for parsing an incoming message from eAthena.

Definition at line 34 of file messagein.h.

Constructor & Destructor Documentation

◆ MessageIn()

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

Definition at line 37 of file messagein.cpp.

Member Function Documentation

◆ getId()

uint16_t TmwAthena::MessageIn::getId ( ) const
inline

Returns the message ID.

Definition at line 42 of file messagein.h.

◆ getLength()

unsigned int TmwAthena::MessageIn::getLength ( ) const
inline

Returns the message length.

Definition at line 47 of file messagein.h.

◆ getUnreadLength()

unsigned int TmwAthena::MessageIn::getUnreadLength ( ) const
inline

Returns the length of unread data.

Definition at line 52 of file messagein.h.

◆ readCoordinatePair()

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.

◆ readCoordinates()

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.

◆ readInt16()

uint16_t TmwAthena::MessageIn::readInt16 ( )

Reads an unsigned 16-bit integer from the message.

Definition at line 57 of file messagein.cpp.

◆ readInt32()

uint32_t TmwAthena::MessageIn::readInt32 ( )

Reads an unsigned 32-bit integer from the message.

Definition at line 69 of file messagein.cpp.

◆ readInt8()

uint8_t TmwAthena::MessageIn::readInt8 ( )

Reads an unsigned 8-bit integer from the message.

Definition at line 46 of file messagein.cpp.

◆ readString()

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.

◆ skip()

void TmwAthena::MessageIn::skip ( unsigned int  length)

Skips a given number of bytes.

Definition at line 137 of file messagein.cpp.

Member Data Documentation

◆ mData

const char* TmwAthena::MessageIn::mData
private

The message data.

Definition at line 98 of file messagein.h.

◆ mId

unsigned short TmwAthena::MessageIn::mId
private

The message ID.

Definition at line 100 of file messagein.h.

◆ mLength

unsigned int TmwAthena::MessageIn::mLength
private

The length of the data.

Definition at line 99 of file messagein.h.

◆ mPos

unsigned int TmwAthena::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 107 of file messagein.h.


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