ManaPlus
|
#include <messagein.h>
Public Member Functions | |
virtual | ~MessageIn () |
uint16_t | readId () const |
int | getId () const |
unsigned int | getLength () const |
unsigned int | getUnreadLength () const |
unsigned char | readUInt8 (const char *const str) |
signed char | readInt8 (const char *const str) |
int16_t | readInt16 (const char *const str) |
uint16_t | readUInt16 (const char *const str) |
int32_t | readInt32 (const char *const str) |
uint32_t | readUInt32 (const char *const str) |
int | readItemId (const char *const str) |
int64_t | readInt64 (const char *const str) |
BeingId | readBeingId (const char *const str) |
float | readFloat (const char *const str) |
void | readCoordinates (uint16_t &x, uint16_t &y, uint8_t &direction, const char *const str) |
void | readCoordinatePair (uint16_t &srcX, uint16_t &srcY, uint16_t &dstX, uint16_t &dstY, const char *const str) |
void | skip (const unsigned int length, const char *const str) |
void | skipToEnd (const char *const str) |
std::string | readString (int length, const char *const dstr) |
std::string | readRawString (int length, const char *const dstr) |
unsigned char * | readBytes (int length, const char *const dstr) |
int | getVersion () const |
int | getVersionMain () const |
int | getVersionRe () const |
int | getVersionZero () const |
Static Public Member Functions | |
static uint8_t | fromServerDirection (const uint8_t serverDir) |
Protected Member Functions | |
MessageIn (const char *const data, const unsigned int length) | |
Protected Attributes | |
const char * | mData |
unsigned int | mLength |
unsigned int | mPos |
int | mVersion |
uint16_t | mId |
bool | mIgnore |
Used for parsing an incoming message.
Definition at line 41 of file messagein.h.
|
virtual |
Definition at line 66 of file messagein.cpp.
References CAST_S32, CAST_U32, Logger::log(), logger, mId, mLength, mPos, and WRONGPACKETSIZE.
|
protected |
Constructor.
Definition at line 54 of file messagein.cpp.
References PacketCounters::incInPackets().
|
static |
Definition at line 266 of file messagein.cpp.
References CAST_S32, Logger::log(), and logger.
Referenced by EAthena::BeingRecv::processBeingChangeDirection(), TmwAthena::BeingRecv::processBeingChangeDirection(), Ea::NpcRecv::processNpcCommand(), and readCoordinates().
|
inline |
|
inline |
|
inline |
Returns the length of unread data. Reads a byte.
Definition at line 65 of file messagein.h.
|
inline |
int Net::MessageIn::getVersionMain | ( | ) | const |
int Net::MessageIn::getVersionRe | ( | ) | const |
int Net::MessageIn::getVersionZero | ( | ) | const |
BeingId Net::MessageIn::readBeingId | ( | const char *const | str | ) |
unsigned char * Net::MessageIn::readBytes | ( | int | length, |
const char *const | dstr | ||
) |
Definition at line 454 of file messagein.cpp.
References CAST_SIZE, CAST_U32, DEBUGLOG2, Logger::dlog(), PacketCounters::incInBytes(), logger, mData, mIgnore, mLength, mPos, readInt16(), and strprintf().
void Net::MessageIn::readCoordinatePair | ( | uint16_t & | srcX, |
uint16_t & | srcY, | ||
uint16_t & | dstX, | ||
uint16_t & | dstY, | ||
const char *const | str | ||
) |
Reads a special 5 byte block used by eAthena, containing a source and destination coordinate pair.
Definition at line 328 of file messagein.cpp.
References CAST_S32, CAST_SIZE, CAST_U16, data, DEBUGLOG2, PacketCounters::incInBytes(), Logger::log(), logger, MAKEWORD, mData, mLength, mPos, and Catch::toString().
void Net::MessageIn::readCoordinates | ( | uint16_t & | x, |
uint16_t & | y, | ||
uint8_t & | direction, | ||
const char *const | str | ||
) |
Reads a special 3 byte block used by eAthena, containing x and y coordinates and direction.
Definition at line 296 of file messagein.cpp.
References CAST_S32, CAST_SIZE, CAST_U16, CAST_U8, data, DEBUGLOG2, fromServerDirection(), PacketCounters::incInBytes(), Logger::log(), logger, MAKEWORD, mData, mLength, mPos, Catch::toString(), x, and y.
float Net::MessageIn::readFloat | ( | const char *const | str | ) |
Definition at line 250 of file messagein.cpp.
References CAST_SIZE, DEBUGLOG2, PacketCounters::incInBytes(), mData, mLength, mPos, and strprintf().
uint16_t Net::MessageIn::readId | ( | ) | const |
Definition at line 87 of file messagein.cpp.
References CAST_SIZE, mData, mLength, and mPos.
Referenced by TmwAthena::MessageIn::postInit(), and EAthena::MessageIn::postInit().
int16_t Net::MessageIn::readInt16 | ( | const char *const | str | ) |
Definition at line 131 of file messagein.cpp.
References CAST_SIZE, CAST_U16, CAST_U32, DEBUGLOG2, PacketCounters::incInBytes(), mData, mLength, mPos, and toStringPrint().
Referenced by TmwAthena::MessageIn::postInit(), EAthena::MessageIn::postInit(), readBytes(), readItemId(), readRawString(), and readString().
int32_t Net::MessageIn::readInt32 | ( | const char *const | str | ) |
Definition at line 175 of file messagein.cpp.
References CAST_S32, CAST_SIZE, DEBUGLOG2, PacketCounters::incInBytes(), mData, mLength, mPos, and toStringPrint().
Referenced by readItemId().
int64_t Net::MessageIn::readInt64 | ( | const char *const | str | ) |
Definition at line 229 of file messagein.cpp.
References CAST_SIZE, CAST_U32, DEBUGLOG2, PacketCounters::incInBytes(), mData, mLength, mPos, and toStringPrint().
signed char Net::MessageIn::readInt8 | ( | const char *const | str | ) |
Reads a short.
Definition at line 117 of file messagein.cpp.
References CAST_S8, CAST_U32, CAST_U8, DEBUGLOG2, PacketCounters::incInBytes(), mData, mLength, mPos, and toStringPrint().
int Net::MessageIn::readItemId | ( | const char *const | str | ) |
std::string Net::MessageIn::readRawString | ( | int | length, |
const char *const | dstr | ||
) |
Definition at line 411 of file messagein.cpp.
References CAST_SIZE, DEBUGLOG2, PacketCounters::incInBytes(), mData, mLength, mPos, and readInt16().
std::string Net::MessageIn::readString | ( | int | length, |
const char *const | dstr | ||
) |
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 384 of file messagein.cpp.
References CAST_SIZE, DEBUGLOG2, PacketCounters::incInBytes(), mData, mLength, mPos, and readInt16().
uint16_t Net::MessageIn::readUInt16 | ( | const char *const | str | ) |
Reads a long.
Definition at line 153 of file messagein.cpp.
References CAST_SIZE, CAST_U16, CAST_U32, DEBUGLOG2, PacketCounters::incInBytes(), mData, mLength, mPos, and toStringPrint().
uint32_t Net::MessageIn::readUInt32 | ( | const char *const | str | ) |
Definition at line 196 of file messagein.cpp.
References CAST_SIZE, CAST_U32, DEBUGLOG2, PacketCounters::incInBytes(), mData, mLength, mPos, and toStringPrint().
Referenced by readBeingId().
unsigned char Net::MessageIn::readUInt8 | ( | const char *const | str | ) |
Reads a byte.
Definition at line 104 of file messagein.cpp.
References CAST_U32, CAST_U8, DEBUGLOG2, PacketCounters::incInBytes(), mData, mLength, mPos, and toStringPrint().
void Net::MessageIn::skip | ( | const unsigned int | length, |
const char *const | str | ||
) |
Skips a given number of bytes.
Definition at line 366 of file messagein.cpp.
References CAST_S32, DEBUGLOG2, PacketCounters::incInBytes(), mPos, and Catch::toString().
void Net::MessageIn::skipToEnd | ( | const char *const | str | ) |
Definition at line 373 of file messagein.cpp.
References CAST_S32, DEBUGLOG2, PacketCounters::incInBytes(), mLength, mPos, and Catch::toString().
|
protected |
The message data.
Definition at line 151 of file messagein.h.
Referenced by readBytes(), readCoordinatePair(), readCoordinates(), readFloat(), readId(), readInt16(), readInt32(), readInt64(), readInt8(), readRawString(), readString(), readUInt16(), readUInt32(), and readUInt8().
|
protected |
The message ID.
Definition at line 161 of file messagein.h.
Referenced by getId(), TmwAthena::MessageIn::postInit(), EAthena::MessageIn::postInit(), and ~MessageIn().
|
protected |
Definition at line 162 of file messagein.h.
Referenced by readBytes().
|
protected |
The length of the data.
Definition at line 152 of file messagein.h.
Referenced by getLength(), getUnreadLength(), readBytes(), readCoordinatePair(), readCoordinates(), readFloat(), readId(), readInt16(), readInt32(), readInt64(), readInt8(), readRawString(), readString(), readUInt16(), readUInt32(), readUInt8(), skipToEnd(), and ~MessageIn().
|
protected |
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 159 of file messagein.h.
Referenced by getUnreadLength(), readBytes(), readCoordinatePair(), readCoordinates(), readFloat(), readId(), readInt16(), readInt32(), readInt64(), readInt8(), readRawString(), readString(), readUInt16(), readUInt32(), readUInt8(), skip(), skipToEnd(), and ~MessageIn().
|
protected |
Definition at line 160 of file messagein.h.
Referenced by getVersion(), getVersionMain(), getVersionRe(), getVersionZero(), and EAthena::MessageIn::postInit().