From bcc91d04a8be00ec347fc2fa84f4bd4c50e65a56 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 28 May 2013 19:57:35 +0300 Subject: Add support for include in monsters.xml --- src/resources/monsterdb.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/resources/monsterdb.cpp') diff --git a/src/resources/monsterdb.cpp b/src/resources/monsterdb.cpp index 870b53fa5..9a47b7c61 100644 --- a/src/resources/monsterdb.cpp +++ b/src/resources/monsterdb.cpp @@ -49,8 +49,13 @@ void MonsterDB::load() unload(); logger->log1("Initializing monster database..."); + loadXmlFile(paths.getStringValue("monstersFile")); + mLoaded = true; +} - XML::Document doc(paths.getStringValue("monstersFile")); +void MonsterDB::loadXmlFile(const std::string &fileName) +{ + XML::Document doc(fileName); const XmlNodePtr rootNode = doc.rootNode(); if (!rootNode || !xmlNameEqual(rootNode, "monsters")) @@ -73,6 +78,13 @@ void MonsterDB::load() // iterate s for_each_xml_child_node(monsterNode, rootNode) { + if (xmlNameEqual(monsterNode, "include")) + { + const std::string name = XML::getProperty(monsterNode, "name", ""); + if (!name.empty()) + loadXmlFile(name); + continue; + } if (!xmlNameEqual(monsterNode, "monster")) continue; @@ -233,7 +245,6 @@ void MonsterDB::load() monsterNode, "id", 0) + offset] = currentInfo; } - mLoaded = true; } void MonsterDB::unload() -- cgit v1.2.3-70-g09d2