summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client.cpp6
-rw-r--r--src/net/eathena/network.cpp32
-rw-r--r--src/net/eathena/network.h2
-rw-r--r--src/net/eathena/updateprotocol.cpp1
-rw-r--r--src/resources/db/networkdb.cpp7
-rw-r--r--src/resources/db/networkdb.h2
6 files changed, 48 insertions, 2 deletions
diff --git a/src/client.cpp b/src/client.cpp
index 9ac6c0df5..64297d599 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -616,6 +616,7 @@ void Client::gameClear()
ElementalDb::unload();
SkillUnitDb::unload();
HorseDB::unload();
+ NetworkDb::unload();
}
MonsterDB::unload();
NPCDB::unload();
@@ -627,7 +628,6 @@ void Client::gameClear()
PETDB::unload();
StatusEffectDB::unload();
ModDB::unload();
- NetworkDb::unload();
if (loginHandler)
loginHandler->clearWorlds();
@@ -1327,7 +1327,6 @@ int Client::gameExec()
AttributesEnum::init();
// Load XML databases
- NetworkDb::load();
CharDB::load();
StatDb::load();
DeadDB::load();
@@ -1342,6 +1341,9 @@ int Client::gameExec()
if (type == ServerType::EATHENA ||
type == ServerType::EVOL2)
{
+ NetworkDb::load();
+ if (loginHandler)
+ loginHandler->updatePacketVersion();
MercenaryDB::load();
HomunculusDB::load();
ElementalDb::load();
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();
}
}
diff --git a/src/resources/db/networkdb.cpp b/src/resources/db/networkdb.cpp
index afab56af3..c430d0f7a 100644
--- a/src/resources/db/networkdb.cpp
+++ b/src/resources/db/networkdb.cpp
@@ -21,6 +21,7 @@
#include "resources/db/networkdb.h"
#include "configuration.h"
+#include "logger.h"
#include "utils/xmlutils.h"
@@ -39,6 +40,7 @@ void NetworkDb::load()
if (mLoaded)
unload();
+ logger->log1("Initializing network database...");
loadXmlFile(paths.getStringValue("networkFile"), SkipError_false);
loadXmlFile(paths.getStringValue("networkPatchFile"), SkipError_true);
loadXmlDir("networkPatchDir", loadXmlFile);
@@ -63,3 +65,8 @@ void NetworkDb::unload()
mInPackets.clear();
mLoaded = false;
}
+
+const NetworkInfos &NetworkDb::getFakePackets()
+{
+ return mInPackets;
+}
diff --git a/src/resources/db/networkdb.h b/src/resources/db/networkdb.h
index 822925fa0..899fc6cda 100644
--- a/src/resources/db/networkdb.h
+++ b/src/resources/db/networkdb.h
@@ -43,6 +43,8 @@ namespace NetworkDb
* Clear the chars data
*/
void unload();
+
+ const NetworkInfos &getFakePackets();
} // namespace NetworkDb
#endif // RESOURCES_DB_NETWORKDB_H