diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-05-28 20:08:11 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-05-28 20:29:17 +0300 |
commit | 5ed8cf4555496ff5636c09ac12be91fb67a2a283 (patch) | |
tree | 0d52730da5cc17bc770a37f98619c05353d5d1d2 /src/resources/npcdb.cpp | |
parent | bcc91d04a8be00ec347fc2fa84f4bd4c50e65a56 (diff) | |
download | manaverse-5ed8cf4555496ff5636c09ac12be91fb67a2a283.tar.gz manaverse-5ed8cf4555496ff5636c09ac12be91fb67a2a283.tar.bz2 manaverse-5ed8cf4555496ff5636c09ac12be91fb67a2a283.tar.xz manaverse-5ed8cf4555496ff5636c09ac12be91fb67a2a283.zip |
Add support for include in npcs.xml
Diffstat (limited to 'src/resources/npcdb.cpp')
-rw-r--r-- | src/resources/npcdb.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/resources/npcdb.cpp b/src/resources/npcdb.cpp index 7b991e7d8..fe10370a5 100644 --- a/src/resources/npcdb.cpp +++ b/src/resources/npcdb.cpp @@ -46,7 +46,13 @@ void NPCDB::load() logger->log1("Initializing NPC database..."); - XML::Document doc(paths.getStringValue("npcsFile")); + loadXmlFile(paths.getStringValue("npcsFile")); + mLoaded = true; +} + +void NPCDB::loadXmlFile(const std::string &fileName) +{ + XML::Document doc(fileName); const XmlNodePtr rootNode = doc.rootNode(); if (!rootNode || !xmlNameEqual(rootNode, "npcs")) @@ -60,6 +66,14 @@ void NPCDB::load() // iterate <npc>s for_each_xml_child_node(npcNode, rootNode) { + if (xmlNameEqual(npcNode, "include")) + { + const std::string name = XML::getProperty(npcNode, "name", ""); + if (!name.empty()) + loadXmlFile(name); + continue; + } + if (!xmlNameEqual(npcNode, "npc")) continue; @@ -123,7 +137,6 @@ void NPCDB::load() mNPCInfos[id] = currentInfo; } - mLoaded = true; } void NPCDB::unload() |