summaryrefslogtreecommitdiff
path: root/src/net/eathena/network.cpp
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/network.cpp
parent331d1d0989acccf5247d34561d0c962f7a64adc2 (diff)
downloadmanaplus-db1d3323103f15c3d31378b9e94982191855d984.tar.gz
manaplus-db1d3323103f15c3d31378b9e94982191855d984.tar.bz2
manaplus-db1d3323103f15c3d31378b9e94982191855d984.tar.xz
manaplus-db1d3323103f15c3d31378b9e94982191855d984.zip
Add fake packets from network.xml if packet unused.
Diffstat (limited to 'src/net/eathena/network.cpp')
-rw-r--r--src/net/eathena/network.cpp32
1 files changed, 32 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 ++)