summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-01-06 18:50:29 +0300
committerAndrei Karas <akaras@inbox.ru>2014-01-06 18:50:29 +0300
commite133b490e49acbfacf9ef86b50338ba923ed6a2f (patch)
treed236f8712cdf44cc0ee8427932a7e0dfcefe5f18 /src
parentc79af51bea401a358764791b0e2e1d7c75a4adc1 (diff)
downloadplus-e133b490e49acbfacf9ef86b50338ba923ed6a2f.tar.gz
plus-e133b490e49acbfacf9ef86b50338ba923ed6a2f.tar.bz2
plus-e133b490e49acbfacf9ef86b50338ba923ed6a2f.tar.xz
plus-e133b490e49acbfacf9ef86b50338ba923ed6a2f.zip
add support for include in status-effects.xml.
Diffstat (limited to 'src')
-rw-r--r--src/statuseffect.cpp20
-rw-r--r--src/statuseffect.h2
2 files changed, 19 insertions, 3 deletions
diff --git a/src/statuseffect.cpp b/src/statuseffect.cpp
index 018fe39ec..be173b023 100644
--- a/src/statuseffect.cpp
+++ b/src/statuseffect.cpp
@@ -127,17 +127,32 @@ void StatusEffect::load()
if (mLoaded)
unload();
- XML::Document doc(paths.getStringValue("statusEffectsFile"));
+ loadXmlFile(paths.getStringValue("statusEffectsFile"));
+
+ mLoaded = true;
+}
+
+void StatusEffect::loadXmlFile(const std::string &fileName)
+{
+ XML::Document doc(fileName);
const XmlNodePtr rootNode = doc.rootNode();
if (!rootNode || !xmlNameEqual(rootNode, "status-effects"))
{
- logger->log1("Error loading status effects file");
+ logger->log("Error loading status effects file: " + fileName);
return;
}
for_each_xml_child_node(node, rootNode)
{
+ if (xmlNameEqual(node, "include"))
+ {
+ const std::string name = XML::getProperty(node, "name", "");
+ if (!name.empty())
+ loadXmlFile(name);
+ continue;
+ }
+
status_effect_map *the_map = nullptr;
const int index = atoi(XML::getProperty(node, "id", "-1").c_str());
@@ -182,7 +197,6 @@ void StatusEffect::load()
(*the_map)[0][index] = endEffect;
}
}
- mLoaded = true;
}
static void unloadMap(std::map<int, StatusEffect *> &map)
diff --git a/src/statuseffect.h b/src/statuseffect.h
index 7c36b48bf..6dda71cfc 100644
--- a/src/statuseffect.h
+++ b/src/statuseffect.h
@@ -105,6 +105,8 @@ public:
static void load();
+ static void loadXmlFile(const std::string &fileName);
+
static void unload();
private:
static bool mLoaded;