diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-12-25 14:46:53 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-12-25 14:47:37 +0300 |
commit | 0f6b7350ad0305d518fb75a8aa07f0616178ede5 (patch) | |
tree | 2e12990ad04106660fbe31547480d8976d1215d7 | |
parent | 5da20a82b1a4d1a4bab77fad0aa73244a53073b1 (diff) | |
download | manaverse-0f6b7350ad0305d518fb75a8aa07f0616178ede5.tar.gz manaverse-0f6b7350ad0305d518fb75a8aa07f0616178ede5.tar.bz2 manaverse-0f6b7350ad0305d518fb75a8aa07f0616178ede5.tar.xz manaverse-0f6b7350ad0305d518fb75a8aa07f0616178ede5.zip |
fix previous/next race button in char creation dialog.
-rw-r--r-- | src/being.cpp | 11 | ||||
-rw-r--r-- | src/being.h | 7 | ||||
-rw-r--r-- | src/client.cpp | 2 | ||||
-rw-r--r-- | src/gui/charcreatedialog.cpp | 13 |
4 files changed, 20 insertions, 13 deletions
diff --git a/src/being.cpp b/src/being.cpp index d65686805..1f92030ab 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -171,6 +171,7 @@ class BeingCacheEntry final int Being::mNumberOfHairstyles = 1; +int Being::mNumberOfRaces = 1; int Being::mUpdateConfigTime = 0; unsigned int Being::mConfLineLim = 0; @@ -1867,14 +1868,20 @@ 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, 0) != paths.getStringValue("spriteErrorFile")) { hairstyles ++; } - mNumberOfHairstyles = hairstyles; + + int races = 100; + while (ItemDB::get(-races).getSprite(GENDER_MALE, 0) != + paths.getStringValue("spriteErrorFile")) + { + races ++; + } + mNumberOfRaces = races - 100; } void Being::updateName() diff --git a/src/being.h b/src/being.h index c8abf988f..1f2d88412 100644 --- a/src/being.h +++ b/src/being.h @@ -398,6 +398,12 @@ class Being : public ActorSprite, public ConfigListener { return mNumberOfHairstyles; } /** + * Get the number of races implemented + */ + static int getNumOfRaces() A_WARN_UNUSED + { return mNumberOfRaces; } + + /** * Get the number of layers used to draw the being */ int getNumberOfLayers() const A_WARN_UNUSED @@ -900,6 +906,7 @@ class Being : public ActorSprite, public ConfigListener const ItemInfo *mEquippedWeapon; static int mNumberOfHairstyles; /** Number of hair styles in use */ + static int mNumberOfRaces; /** Number of races in use */ Path mPath; std::string mSpeech; diff --git a/src/client.cpp b/src/client.cpp index 7248aae43..1ae9185e2 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -1350,7 +1350,7 @@ int Client::gameExec() ColorDB::load(); MapDB::load(); ItemDB::load(); - Being::load(); // Hairstyles + Being::load(); MonsterDB::load(); #ifdef MANASERV_SUPPORT SpecialDB::load(); diff --git a/src/gui/charcreatedialog.cpp b/src/gui/charcreatedialog.cpp index 33806753d..8315bed02 100644 --- a/src/gui/charcreatedialog.cpp +++ b/src/gui/charcreatedialog.cpp @@ -538,17 +538,10 @@ void CharCreateDialog::updateRace() { int id; if (mRace < 0) - { + mRace = Being::getNumOfRaces() - 1; + else if (mRace >= Being::getNumOfRaces()) mRace = 0; - id = -100; - } - else - { - id = -100 - mRace; - while (id < -100 && !ItemDB::exists(id)) - id ++; - mRace = -100 - id; - } + id = -100 - mRace; mPlayer->setSubtype(static_cast<uint16_t>(mRace)); const ItemInfo &item = ItemDB::get(id); |