diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-09-13 23:15:31 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-09-13 23:15:31 +0300 |
commit | 0fc8851faef219be6a3e161946fd6a09930efeb0 (patch) | |
tree | 10e6af31050715ad1267fe87cd00b81bcb0eb2f3 | |
parent | db1d3323103f15c3d31378b9e94982191855d984 (diff) | |
download | manaverse-0fc8851faef219be6a3e161946fd6a09930efeb0.tar.gz manaverse-0fc8851faef219be6a3e161946fd6a09930efeb0.tar.bz2 manaverse-0fc8851faef219be6a3e161946fd6a09930efeb0.tar.xz manaverse-0fc8851faef219be6a3e161946fd6a09930efeb0.zip |
Add support for removepacket tag in network.xml
-rw-r--r-- | src/net/eathena/network.cpp | 28 | ||||
-rw-r--r-- | src/resources/db/networkdb.cpp | 19 | ||||
-rw-r--r-- | src/resources/db/networkdb.h | 11 | ||||
-rw-r--r-- | src/utils/xmlutils.cpp | 1 |
4 files changed, 51 insertions, 8 deletions
diff --git a/src/net/eathena/network.cpp b/src/net/eathena/network.cpp index 74f3c3e00..973d306f9 100644 --- a/src/net/eathena/network.cpp +++ b/src/net/eathena/network.cpp @@ -117,8 +117,8 @@ void Network::registerHandlers() void Network::registerFakeHandlers() { - const NetworkInfos &packets = NetworkDb::getFakePackets(); - FOR_EACH (NetworkInfosIter, it, packets) + const NetworkInPacketInfos &packets = NetworkDb::getFakePackets(); + FOR_EACH (NetworkInPacketInfosIter, it, packets) { const size_t id = (*it).first; if (id >= packet_lengths_size) @@ -141,6 +141,30 @@ void Network::registerFakeHandlers() mPackets[id].func = nullptr; mPackets[id].version = 0; } + + const NetworkRemovePacketInfos &removePackets = + NetworkDb::getRemovePackets(); + FOR_EACH (NetworkRemovePacketInfosIter, it, removePackets) + { + const size_t id = *it; + if (id >= packet_lengths_size) + { + reportAlways("Wrong remove packet id %d", CAST_S32(id)); + continue; + } + if (mPackets[id].len == 0 && + mPackets[id].func == nullptr && + mPackets[id].version == 0) + { + continue; + } + logger->log("Remove packet: %d", + CAST_S32(id)); + mPackets[id].name = ""; + mPackets[id].len = 0; + mPackets[id].func = nullptr; + mPackets[id].version = 0; + } } void Network::clearHandlers() diff --git a/src/resources/db/networkdb.cpp b/src/resources/db/networkdb.cpp index c430d0f7a..70a5b814f 100644 --- a/src/resources/db/networkdb.cpp +++ b/src/resources/db/networkdb.cpp @@ -32,7 +32,8 @@ namespace { bool mLoaded = false; - NetworkInfos mInPackets; + NetworkInPacketInfos mInPackets; + NetworkRemovePacketInfos mRemovePackets; } // namespace void NetworkDb::load() @@ -58,15 +59,29 @@ void NetworkDb::loadXmlFile(const std::string &fileName, "len", mInPackets, skipError); + + readXmlIntVector(fileName, + "network", + "inpackets", + "removepacket", + "id", + mRemovePackets, + skipError); } void NetworkDb::unload() { mInPackets.clear(); + mRemovePackets.clear(); mLoaded = false; } -const NetworkInfos &NetworkDb::getFakePackets() +const NetworkInPacketInfos &NetworkDb::getFakePackets() { return mInPackets; } + +const NetworkRemovePacketInfos &NetworkDb::getRemovePackets() +{ + return mRemovePackets; +} diff --git a/src/resources/db/networkdb.h b/src/resources/db/networkdb.h index 899fc6cda..b6eb47726 100644 --- a/src/resources/db/networkdb.h +++ b/src/resources/db/networkdb.h @@ -24,10 +24,13 @@ #include "enums/simpletypes/skiperror.h" #include <map> +#include <vector> #include <string> -typedef std::map<int32_t, int32_t> NetworkInfos; -typedef NetworkInfos::const_iterator NetworkInfosIter; +typedef std::map<int32_t, int32_t> NetworkInPacketInfos; +typedef NetworkInPacketInfos::const_iterator NetworkInPacketInfosIter; +typedef std::vector<int> NetworkRemovePacketInfos; +typedef NetworkRemovePacketInfos::const_iterator NetworkRemovePacketInfosIter; namespace NetworkDb { @@ -44,7 +47,9 @@ namespace NetworkDb */ void unload(); - const NetworkInfos &getFakePackets(); + const NetworkInPacketInfos &getFakePackets(); + + const NetworkRemovePacketInfos &getRemovePackets(); } // namespace NetworkDb #endif // RESOURCES_DB_NETWORKDB_H diff --git a/src/utils/xmlutils.cpp b/src/utils/xmlutils.cpp index 5cc14f517..797f8d48e 100644 --- a/src/utils/xmlutils.cpp +++ b/src/utils/xmlutils.cpp @@ -34,7 +34,6 @@ void readXmlIntVector(const std::string &fileName, std::vector<int> &arr, const SkipError skipError) { - arr.clear(); XML::Document doc(fileName, UseResman_true, skipError); const XmlNodePtrConst rootNode = doc.rootNode(); |