summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-01-06 15:43:45 +0300
committerAndrei Karas <akaras@inbox.ru>2014-01-06 15:43:45 +0300
commit4c4ceabb105079fdf389e0c63d106e1d1e21b0c5 (patch)
treefeb14a45b548bda378194370625473216d9fd1c3
parent17919a843d9b20595651b712e664a6d796b59898 (diff)
downloadmanaverse-4c4ceabb105079fdf389e0c63d106e1d1e21b0c5.tar.gz
manaverse-4c4ceabb105079fdf389e0c63d106e1d1e21b0c5.tar.bz2
manaverse-4c4ceabb105079fdf389e0c63d106e1d1e21b0c5.tar.xz
manaverse-4c4ceabb105079fdf389e0c63d106e1d1e21b0c5.zip
add support for include in hair.xml.
-rw-r--r--src/resources/db/colordb.cpp30
-rw-r--r--src/resources/db/colordb.h3
2 files changed, 20 insertions, 13 deletions
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<int, ItemColor> 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<int>((*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<int, ItemColor> &colors)
{
- std::map <int, ItemColor> 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 <code>colors.xml</code>.
*/
- void loadHair();
+ void loadHair(const std::string &fileName,
+ std::map<int, ItemColor> &colors);
void loadColorLists();