summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/npcdb.cpp17
-rw-r--r--src/resources/npcdb.h4
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