diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-06-29 23:24:11 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-06-30 00:03:20 +0300 |
commit | 1afa5bf3c437150dd18ad4e8d435072b103283c3 (patch) | |
tree | 8019d315cb94e390b23fb49c7d7624d886aa11bb | |
parent | d0a72be7362cfad41187b6e9544ac44802a66ebd (diff) | |
download | ManaVerse-1afa5bf3c437150dd18ad4e8d435072b103283c3.tar.gz ManaVerse-1afa5bf3c437150dd18ad4e8d435072b103283c3.tar.bz2 ManaVerse-1afa5bf3c437150dd18ad4e8d435072b103283c3.tar.xz ManaVerse-1afa5bf3c437150dd18ad4e8d435072b103283c3.zip |
Allow read basic attributes from stats.xml
-rw-r--r-- | src/enums/being/attributes.h | 3 | ||||
-rw-r--r-- | src/resources/db/statdb.cpp | 33 |
2 files changed, 30 insertions, 6 deletions
diff --git a/src/enums/being/attributes.h b/src/enums/being/attributes.h index c6c3d00d6..d5198be79 100644 --- a/src/enums/being/attributes.h +++ b/src/enums/being/attributes.h @@ -60,7 +60,8 @@ enumStart(Attributes) DEF, ATK, CART_TOTAL_WEIGHT = 1000, - CART_MAX_WEIGHT + CART_MAX_WEIGHT, + MAX_ATTRIBUTE } enumEnd(Attributes); diff --git a/src/resources/db/statdb.cpp b/src/resources/db/statdb.cpp index 36748c476..064ae0b84 100644 --- a/src/resources/db/statdb.cpp +++ b/src/resources/db/statdb.cpp @@ -91,16 +91,35 @@ void StatDb::load() logger->log1("Initializing stat database..."); - addBasicStats(); - loadXmlFile(paths.getStringValue("statFile"), SkipError_false); loadXmlFile(paths.getStringValue("statPatchFile"), SkipError_true); loadXmlDir("statPatchDir", loadXmlFile); mLoaded = true; } +static void loadBasicStats(const XmlNodePtr rootNode) +{ + const int maxAttr = static_cast<int>(Attributes::MAX_ATTRIBUTE); + for_each_xml_child_node(node, rootNode) + { + if (xmlNameEqual(node, "stat")) + { + const int id = XML::getProperty(node, "id", 0); + if (id <= 0 || id >= maxAttr) + continue; + const std::string tag = XML::getProperty(node, "tag", ""); + const std::string name = XML::getProperty(node, "name", ""); + const std::string format = XML::getProperty(node, "format", ""); + mBasicStats.push_back(BasicStat(static_cast<AttributesT>(id), + tag, + name, + format)); + } + } +} + void StatDb::loadXmlFile(const std::string &fileName, - const SkipError skipError) + const SkipError skipError) { XML::Document doc(fileName, UseResman_true, @@ -111,6 +130,8 @@ void StatDb::loadXmlFile(const std::string &fileName, { logger->log("StatDb: Error while loading %s!", fileName.c_str()); + if (skipError == SkipError_false) + addBasicStats(); return; } @@ -123,8 +144,10 @@ void StatDb::loadXmlFile(const std::string &fileName, loadXmlFile(name, skipError); continue; } - - + else if (xmlNameEqual(node, "basic")) + { + loadBasicStats(node); + } } } |