summaryrefslogtreecommitdiff
path: root/src/net/eathena
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-09-17 16:34:43 +0300
committerAndrei Karas <akaras@inbox.ru>2014-09-17 16:58:46 +0300
commit38659dbd75d81edbe336d5311a1cd1184d359b7e (patch)
tree919c97a5e48c5e9287250eab34cb36ef5f02c21e /src/net/eathena
parentc1ba61eb566a0a1a2532690ba3bf7e6498bee06b (diff)
downloadmv-38659dbd75d81edbe336d5311a1cd1184d359b7e.tar.gz
mv-38659dbd75d81edbe336d5311a1cd1184d359b7e.tar.bz2
mv-38659dbd75d81edbe336d5311a1cd1184d359b7e.tar.xz
mv-38659dbd75d81edbe336d5311a1cd1184d359b7e.zip
add support for ignore packets logging.
Option for coma separated packet ids added in misc tab.
Diffstat (limited to 'src/net/eathena')
-rw-r--r--src/net/eathena/messagein.cpp22
-rw-r--r--src/net/eathena/messagein.h2
2 files changed, 23 insertions, 1 deletions
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<size_t>(mPos), sizeof(int16_t));
+ value = SDL_Swap16(swap);
+#else
+ memcpy(&value, mData + static_cast<size_t>(mPos), sizeof(int16_t));
+#endif
+ }
+ return value;
}
int16_t MessageIn::readInt16(const char *const str)
diff --git a/src/net/eathena/messagein.h b/src/net/eathena/messagein.h
index 1b9001c64..fec2b5e4f 100644
--- a/src/net/eathena/messagein.h
+++ b/src/net/eathena/messagein.h
@@ -53,6 +53,8 @@ class MessageIn final : public Net::MessageIn
int32_t readInt32(const char *const str = nullptr);
int64_t readInt64(const char *const str = nullptr);
+
+ uint16_t readId();
};
} // namespace EAthena