summaryrefslogtreecommitdiff
path: root/src/net/eathena
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-09-13 21:57:12 +0300
committerAndrei Karas <akaras@inbox.ru>2016-09-13 21:57:12 +0300
commitdb1d3323103f15c3d31378b9e94982191855d984 (patch)
tree85c0aa4c738fceb135d5fe954a7512d22fff1c9f /src/net/eathena
parent331d1d0989acccf5247d34561d0c962f7a64adc2 (diff)
downloadplus-db1d3323103f15c3d31378b9e94982191855d984.tar.gz
plus-db1d3323103f15c3d31378b9e94982191855d984.tar.bz2
plus-db1d3323103f15c3d31378b9e94982191855d984.tar.xz
plus-db1d3323103f15c3d31378b9e94982191855d984.zip
Add fake packets from network.xml if packet unused.
Diffstat (limited to 'src/net/eathena')
-rw-r--r--src/net/eathena/network.cpp32
-rw-r--r--src/net/eathena/network.h2
-rw-r--r--src/net/eathena/updateprotocol.cpp1
3 files changed, 35 insertions, 0 deletions
diff --git a/src/net/eathena/network.cpp b/src/net/eathena/network.cpp
index 21736333c..74f3c3e00 100644
--- a/src/net/eathena/network.cpp
+++ b/src/net/eathena/network.cpp
@@ -80,6 +80,10 @@
#include "net/eathena/messagein.h"
+#include "resources/db/networkdb.h"
+
+#include "utils/checkutils.h"
+
#include "debug.h"
extern int packetVersion;
@@ -111,6 +115,34 @@ void Network::registerHandlers()
RECVPACKETS_VOID
}
+void Network::registerFakeHandlers()
+{
+ const NetworkInfos &packets = NetworkDb::getFakePackets();
+ FOR_EACH (NetworkInfosIter, it, packets)
+ {
+ const size_t id = (*it).first;
+ if (id >= packet_lengths_size)
+ {
+ reportAlways("Wrong fake packet id %d", CAST_S32(id));
+ continue;
+ }
+ if (mPackets[id].len != 0 ||
+ mPackets[id].func != nullptr ||
+ mPackets[id].version != 0)
+ {
+ continue;
+ }
+ const int32_t len = (*it).second;
+ logger->log("Add fake packet: %d, %d",
+ CAST_S32(id),
+ len);
+ mPackets[id].name = "fake";
+ mPackets[id].len = len;
+ mPackets[id].func = nullptr;
+ mPackets[id].version = 0;
+ }
+}
+
void Network::clearHandlers()
{
for (size_t f = 0; f < packet_lengths_size; f ++)
diff --git a/src/net/eathena/network.h b/src/net/eathena/network.h
index 429603237..ec8890cfc 100644
--- a/src/net/eathena/network.h
+++ b/src/net/eathena/network.h
@@ -51,6 +51,8 @@ class Network final : public Ea::Network
void registerHandlers();
+ void registerFakeHandlers();
+
static Network *mInstance;
protected:
diff --git a/src/net/eathena/updateprotocol.cpp b/src/net/eathena/updateprotocol.cpp
index 2e7dc8cb9..bae8b81fe 100644
--- a/src/net/eathena/updateprotocol.cpp
+++ b/src/net/eathena/updateprotocol.cpp
@@ -45,6 +45,7 @@ void updateProtocol()
{
network->clearHandlers();
network->registerHandlers();
+ network->registerFakeHandlers();
}
}