diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-09-13 19:27:47 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-09-13 19:27:47 +0300 |
commit | 331d1d0989acccf5247d34561d0c962f7a64adc2 (patch) | |
tree | 7b60f9e6242763b0fd810ac3270f32fe7866ad2c | |
parent | dca3de26978bf0a9d7ac9df8524c90b85f8920da (diff) | |
download | manaplus-331d1d0989acccf5247d34561d0c962f7a64adc2.tar.gz manaplus-331d1d0989acccf5247d34561d0c962f7a64adc2.tar.bz2 manaplus-331d1d0989acccf5247d34561d0c962f7a64adc2.tar.xz manaplus-331d1d0989acccf5247d34561d0c962f7a64adc2.zip |
Add basic support for networkdb.
-rw-r--r-- | src/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/client.cpp | 3 | ||||
-rw-r--r-- | src/defaults.cpp | 3 | ||||
-rw-r--r-- | src/resources/db/networkdb.cpp | 65 | ||||
-rw-r--r-- | src/resources/db/networkdb.h | 48 |
6 files changed, 123 insertions, 0 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1bd322e14..d04f82b52 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -708,6 +708,8 @@ SET(SRCS enums/resources/notifytypes.h resources/db/monsterdb.cpp resources/db/monsterdb.h + resources/db/networkdb.cpp + resources/db/networkdb.h resources/db/npcdb.cpp resources/db/npcdb.h resources/db/npcdialogdb.cpp diff --git a/src/Makefile.am b/src/Makefile.am index b3595ec94..b88c41eb7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1260,6 +1260,8 @@ manaplus_SOURCES += main.cpp \ resources/db/moddb.h \ resources/db/monsterdb.cpp \ resources/db/monsterdb.h \ + resources/db/networkdb.cpp \ + resources/db/networkdb.h \ resources/db/npcdb.cpp \ resources/db/npcdb.h \ resources/db/npcdialogdb.cpp \ diff --git a/src/client.cpp b/src/client.cpp index 4b6b3118f..9ac6c0df5 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -118,6 +118,7 @@ #include "resources/db/mercenarydb.h" #include "resources/db/moddb.h" #include "resources/db/monsterdb.h" +#include "resources/db/networkdb.h" #include "resources/db/npcdb.h" #include "resources/db/npcdialogdb.h" #include "resources/db/palettedb.h" @@ -626,6 +627,7 @@ void Client::gameClear() PETDB::unload(); StatusEffectDB::unload(); ModDB::unload(); + NetworkDb::unload(); if (loginHandler) loginHandler->clearWorlds(); @@ -1325,6 +1327,7 @@ int Client::gameExec() AttributesEnum::init(); // Load XML databases + NetworkDb::load(); CharDB::load(); StatDb::load(); DeadDB::load(); diff --git a/src/defaults.cpp b/src/defaults.cpp index bd4ea9224..312c3a2fe 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -627,6 +627,9 @@ DefaultsData* getPathsDefaults() AddDEF("badgesFile", "badges.xml"); AddDEF("badgesPatchFile", "badges_patch.xml"); AddDEF("badgesPatchDir", "badges.d"); + AddDEF("networkFile", "network.xml"); + AddDEF("networkPatchFile", "network_patch.xml"); + AddDEF("networkPatchDir", "network.d"); AddDEF("statFile", "stats.xml"); AddDEF("statPatchFile", "stats_patch.xml"); AddDEF("statPatchDir", "stats.d"); diff --git a/src/resources/db/networkdb.cpp b/src/resources/db/networkdb.cpp new file mode 100644 index 000000000..afab56af3 --- /dev/null +++ b/src/resources/db/networkdb.cpp @@ -0,0 +1,65 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2016 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "resources/db/networkdb.h" + +#include "configuration.h" + +#include "utils/xmlutils.h" + +#include "resources/beingcommon.h" + +#include "debug.h" + +namespace +{ + bool mLoaded = false; + NetworkInfos mInPackets; +} // namespace + +void NetworkDb::load() +{ + if (mLoaded) + unload(); + + loadXmlFile(paths.getStringValue("networkFile"), SkipError_false); + loadXmlFile(paths.getStringValue("networkPatchFile"), SkipError_true); + loadXmlDir("networkPatchDir", loadXmlFile); + mLoaded = true; +} + +void NetworkDb::loadXmlFile(const std::string &fileName, + const SkipError skipError) +{ + readXmlIntMap(fileName, + "network", + "inpackets", + "fakepacket", + "id", + "len", + mInPackets, + skipError); +} + +void NetworkDb::unload() +{ + mInPackets.clear(); + mLoaded = false; +} diff --git a/src/resources/db/networkdb.h b/src/resources/db/networkdb.h new file mode 100644 index 000000000..822925fa0 --- /dev/null +++ b/src/resources/db/networkdb.h @@ -0,0 +1,48 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2016 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef RESOURCES_DB_NETWORKDB_H +#define RESOURCES_DB_NETWORKDB_H + +#include "enums/simpletypes/skiperror.h" + +#include <map> +#include <string> + +typedef std::map<int32_t, int32_t> NetworkInfos; +typedef NetworkInfos::const_iterator NetworkInfosIter; + +namespace NetworkDb +{ + /** + * Loads the chars data. + */ + void load(); + + void loadXmlFile(const std::string &fileName, + const SkipError skipError); + + /** + * Clear the chars data + */ + void unload(); +} // namespace NetworkDb + +#endif // RESOURCES_DB_NETWORKDB_H |