diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-05-28 19:57:35 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-05-28 20:29:17 +0300 |
commit | bcc91d04a8be00ec347fc2fa84f4bd4c50e65a56 (patch) | |
tree | 5106310d5bef8484b6875b1c8d53e24086068fde /src | |
parent | 74bccec70cf17b038a9add58b37d85f91ad04015 (diff) | |
download | ManaVerse-bcc91d04a8be00ec347fc2fa84f4bd4c50e65a56.tar.gz ManaVerse-bcc91d04a8be00ec347fc2fa84f4bd4c50e65a56.tar.bz2 ManaVerse-bcc91d04a8be00ec347fc2fa84f4bd4c50e65a56.tar.xz ManaVerse-bcc91d04a8be00ec347fc2fa84f4bd4c50e65a56.zip |
Add support for include in monsters.xml
Diffstat (limited to 'src')
-rw-r--r-- | src/resources/monsterdb.cpp | 15 | ||||
-rw-r--r-- | src/resources/monsterdb.h | 4 |
2 files changed, 17 insertions, 2 deletions
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 <monster>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() diff --git a/src/resources/monsterdb.h b/src/resources/monsterdb.h index 4d88320b5..426228388 100644 --- a/src/resources/monsterdb.h +++ b/src/resources/monsterdb.h @@ -25,6 +25,8 @@ #include "localconsts.h" +#include <string> + class BeingInfo; /** @@ -36,6 +38,8 @@ namespace MonsterDB void unload(); + void loadXmlFile(const std::string &fileName); + BeingInfo *get(const int id) A_WARN_UNUSED; } |