summaryrefslogtreecommitdiff
path: root/src/net/eathena
diff options
context:
space:
mode:
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();
}
}