diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-11-19 21:49:38 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-11-19 21:52:21 +0300 |
commit | 10cf52b5ab6a9e1bb8328d9859b11d885fd5eef9 (patch) | |
tree | 0bbedbb7883e08901d4a787cac2f2dc6902f1279 /src/gui | |
parent | 7929cda3c6a65f8707b753e7190a4ca89891fd7e (diff) | |
download | mv-10cf52b5ab6a9e1bb8328d9859b11d885fd5eef9.tar.gz mv-10cf52b5ab6a9e1bb8328d9859b11d885fd5eef9.tar.bz2 mv-10cf52b5ab6a9e1bb8328d9859b11d885fd5eef9.tar.xz mv-10cf52b5ab6a9e1bb8328d9859b11d885fd5eef9.zip |
Add limits for creating chars (hair color, hair style, stats).
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/charcreatedialog.cpp | 19 | ||||
-rw-r--r-- | src/gui/charcreatedialog.h | 5 |
2 files changed, 21 insertions, 3 deletions
diff --git a/src/gui/charcreatedialog.cpp b/src/gui/charcreatedialog.cpp index 42435f036..c20cfab95 100644 --- a/src/gui/charcreatedialog.cpp +++ b/src/gui/charcreatedialog.cpp @@ -44,6 +44,7 @@ #include "net/messageout.h" #include "net/net.h" +#include "resources/chardb.h" #include "resources/colordb.h" #include "resources/itemdb.h" @@ -66,10 +67,18 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot): mPlayer = new Being(0, ActorSprite::PLAYER, mRace, nullptr); mPlayer->setGender(GENDER_MALE); - int numberOfHairColors = ColorDB::getHairSize(); + maxHairColor = CharDB::getMaxHairColor(); + minHairColor = CharDB::getMinHairColor(); + if (!maxHairColor) + maxHairColor = ColorDB::getHairSize(); - mHairStyle = rand() % mPlayer->getNumOfHairstyles(); - mHairColor = rand() % numberOfHairColors; + maxHairStyle = CharDB::getMaxHairStyle(); + minHairStyle = CharDB::getMinHairStyle(); + if (!maxHairStyle) + maxHairStyle = mPlayer->getNumOfHairstyles(); + + mHairStyle = (rand() % maxHairStyle) + minHairStyle; + mHairColor = (rand() % maxHairColor) + minHairColor; updateHair(); mNameField = new TextField(""); @@ -408,10 +417,14 @@ void CharCreateDialog::updateHair() mHairStyle %= Being::getNumOfHairstyles(); if (mHairStyle < 0) mHairStyle += Being::getNumOfHairstyles(); + if (mHairStyle < minHairStyle || mHairStyle > maxHairStyle) + mHairStyle = minHairStyle; mHairColor %= ColorDB::getHairSize(); if (mHairColor < 0) mHairColor += ColorDB::getHairSize(); + if (mHairColor < minHairColor || mHairColor > maxHairColor) + mHairColor = minHairColor; mPlayer->setSprite(Net::getCharHandler()->hairSprite(), mHairStyle * -1, ColorDB::getHairColor(mHairColor)); diff --git a/src/gui/charcreatedialog.h b/src/gui/charcreatedialog.h index 2f0f83513..c7010d6b1 100644 --- a/src/gui/charcreatedialog.h +++ b/src/gui/charcreatedialog.h @@ -124,6 +124,11 @@ class CharCreateDialog : public Window, public gcn::ActionListener int mRace; int mSlot; + + unsigned maxHairColor; + unsigned minHairColor; + unsigned maxHairStyle; + unsigned minHairStyle; }; #endif // CHAR_CREATE_DIALOG_H |