summaryrefslogtreecommitdiff
path: root/src/resources/db
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-06-29 23:24:11 +0300
committerAndrei Karas <akaras@inbox.ru>2016-06-30 00:03:20 +0300
commit1afa5bf3c437150dd18ad4e8d435072b103283c3 (patch)
tree8019d315cb94e390b23fb49c7d7624d886aa11bb /src/resources/db
parentd0a72be7362cfad41187b6e9544ac44802a66ebd (diff)
downloadplus-1afa5bf3c437150dd18ad4e8d435072b103283c3.tar.gz
plus-1afa5bf3c437150dd18ad4e8d435072b103283c3.tar.bz2
plus-1afa5bf3c437150dd18ad4e8d435072b103283c3.tar.xz
plus-1afa5bf3c437150dd18ad4e8d435072b103283c3.zip
Allow read basic attributes from stats.xml
Diffstat (limited to 'src/resources/db')
-rw-r--r--src/resources/db/statdb.cpp33
1 files changed, 28 insertions, 5 deletions
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);
+ }
}
}