From 4b0da49b28bb64d2da293ca90fec63079c2c5849 Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Sat, 27 Apr 2013 21:43:32 +0200 Subject: Added support for charcreation.xml settings This file was introduced by ManaPlus as a way of configuring the character creation process. It defines the number of hair styles and colors, how stat points should be divided and what the starting equipment of the player is. The minimum and maximum hair color/style IDs are not supported at the moment. This is mostly a backport of ManaPlus commits 10cf52b5 and dcc18eba, with some style changes. Mantis-issue: 501 Reviewed-by: Ablu --- src/net/tmwa/charserverhandler.cpp | 28 ++++++++++++++++++++++++---- src/net/tmwa/charserverhandler.h | 11 ++--------- 2 files changed, 26 insertions(+), 13 deletions(-) (limited to 'src/net') diff --git a/src/net/tmwa/charserverhandler.cpp b/src/net/tmwa/charserverhandler.cpp index cc242951..7c5f5c88 100644 --- a/src/net/tmwa/charserverhandler.cpp +++ b/src/net/tmwa/charserverhandler.cpp @@ -39,6 +39,7 @@ #include "net/tmwa/protocol.h" #include "resources/attributes.h" +#include "resources/chardb.h" #include "resources/hairdb.h" #include "utils/dtor.h" @@ -279,10 +280,17 @@ void CharServerHandler::setCharCreateDialog(CharCreateDialog *window) const Token &token = static_cast(Net::getLoginHandler())->getToken(); - mCharCreateDialog->setAttributes(attributes, - Attributes::getCreationPoints(), - Attributes::getAttributeMinimum(), - Attributes::getAttributeMaximum()); + unsigned minStat = CharDB::getMinStat(); + if (minStat == 0) + minStat = Attributes::getAttributeMinimum(); + unsigned maxStat = CharDB::getMaxStat(); + if (maxStat == 0) + maxStat = Attributes::getAttributeMaximum(); + unsigned sumStat = CharDB::getSumStat(); + if (sumStat == 0) + sumStat = Attributes::getCreationPoints(); + + mCharCreateDialog->setAttributes(attributes, sumStat, minStat, maxStat); mCharCreateDialog->setFixedGender(true, token.sex); } @@ -346,6 +354,18 @@ unsigned int CharServerHandler::maxSprite() const return SPRITE_VECTOREND; } +int CharServerHandler::getCharCreateMaxHairColorId() const +{ + const int max = CharDB::getMaxHairColor(); + return max ? max : 11; // default maximum +} + +int CharServerHandler::getCharCreateMaxHairStyleId() const +{ + const int max = CharDB::getMaxHairStyle(); + return max ? max : 19; // default maximum +} + void CharServerHandler::connect() { const Token &token = diff --git a/src/net/tmwa/charserverhandler.h b/src/net/tmwa/charserverhandler.h index c9f44e0f..7e4fc2d9 100644 --- a/src/net/tmwa/charserverhandler.h +++ b/src/net/tmwa/charserverhandler.h @@ -69,15 +69,8 @@ class CharServerHandler : public MessageHandler, public Net::CharHandler unsigned int maxSprite() const; - // Must be < 12 at character creation time, but can be higher - // after that. - int getCharCreateMaxHairColorId() const - { return 11; } - - // Must be < 20 at character creation time, but can be higher - // after that. - int getCharCreateMaxHairStyleId() const - { return 19; } + int getCharCreateMaxHairColorId() const; + int getCharCreateMaxHairStyleId() const; void connect(); -- cgit v1.2.3-70-g09d2