36 PRAGMA48(GCC diagnostic ignored
"-Wshadow")
37 #ifndef SDL_BIG_ENDIAN
38 #include <SDL_endian.h>
42 #define MAKEWORD(low, high) \
43 (CAST_U16((CAST_U8(low)) | \
44 (CAST_U16(CAST_U8(high))) << 8))
55 const unsigned int length) :
72 logger->
log(
"Wrong actual or planned inbound packet size!");
92 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
95 value = SDL_Swap16(swap);
106 unsigned char value =
CAST_U8(-1);
119 signed char value =
CAST_S8(-1);
136 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
139 value = SDL_Swap16(swap);
155 uint16_t value = 0xffU;
158 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
161 value = SDL_Swap16(swap);
180 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
183 value = SDL_Swap32(swap);
201 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
204 value = SDL_Swap32(swap);
234 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
237 value = SDL_Swap64(swap);
257 #ifdef ENABLEDEBUGLOG
258 std::string text =
strprintf(
"readFloat: %f", value);
299 const char *
const str)
309 const uint8_t serverDir =
CAST_U8(
data[2] & 0x000f);
322 logger->
log(
"error: wrong readCoordinates packet");
332 const char *
const str)
360 logger->
log(
"error: wrong readCoordinatePair packet");
391 if (length < 0 || mPos + length >
mLength)
400 const char *
const stringEnd
401 =
static_cast<const char *
>(memchr(stringBeg,
'\0', length));
403 const std::string str(stringBeg, stringEnd !=
nullptr
404 ? stringEnd - stringBeg :
CAST_SIZE(length));
418 if (length < 0 || mPos + length >
mLength)
426 const char *
const stringEnd
427 =
static_cast<const char *
>(memchr(stringBeg,
'\0', length));
428 std::string str(stringBeg, stringEnd !=
nullptr
429 ? stringEnd - stringBeg :
CAST_SIZE(length));
433 if (stringEnd !=
nullptr)
436 - (stringEnd - stringBeg) - 1;
437 const char *
const stringBeg2 = stringEnd + 1;
438 const char *
const stringEnd2
439 =
static_cast<const char *
>(memchr(stringBeg2,
'\0', len2));
440 const std::string hiddenPart = std::string(stringBeg2,
441 stringEnd2 !=
nullptr ? stringEnd2 - stringBeg2 : len2);
442 if (hiddenPart.length() > 0)
445 return str.append(
"|").append(hiddenPart);
461 if (length < 0 || mPos + length >
mLength)
468 unsigned char *
const buf
469 =
new unsigned char[
CAST_SIZE(length + 2)];
476 #ifdef ENABLEDEBUGLOG
480 for (
int f = 0; f < length; f ++)
483 for (
int f = 0; f < length; f ++)
void log(const char *const log_text,...)
void dlog(const std::string &str)
uint32_t readUInt32(const char *const str)
int getVersionZero() const
int64_t readInt64(const char *const str)
float readFloat(const char *const str)
void readCoordinatePair(uint16_t &srcX, uint16_t &srcY, uint16_t &dstX, uint16_t &dstY, const char *const str)
int32_t readInt32(const char *const str)
signed char readInt8(const char *const str)
void skip(const unsigned int length, const char *const str)
uint16_t readUInt16(const char *const str)
MessageIn(const char *const data, const unsigned int length)
int16_t readInt16(const char *const str)
BeingId readBeingId(const char *const str)
std::string readString(int length, const char *const dstr)
unsigned char readUInt8(const char *const str)
static uint8_t fromServerDirection(const uint8_t serverDir)
unsigned char * readBytes(int length, const char *const dstr)
std::string readRawString(int length, const char *const dstr)
void readCoordinates(uint16_t &x, uint16_t &y, uint8_t &direction, const char *const str)
int getVersionMain() const
int readItemId(const char *const str)
void skipToEnd(const char *const str)
static void incInBytes(const int cnt)
static void incInPackets()
#define fromInt(val, name)
#define DEBUGLOG2(str, pos, comment)
#define MAKEWORD(low, high)
std::string toString(T const &value)
converts any type to a string
std::string toStringPrint(const unsigned int val)
std::string strprintf(const char *const format,...)