From 38659dbd75d81edbe336d5311a1cd1184d359b7e Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 17 Sep 2014 16:34:43 +0300 Subject: add support for ignore packets logging. Option for coma separated packet ids added in misc tab. --- src/net/eathena/messagein.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src/net/eathena/messagein.cpp') diff --git a/src/net/eathena/messagein.cpp b/src/net/eathena/messagein.cpp index e24134a72..bacf189c6 100644 --- a/src/net/eathena/messagein.cpp +++ b/src/net/eathena/messagein.cpp @@ -22,6 +22,7 @@ #include "net/eathena/messagein.h" +#include "net/net.h" #include "net/packetcounters.h" #include "logger.h" @@ -43,7 +44,26 @@ MessageIn::MessageIn(const char *const data, const unsigned int length) : void MessageIn::postInit() { // Read the message ID - mId = readInt16("packet id"); + mId = readId(); + IGNOREDEBUGLOG; + DEBUGLOG2("Receive packet", 0, "MessageIn"); + readInt16("packet id"); +} + +uint16_t MessageIn::readId() +{ + int16_t value = -1; + if (mPos + 2 <= mLength) + { +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + int16_t swap; + memcpy(&swap, mData + static_cast(mPos), sizeof(int16_t)); + value = SDL_Swap16(swap); +#else + memcpy(&value, mData + static_cast(mPos), sizeof(int16_t)); +#endif + } + return value; } int16_t MessageIn::readInt16(const char *const str) -- cgit v1.2.3-70-g09d2