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 | |
parent | bcc91d04a8be00ec347fc2fa84f4bd4c50e65a56 (diff) | |
download | manaplus-5ed8cf4555496ff5636c09ac12be91fb67a2a283.tar.gz manaplus-5ed8cf4555496ff5636c09ac12be91fb67a2a283.tar.bz2 manaplus-5ed8cf4555496ff5636c09ac12be91fb67a2a283.tar.xz manaplus-5ed8cf4555496ff5636c09ac12be91fb67a2a283.zip |
Add support for include in npcs.xml
Diffstat (limited to 'src/resources')
-rw-r--r-- | src/resources/npcdb.cpp | 17 | ||||
-rw-r--r-- | src/resources/npcdb.h | 4 |
2 files changed, 19 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() diff --git a/src/resources/npcdb.h b/src/resources/npcdb.h index a01730ed8..83d938f5a 100644 --- a/src/resources/npcdb.h +++ b/src/resources/npcdb.h @@ -25,6 +25,8 @@ #include <stdint.h> +#include <string> + #include "localconsts.h" class BeingInfo; @@ -41,6 +43,8 @@ namespace NPCDB BeingInfo *get(const int id) A_WARN_UNUSED; uint16_t getAvatarFor(const int id); + + void loadXmlFile(const std::string &fileName); } #endif // RESOURCES_NPCDB_H |