From 7c2a0d292b3c39a7947563c1fc1df50423bf2a8f Mon Sep 17 00:00:00 2001 From: Yohann Ferreira Date: Wed, 28 Sep 2011 22:54:47 +0200 Subject: Officially added the being gender to the protocol. --- src/common/manaserv_protocol.h | 12 ++++++++++++ src/game-server/character.cpp | 15 ++++++++++++++- src/game-server/character.h | 7 +++---- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/common/manaserv_protocol.h b/src/common/manaserv_protocol.h index 532eff6f..5bcfeb66 100644 --- a/src/common/manaserv_protocol.h +++ b/src/common/manaserv_protocol.h @@ -431,6 +431,18 @@ enum BeingDirection RIGHT = 8 }; +/** + * Beings Genders + * WARNING: Has to be in sync with the same enum in the Being class + * of the client! + */ +enum BeingGender +{ + GENDER_MALE = 0, + GENDER_FEMALE, + GENDER_UNSPECIFIED +}; + } // namespace ManaServ #endif // MANASERV_PROTOCOL_H diff --git a/src/game-server/character.cpp b/src/game-server/character.cpp index ef001638..0cac8cfa 100644 --- a/src/game-server/character.cpp +++ b/src/game-server/character.cpp @@ -58,7 +58,7 @@ Character::Character(MessageIn &msg): mRechargePerSpecial(0), mSpecialUpdateNeeded(false), mDatabaseID(-1), - mGender(0), + mGender(GENDER_UNSPECIFIED), mHairStyle(0), mHairColor(0), mLevel(1), @@ -295,6 +295,19 @@ void Character::cancelTransaction() } } +void Character::setGender(int gender) +{ + switch (gender) + { + case GENDER_MALE: + case GENDER_FEMALE: + mGender = (BeingGender)gender; + break; + default: + mGender = GENDER_UNSPECIFIED; + } +} + Trade *Character::getTrading() const { return mTransaction == TRANS_TRADE diff --git a/src/game-server/character.h b/src/game-server/character.h index 83445916..30e39633 100644 --- a/src/game-server/character.h +++ b/src/game-server/character.h @@ -174,12 +174,11 @@ class Character : public Being void setDatabaseID(int id) { mDatabaseID = id; } /** Gets the gender of the character (male or female). */ - int getGender() const + BeingGender getGender() const { return mGender; } /** Sets the gender of the character (male or female). */ - void setGender(int gender) - { mGender = gender; } + void setGender(int gender); int getHairStyle() const { return mHairStyle; } void setHairStyle(int style) { mHairStyle = style; } @@ -443,7 +442,7 @@ class Character : public Being bool mSpecialUpdateNeeded; int mDatabaseID; /**< Character's database ID. */ - unsigned char mGender; /**< Gender of the character. */ + BeingGender mGender; /**< Gender of the character. */ unsigned char mHairStyle; /**< Hair Style of the character. */ unsigned char mHairColor; /**< Hair Color of the character. */ int mLevel; /**< Level of the character. */ -- cgit v1.2.3-70-g09d2