summaryrefslogtreecommitdiff
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
parent34bc5498ea3098ca83d454b1745255f060ab2797 (diff)
downloadmv-3fae3f59aad1f1f2eee1e1bfa088672787bc9c78.tar.gz
mv-3fae3f59aad1f1f2eee1e1bfa088672787bc9c78.tar.bz2
mv-3fae3f59aad1f1f2eee1e1bfa088672787bc9c78.tar.xz
mv-3fae3f59aad1f1f2eee1e1bfa088672787bc9c78.zip
Move getNumOfHairstyles from being to itemdb.
-rw-r--r--src/being/being.cpp24
-rw-r--r--src/being/being.h11
-rw-r--r--src/gui/windows/charcreatedialog.cpp6
-rw-r--r--src/resources/db/itemdb.cpp25
-rw-r--r--src/resources/db/itemdb.h2
5 files changed, 30 insertions, 38 deletions
diff --git a/src/being/being.cpp b/src/being/being.cpp
index a0add020e..49fb6a480 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -103,9 +103,6 @@
const unsigned int CACHE_SIZE = 50;
-int Being::mNumberOfHairstyles = 1;
-int Being::mNumberOfRaces = 1;
-
int Being::mUpdateConfigTime = 0;
unsigned int Being::mConfLineLim = 0;
int Being::mSpeechType = 0;
@@ -2625,27 +2622,6 @@ void Being::dumpSprites() const restrict2
}
}
-void Being::load()
-{
- // 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 Being::updateName() restrict2
{
if (mShowName)
diff --git a/src/being/being.h b/src/being/being.h
index afcc61839..1fd7aa0ba 100644
--- a/src/being/being.h
+++ b/src/being/being.h
@@ -327,12 +327,6 @@ class Being notfinal : public ActorSprite,
const std::string &restrict color = "") restrict2;
/**
- * Get the number of hairstyles implemented
- */
- static int getNumOfHairstyles() noexcept A_WARN_UNUSED
- { return mNumberOfHairstyles; }
-
- /**
* Get the number of layers used to draw the being
*/
int getNumberOfLayers() const restrict2 override A_WARN_UNUSED
@@ -548,8 +542,6 @@ class Being notfinal : public ActorSprite,
const int width,
const int height) const restrict2 A_NONNULL(2);
- static void load();
-
void optionChanged(const std::string &restrict value)
restrict2 override;
@@ -1029,9 +1021,6 @@ class Being notfinal : public ActorSprite,
/** Engine-related infos about weapon. */
const ItemInfo *restrict mEquippedWeapon;
- static int mNumberOfHairstyles; /** Number of hair styles in use */
- static int mNumberOfRaces; /** Number of races in use */
-
Path mPath;
Text *restrict mText;
const Color *restrict mTextColor;
diff --git a/src/gui/windows/charcreatedialog.cpp b/src/gui/windows/charcreatedialog.cpp
index b172f788c..91e1c16cc 100644
--- a/src/gui/windows/charcreatedialog.cpp
+++ b/src/gui/windows/charcreatedialog.cpp
@@ -160,7 +160,7 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent,
if (!maxHairColor)
maxHairColor = ColorDB::getHairSize();
if (!maxHairStyle)
- maxHairStyle = mPlayer->getNumOfHairstyles();
+ maxHairStyle = ItemDB::getNumOfHairstyles();
if (maxHairStyle)
{
@@ -723,9 +723,9 @@ void CharCreateDialog::setDefaultGender(const GenderT gender)
void CharCreateDialog::updateHair()
{
if (mHairStyle <= 0)
- mHairStyle = Being::getNumOfHairstyles() - 1;
+ mHairStyle = ItemDB::getNumOfHairstyles() - 1;
else
- mHairStyle %= Being::getNumOfHairstyles();
+ mHairStyle %= ItemDB::getNumOfHairstyles();
if (mHairStyle < CAST_S32(minHairStyle)
|| mHairStyle > CAST_S32(maxHairStyle))
{
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;