From 61e3fa8513c1bc2644348ac6052ab87785fb119d Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 26 May 2013 14:32:56 +0300 Subject: Add support for include tag in items.xml. Example: --- src/resources/itemdb.cpp | 13 ++++++++++++- src/resources/itemdb.h | 8 ++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp index b4ae544ba..4643b5d76 100644 --- a/src/resources/itemdb.cpp +++ b/src/resources/itemdb.cpp @@ -176,8 +176,12 @@ void ItemDB::load() mUnknown->setSprite(errFile, GENDER_FEMALE, 0); mUnknown->setSprite(errFile, GENDER_OTHER, 0); mUnknown->addTag(mTags["All"]); + loadXmlFile("items.xml", tagNum); +} - XML::Document doc("items.xml"); +void ItemDB::loadXmlFile(const std::string &fileName, int &tagNum) +{ + XML::Document doc(fileName); const XmlNodePtr rootNode = doc.rootNode(); if (!rootNode || !xmlNameEqual(rootNode, "items")) @@ -189,6 +193,13 @@ void ItemDB::load() for_each_xml_child_node(node, rootNode) { + if (xmlNameEqual(node, "include")) + { + const std::string name = XML::getProperty(node, "name", ""); + if (!name.empty()) + loadXmlFile(name, tagNum); + continue; + } if (!xmlNameEqual(node, "item")) continue; diff --git a/src/resources/itemdb.h b/src/resources/itemdb.h index 98b38d256..44ab68f6d 100644 --- a/src/resources/itemdb.h +++ b/src/resources/itemdb.h @@ -37,16 +37,12 @@ class ItemInfo; */ namespace ItemDB { - /** - * Loads the item data from items.xml. - */ void load(); - /** - * Frees item data. - */ void unload(); + void loadXmlFile(const std::string &fileName, int &tagNum); + const StringVect &getTags(); bool exists(const int id) A_WARN_UNUSED; -- cgit v1.2.3-70-g09d2