From 0f6b7350ad0305d518fb75a8aa07f0616178ede5 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 25 Dec 2012 14:46:53 +0300 Subject: fix previous/next race button in char creation dialog. --- src/being.cpp | 11 +++++++++-- src/being.h | 7 +++++++ src/client.cpp | 2 +- src/gui/charcreatedialog.cpp | 13 +++---------- 4 files changed, 20 insertions(+), 13 deletions(-) (limited to 'src') 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 @@ -397,6 +397,12 @@ class Being : public ActorSprite, public ConfigListener static int getNumOfHairstyles() A_WARN_UNUSED { 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 */ @@ -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(mRace)); const ItemInfo &item = ItemDB::get(id); -- cgit v1.2.3-60-g2f50