summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/colordb.cpp27
-rw-r--r--src/resources/colordb.h4
2 files changed, 25 insertions, 6 deletions
diff --git a/src/resources/colordb.cpp b/src/resources/colordb.cpp
index 1ffe507b2..bce768d6d 100644
--- a/src/resources/colordb.cpp
+++ b/src/resources/colordb.cpp
@@ -65,7 +65,7 @@ void ColorDB::loadHair()
if (!root || !xmlNameEqual(root, "colors"))
{
logger->log1("ColorDB: Failed to find any color files.");
- mHairColors[0] = mFail;
+ mHairColors[0] = ItemColor(0, "", "");
mLoaded = true;
delete doc;
@@ -83,9 +83,8 @@ void ColorDB::loadHair()
if (mHairColors.find(id) != mHairColors.end())
logger->log("ColorDB: Redefinition of dye ID %d", id);
- mHairColors[id] = hairXml ?
- XML::getProperty(node, "value", "#FFFFFF") :
- XML::getProperty(node, "dye", "#FFFFFF");
+ mHairColors[id] = ItemColor(id, XML::getProperty(node, "name", ""),
+ XML::getProperty(node, hairXml ? "value" : "dye", "#FFFFFF"));
}
}
@@ -158,7 +157,25 @@ std::string &ColorDB::getHairColor(int id)
}
else
{
- return i->second;
+ return i->second.color;
+ }
+}
+
+std::string &ColorDB::getHairColorName(int id)
+{
+ if (!mLoaded)
+ load();
+
+ ColorIterator i = mHairColors.find(id);
+
+ if (i == mHairColors.end())
+ {
+ logger->log("ColorDB: Error, unknown dye ID# %d", id);
+ return mFail;
+ }
+ else
+ {
+ return i->second.name;
}
}
diff --git a/src/resources/colordb.h b/src/resources/colordb.h
index 36907095e..ade4227f8 100644
--- a/src/resources/colordb.h
+++ b/src/resources/colordb.h
@@ -70,12 +70,14 @@ namespace ColorDB
std::string &getHairColor(int id);
+ std::string &getHairColorName(int id);
+
int getHairSize();
std::map <int, ItemColor> *getColorsList(std::string name);
// Color DB
- typedef std::map<int, std::string> Colors;
+ typedef std::map<int, ItemColor> Colors;
typedef Colors::iterator ColorIterator;
typedef std::map <std::string, std::map <int, ItemColor> > ColorLists;
typedef ColorLists::iterator ColorListsIterator;