From a3fdbe3f382d11fcb83d7f3c342b676837478821 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 6 Jan 2014 16:19:38 +0300 Subject: add support for include in deadmessages.xml. --- src/resources/db/deaddb.cpp | 17 ++++++++++++++--- src/resources/db/deaddb.h | 2 ++ 2 files changed, 16 insertions(+), 3 deletions(-) (limited to 'src/resources/db') diff --git a/src/resources/db/deaddb.cpp b/src/resources/db/deaddb.cpp index ba4efc8a8..be7c9cade 100644 --- a/src/resources/db/deaddb.cpp +++ b/src/resources/db/deaddb.cpp @@ -34,12 +34,16 @@ namespace } // namespace void DeadDB::load() +{ + loadXmlFile(paths.getStringValue("deadMessagesFile")); +} + +void DeadDB::loadXmlFile(const std::string &fileName) { if (mLoaded) unload(); - XML::Document *doc = new XML::Document( - paths.getStringValue("deadMessagesFile")); + XML::Document *doc = new XML::Document(fileName); const XmlNodePtr root = doc->rootNode(); if (!root || !xmlNameEqual(root, "messages")) @@ -52,7 +56,14 @@ void DeadDB::load() for_each_xml_child_node(node, root) { - if (xmlNameEqual(node, "message")) + if (xmlNameEqual(node, "include")) + { + const std::string name = XML::getProperty(node, "name", ""); + if (!name.empty()) + loadXmlFile(name); + continue; + } + else if (xmlNameEqual(node, "message")) { const char *const data = reinterpret_cast( xmlNodeGetContent(node)); diff --git a/src/resources/db/deaddb.h b/src/resources/db/deaddb.h index 1e47e9c3b..06ed14722 100644 --- a/src/resources/db/deaddb.h +++ b/src/resources/db/deaddb.h @@ -33,6 +33,8 @@ namespace DeadDB */ void load(); + void loadXmlFile(const std::string &fileName); + /** * Clear the chars data */ -- cgit v1.2.3-70-g09d2