summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-03-31 23:33:24 +0300
committerAndrei Karas <akaras@inbox.ru>2016-04-01 00:08:29 +0300
commit15f4f0d6fecf4dc38ae1ec07c0abb04c20e22c1e (patch)
tree8428836351e6ea64d8f19f9324fd58bcde698ee9 /src/net
parent9b06b6b56522f23eb3752d3a1e099c75ba130fc9 (diff)
downloadmanaverse-15f4f0d6fecf4dc38ae1ec07c0abb04c20e22c1e.tar.gz
manaverse-15f4f0d6fecf4dc38ae1ec07c0abb04c20e22c1e.tar.bz2
manaverse-15f4f0d6fecf4dc38ae1ec07c0abb04c20e22c1e.tar.xz
manaverse-15f4f0d6fecf4dc38ae1ec07c0abb04c20e22c1e.zip
Set packet version based on packet id and current packet version into version in MessageIn.
Only for hercules.
Diffstat (limited to 'src/net')
-rw-r--r--src/net/eathena/messagein.cpp11
-rw-r--r--src/net/eathena/messagein.h3
-rw-r--r--src/net/eathena/network.cpp5
-rw-r--r--src/net/messagein.cpp1
-rw-r--r--src/net/messagein.h4
5 files changed, 21 insertions, 3 deletions
diff --git a/src/net/eathena/messagein.cpp b/src/net/eathena/messagein.cpp
index 3a71e0c76..7b21b7485 100644
--- a/src/net/eathena/messagein.cpp
+++ b/src/net/eathena/messagein.cpp
@@ -40,12 +40,21 @@ MessageIn::MessageIn(const char *const data,
{
}
-void MessageIn::postInit(const char *const str)
+void MessageIn::postInit(const char *const str,
+ const unsigned int version)
{
// Read the message ID
mId = readId();
+ mVersion = version;
IGNOREDEBUGLOG;
DEBUGLOG2("Receive packet", 0, "MessageIn");
+#ifdef ENABLEDEBUGLOG
+ if (mVersion > 0)
+ {
+ const std::string verStr = toString(mVersion);
+ DEBUGLOG2("Version", 0, verStr.c_str());
+ }
+#endif
readInt16(str);
}
diff --git a/src/net/eathena/messagein.h b/src/net/eathena/messagein.h
index da5f57d7d..5ba13ea9c 100644
--- a/src/net/eathena/messagein.h
+++ b/src/net/eathena/messagein.h
@@ -46,7 +46,8 @@ class MessageIn final : public Net::MessageIn
A_DELETE_COPY(MessageIn)
- void postInit(const char *const str);
+ void postInit(const char *const str,
+ const unsigned int version);
/**< Reads a short. */
int16_t readInt16(const char *const str) override final;
diff --git a/src/net/eathena/network.cpp b/src/net/eathena/network.cpp
index fc0cd3837..96bebd320 100644
--- a/src/net/eathena/network.cpp
+++ b/src/net/eathena/network.cpp
@@ -134,7 +134,10 @@ void Network::dispatchMessages()
len = readWord(2);
MessageIn msg(mInBuffer, len);
- msg.postInit(mPackets[msgId].name);
+ unsigned int ver = mPackets[msgId].version;
+ if (ver == 0)
+ ver = packetVersion;
+ msg.postInit(mPackets[msgId].name, ver);
SDL_mutexV(mMutexIn);
if (len == 0)
diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp
index db0318a4d..8c2e32a75 100644
--- a/src/net/messagein.cpp
+++ b/src/net/messagein.cpp
@@ -42,6 +42,7 @@ MessageIn::MessageIn(const char *const data,
mData(data),
mLength(length),
mPos(0),
+ mVersion(0),
mId(0),
mIgnore(false)
{
diff --git a/src/net/messagein.h b/src/net/messagein.h
index 613eca09e..44d6a9aab 100644
--- a/src/net/messagein.h
+++ b/src/net/messagein.h
@@ -122,6 +122,9 @@ class MessageIn notfinal
static uint8_t fromServerDirection(const uint8_t serverDir)
A_WARN_UNUSED;
+ unsigned int getVersion() const A_WARN_UNUSED
+ { return mVersion; }
+
protected:
/**
* Constructor.
@@ -137,6 +140,7 @@ class MessageIn notfinal
* reading it.
*/
unsigned int mPos;
+ unsigned int mVersion;
uint16_t mId; /**< The message ID. */
bool mIgnore;
};