summaryrefslogtreecommitdiff
path: root/src/gui/charcreatedialog.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-11-19 21:49:38 +0300
committerAndrei Karas <akaras@inbox.ru>2011-11-19 21:52:21 +0300
commit10cf52b5ab6a9e1bb8328d9859b11d885fd5eef9 (patch)
tree0bbedbb7883e08901d4a787cac2f2dc6902f1279 /src/gui/charcreatedialog.cpp
parent7929cda3c6a65f8707b753e7190a4ca89891fd7e (diff)
downloadmv-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/charcreatedialog.cpp')
-rw-r--r--src/gui/charcreatedialog.cpp19
1 files changed, 16 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));