diff options
-rw-r--r-- | src/gui/charcreatedialog.cpp | 66 | ||||
-rw-r--r-- | src/gui/charcreatedialog.h | 6 | ||||
-rw-r--r-- | src/net/charhandler.h | 1 | ||||
-rw-r--r-- | src/net/manaserv/charhandler.cpp | 2 | ||||
-rw-r--r-- | src/net/manaserv/charhandler.h | 1 | ||||
-rw-r--r-- | src/net/tmwa/charserverhandler.cpp | 4 | ||||
-rw-r--r-- | src/net/tmwa/charserverhandler.h | 1 | ||||
-rw-r--r-- | src/net/tmwa/network.h | 2 |
8 files changed, 74 insertions, 9 deletions
diff --git a/src/gui/charcreatedialog.cpp b/src/gui/charcreatedialog.cpp index ae4401572..973273e95 100644 --- a/src/gui/charcreatedialog.cpp +++ b/src/gui/charcreatedialog.cpp @@ -22,6 +22,7 @@ #include "gui/charcreatedialog.h" +#include "client.h" #include "game.h" #include "localplayer.h" #include "main.h" @@ -44,6 +45,7 @@ #include "net/net.h" #include "resources/colordb.h" +#include "resources/itemdb.h" #include "utils/gettext.h" #include "utils/stringutils.h" @@ -53,9 +55,10 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot): Window(_("Create Character"), true, parent), mCharSelectDialog(parent), + mRace(0), mSlot(slot) { - mPlayer = new Being(0, ActorSprite::PLAYER, 0, NULL); + mPlayer = new Being(0, ActorSprite::PLAYER, mRace, NULL); mPlayer->setGender(GENDER_MALE); int numberOfHairColors = ColorDB::getHairSize(); @@ -76,6 +79,14 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot): mNextHairStyleButton = new Button(_(">"), "nextstyle", this); mPrevHairStyleButton = new Button(_("<"), "prevstyle", this); mHairStyleLabel = new Label(_("Hair style:")); + + if (serverVersion >= 2) + { + mNextRaceButton = new Button(_(">"), "nextrace", this); + mPrevRaceButton = new Button(_("<"), "prevrace", this); + mRaceLabel = new Label(_("Race:")); + } + mCreateButton = new Button(_("Create"), "create", this); mCancelButton = new Button(_("Cancel"), "cancel", this); mMale = new RadioButton(_("Male"), "gender"); @@ -112,6 +123,14 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot): mPrevHairStyleButton->setPosition(90, 64); mNextHairStyleButton->setPosition(165, 64); mHairStyleLabel->setPosition(5, 70); + + if (serverVersion >= 2) + { + mPrevRaceButton->setPosition(90, 93); + mNextRaceButton->setPosition(165, 93); + mRaceLabel->setPosition(5, 100); + } + mAttributesLeft->setPosition(15, 280); updateSliders(); mCancelButton->setPosition( @@ -133,6 +152,14 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot): add(mNextHairStyleButton); add(mPrevHairStyleButton); add(mHairStyleLabel); + + if (serverVersion >= 2) + { + add(mNextRaceButton); + add(mPrevRaceButton); + add(mRaceLabel); + } + add(mAttributesLeft); add(mCreateButton); add(mCancelButton); @@ -177,9 +204,7 @@ void CharCreateDialog::action(const gcn::ActionEvent &event) ++characterSlot; Net::getCharHandler()->newCharacter(getName(), characterSlot, - mFemale->isSelected(), - mHairStyle, - mHairColor, atts); + mFemale->isSelected(), mHairStyle, mHairColor, mRace, atts); } else { @@ -212,6 +237,16 @@ void CharCreateDialog::action(const gcn::ActionEvent &event) mHairStyle--; updateHair(); } + else if (event.getId() == "nextrace") + { + mRace++; + updateRace(); + } + else if (event.getId() == "prevrace") + { + mRace--; + updateRace(); + } else if (event.getId() == "statslider") { updateSliders(); @@ -353,8 +388,8 @@ void CharCreateDialog::setFixedGender(bool fixed, Gender gender) if (fixed) { - mMale->setEnabled(false); - mFemale->setEnabled(false); + mMale->setVisible(false); + mFemale->setVisible(false); } } @@ -371,3 +406,22 @@ void CharCreateDialog::updateHair() mPlayer->setSprite(Net::getCharHandler()->hairSprite(), mHairStyle * -1, ColorDB::getHairColor(mHairColor)); } + +void CharCreateDialog::updateRace() +{ + int id; + if (mRace < 0) + { + mRace = 0; + id = -100; + } + else + { + id = -100 - mRace; + while (id < -100 && !ItemDB::exists(id)) + id ++; + mRace = -100 - id; + } + + mPlayer->setSubtype(mRace); +} diff --git a/src/gui/charcreatedialog.h b/src/gui/charcreatedialog.h index 7a029ac2f..2f0f83513 100644 --- a/src/gui/charcreatedialog.h +++ b/src/gui/charcreatedialog.h @@ -86,6 +86,8 @@ class CharCreateDialog : public Window, public gcn::ActionListener void updateHair(); + void updateRace(); + CharSelectDialog *mCharSelectDialog; gcn::TextField *mNameField; @@ -96,6 +98,9 @@ class CharCreateDialog : public Window, public gcn::ActionListener gcn::Button *mNextHairStyleButton; gcn::Button *mPrevHairStyleButton; gcn::Label *mHairStyleLabel; + gcn::Button *mNextRaceButton; + gcn::Button *mPrevRaceButton; + gcn::Label *mRaceLabel; gcn::RadioButton *mMale; gcn::RadioButton *mFemale; @@ -116,6 +121,7 @@ class CharCreateDialog : public Window, public gcn::ActionListener int mHairStyle; int mHairColor; + int mRace; int mSlot; }; diff --git a/src/net/charhandler.h b/src/net/charhandler.h index cef98dfa1..0cddc62d0 100644 --- a/src/net/charhandler.h +++ b/src/net/charhandler.h @@ -76,6 +76,7 @@ class CharHandler virtual void newCharacter(const std::string &name, int slot, bool gender, int hairstyle, int hairColor, + unsigned char race, const std::vector<int> &stats) = 0; virtual void deleteCharacter(Net::Character *character) = 0; diff --git a/src/net/manaserv/charhandler.cpp b/src/net/manaserv/charhandler.cpp index 163aad988..0988fc9a6 100644 --- a/src/net/manaserv/charhandler.cpp +++ b/src/net/manaserv/charhandler.cpp @@ -310,7 +310,7 @@ void CharHandler::newCharacter(const std::string &name, int slot, bool gender, int hairstyle, - int hairColor, + int hairColor, unsigned char race, const std::vector<int> &stats) { MessageOut msg(PAMSG_CHAR_CREATE); diff --git a/src/net/manaserv/charhandler.h b/src/net/manaserv/charhandler.h index 8de582753..ea44ae23e 100644 --- a/src/net/manaserv/charhandler.h +++ b/src/net/manaserv/charhandler.h @@ -63,6 +63,7 @@ class CharHandler : public MessageHandler, public Net::CharHandler void newCharacter(const std::string &name, int slot, bool gender, int hairstyle, int hairColor, + unsigned char race, const std::vector<int> &stats); void deleteCharacter(Net::Character *character); diff --git a/src/net/tmwa/charserverhandler.cpp b/src/net/tmwa/charserverhandler.cpp index 545c36611..7f091bc67 100644 --- a/src/net/tmwa/charserverhandler.cpp +++ b/src/net/tmwa/charserverhandler.cpp @@ -408,7 +408,7 @@ void CharServerHandler::chooseCharacter(Net::Character *character) void CharServerHandler::newCharacter(const std::string &name, int slot, bool gender _UNUSED_, int hairstyle, - int hairColor, + int hairColor, unsigned char race, const std::vector<int> &stats) { MessageOut outMsg(CMSG_CHAR_CREATE); @@ -419,6 +419,8 @@ void CharServerHandler::newCharacter(const std::string &name, int slot, outMsg.writeInt8(static_cast<unsigned char>(slot)); outMsg.writeInt16(static_cast<short>(hairColor)); outMsg.writeInt16(static_cast<short>(hairstyle)); + if (serverVersion >= 2) + outMsg.writeInt8(race); } void CharServerHandler::deleteCharacter(Net::Character *character) diff --git a/src/net/tmwa/charserverhandler.h b/src/net/tmwa/charserverhandler.h index 9d65639b9..7e843ffec 100644 --- a/src/net/tmwa/charserverhandler.h +++ b/src/net/tmwa/charserverhandler.h @@ -65,6 +65,7 @@ class CharServerHandler : public MessageHandler, public Net::CharHandler void newCharacter(const std::string &name, int slot, bool gender, int hairstyle, int hairColor, + unsigned char race, const std::vector<int> &stats); void deleteCharacter(Net::Character *character); diff --git a/src/net/tmwa/network.h b/src/net/tmwa/network.h index 4a554f9eb..757358c25 100644 --- a/src/net/tmwa/network.h +++ b/src/net/tmwa/network.h @@ -39,7 +39,7 @@ * Protocol version, reported to the eAthena char and mapserver who can adjust * the protocol accordingly. */ -#define CLIENT_PROTOCOL_VERSION 3 +#define CLIENT_PROTOCOL_VERSION 4 #define CLIENT_TMW_PROTOCOL_VERSION 1 namespace TmwAthena |