summaryrefslogtreecommitdiff
path: root/src/resources/db
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-03-05 17:29:03 +0300
committerAndrei Karas <akaras@inbox.ru>2016-03-05 17:29:03 +0300
commit3fae3f59aad1f1f2eee1e1bfa088672787bc9c78 (patch)
tree570faffa2f7e786bc00feb2519031d6c46fedd0e /src/resources/db
parent34bc5498ea3098ca83d454b1745255f060ab2797 (diff)
downloadmanaplus-3fae3f59aad1f1f2eee1e1bfa088672787bc9c78.tar.gz
manaplus-3fae3f59aad1f1f2eee1e1bfa088672787bc9c78.tar.bz2
manaplus-3fae3f59aad1f1f2eee1e1bfa088672787bc9c78.tar.xz
manaplus-3fae3f59aad1f1f2eee1e1bfa088672787bc9c78.zip
Move getNumOfHairstyles from being to itemdb.
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;