summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/charcreatedialog.cpp19
-rw-r--r--src/gui/charcreatedialog.h5
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