From 4c4ceabb105079fdf389e0c63d106e1d1e21b0c5 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 6 Jan 2014 15:43:45 +0300 Subject: add support for include in hair.xml. --- src/resources/db/colordb.cpp | 30 ++++++++++++++++++------------ src/resources/db/colordb.h | 3 ++- 2 files changed, 20 insertions(+), 13 deletions(-) (limited to 'src/resources') diff --git a/src/resources/db/colordb.cpp b/src/resources/db/colordb.cpp index e3ab56672..d4828cc75 100644 --- a/src/resources/db/colordb.cpp +++ b/src/resources/db/colordb.cpp @@ -43,11 +43,17 @@ void ColorDB::load() if (mLoaded) unload(); - loadHair(); + std::map colors; + ColorListsIterator it = mColorLists.find("hair"); + if (it != mColorLists.end()) + colors = it->second; + loadHair(paths.getStringValue("hairColorFile"), colors); + mColorLists["hair"] = colors; + if (serverVersion >= 1) loadColorLists(); - const ColorListsIterator it = mColorLists.find("hair"); + it = mColorLists.find("hair"); if (it != mColorLists.end()) mHairColorsSize = static_cast((*it).second.size()); else @@ -55,16 +61,10 @@ void ColorDB::load() mLoaded = true; } -void ColorDB::loadHair() +void ColorDB::loadHair(const std::string &fileName, + std::map &colors) { - std::map colors; - const ColorListsIterator it = mColorLists.find("hair"); - - if (it != mColorLists.end()) - colors = it->second; - - XML::Document *doc = new XML::Document( - paths.getStringValue("hairColorFile")); + XML::Document *doc = new XML::Document(fileName); XmlNodePtr root = doc->rootNode(); bool hairXml = true; @@ -79,6 +79,13 @@ void ColorDB::loadHair() for_each_xml_child_node(node, root) { + if (xmlNameEqual(node, "include")) + { + const std::string name = XML::getProperty(node, "name", ""); + if (!name.empty()) + loadHair(name, colors); + continue; + } if (xmlNameEqual(node, "color")) { const int id = XML::getProperty(node, "id", 0); @@ -92,7 +99,6 @@ void ColorDB::loadHair() } delete doc; - mColorLists["hair"] = colors; } void ColorDB::loadColorLists() diff --git a/src/resources/db/colordb.h b/src/resources/db/colordb.h index e466102f9..d940ef772 100644 --- a/src/resources/db/colordb.h +++ b/src/resources/db/colordb.h @@ -62,7 +62,8 @@ namespace ColorDB /** * Loads the color data from colors.xml. */ - void loadHair(); + void loadHair(const std::string &fileName, + std::map &colors); void loadColorLists(); -- cgit v1.2.3-70-g09d2