From e133b490e49acbfacf9ef86b50338ba923ed6a2f Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 6 Jan 2014 18:50:29 +0300 Subject: add support for include in status-effects.xml. --- src/statuseffect.cpp | 20 +++++++++++++++++--- src/statuseffect.h | 2 ++ 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 &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; -- cgit v1.2.3-60-g2f50