summaryrefslogtreecommitdiff
path: root/src/resources/db
diff options
context:
space:
mode:
Diffstat (limited to 'src/resources/db')
-rw-r--r--src/resources/db/itemdb.cpp25
-rw-r--r--src/resources/db/itemdb.h2
2 files changed, 27 insertions, 0 deletions
diff --git a/src/resources/db/itemdb.cpp b/src/resources/db/itemdb.cpp
index 3b942797d..cd860df71 100644
--- a/src/resources/db/itemdb.cpp
+++ b/src/resources/db/itemdb.cpp
@@ -55,6 +55,8 @@ namespace
StringVect mTagNames;
StringIntMap mTags;
std::map<std::string, ItemSoundEvent::Type> mSoundNames;
+ int mNumberOfHairstyles = 1;
+ int mNumberOfRaces = 1;
} // namespace
// Forward declarations
@@ -255,6 +257,24 @@ void ItemDB::load()
".xml");
FOR_EACH (StringVectCIter, it, list)
loadXmlFile(*it, tagNum);
+
+ // Hairstyles are encoded as negative numbers. Count how far negative
+ // we can go.
+ int hairstyles = 1;
+ while (ItemDB::get(-hairstyles).getSprite(Gender::MALE,
+ BeingTypeId_zero) != paths.getStringValue("spriteErrorFile"))
+ {
+ hairstyles ++;
+ }
+ mNumberOfHairstyles = hairstyles;
+
+ int races = 100;
+ while (ItemDB::get(-races).getSprite(Gender::MALE, BeingTypeId_zero) !=
+ paths.getStringValue("spriteErrorFile"))
+ {
+ races ++;
+ }
+ mNumberOfRaces = races - 100;
}
void ItemDB::loadXmlFile(const std::string &fileName, int &tagNum)
@@ -1072,6 +1092,11 @@ std::string ItemDB::getNamesStr(const std::vector<int> &parts)
return str;
}
+int ItemDB::getNumOfHairstyles()
+{
+ return mNumberOfHairstyles;
+}
+
#ifdef UNITTESTS
ItemDB::NamedItemInfos &ItemDB::getNamedItemInfosTest()
{
diff --git a/src/resources/db/itemdb.h b/src/resources/db/itemdb.h
index 7cc47b121..e855c80ca 100644
--- a/src/resources/db/itemdb.h
+++ b/src/resources/db/itemdb.h
@@ -54,6 +54,8 @@ namespace ItemDB
const ItemInfo &get(const int id) A_WARN_UNUSED;
const ItemInfo &get(const std::string &name) A_WARN_UNUSED;
+ int getNumOfHairstyles() A_WARN_UNUSED;
+
// Items database
typedef std::map<int, ItemInfo*> ItemInfos;
typedef std::map<std::string, ItemInfo*> NamedItemInfos;