diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-05-29 23:49:29 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-05-29 23:49:29 +0300 |
commit | 45379d14d9d3c7f4673b8390cb95d98bb1759f45 (patch) | |
tree | 698fe787014ca277f5b23144136d4e5417c6b444 /src | |
parent | 273b79cf4f52c846508f3493727e34b1811ecfd5 (diff) | |
download | mv-45379d14d9d3c7f4673b8390cb95d98bb1759f45.tar.gz mv-45379d14d9d3c7f4673b8390cb95d98bb1759f45.tar.bz2 mv-45379d14d9d3c7f4673b8390cb95d98bb1759f45.tar.xz mv-45379d14d9d3c7f4673b8390cb95d98bb1759f45.zip |
Convert Gender enum into strong typed enum.
Diffstat (limited to 'src')
-rw-r--r-- | src/avatar.h | 6 | ||||
-rw-r--r-- | src/being/being.cpp | 6 | ||||
-rw-r--r-- | src/being/being.h | 10 | ||||
-rw-r--r-- | src/enums/being/gender.h | 18 | ||||
-rw-r--r-- | src/gui/onlineplayer.h | 10 | ||||
-rw-r--r-- | src/gui/windows/charcreatedialog.cpp | 2 | ||||
-rw-r--r-- | src/gui/windows/charcreatedialog.h | 6 | ||||
-rw-r--r-- | src/inventory.cpp | 2 | ||||
-rw-r--r-- | src/inventory.h | 2 | ||||
-rw-r--r-- | src/net/charserverhandler.h | 2 | ||||
-rw-r--r-- | src/net/ea/playerhandler.cpp | 2 | ||||
-rw-r--r-- | src/net/ea/token.h | 2 | ||||
-rw-r--r-- | src/net/eathena/charserverhandler.cpp | 2 | ||||
-rw-r--r-- | src/net/eathena/charserverhandler.h | 2 | ||||
-rw-r--r-- | src/net/eathena/guildhandler.cpp | 2 | ||||
-rw-r--r-- | src/net/logindata.h | 2 | ||||
-rw-r--r-- | src/net/tmwa/charserverhandler.cpp | 2 | ||||
-rw-r--r-- | src/net/tmwa/charserverhandler.h | 2 | ||||
-rw-r--r-- | src/resources/iteminfo.cpp | 4 | ||||
-rw-r--r-- | src/resources/iteminfo.h | 4 |
20 files changed, 46 insertions, 42 deletions
diff --git a/src/avatar.h b/src/avatar.h index f079e367f..75de6739d 100644 --- a/src/avatar.h +++ b/src/avatar.h @@ -158,10 +158,10 @@ class Avatar notfinal void setCharId(const int id) { mCharId = id; } - Gender::Type getGender() const A_WARN_UNUSED + GenderT getGender() const A_WARN_UNUSED { return mGender; } - void setGender(const Gender::Type g) + void setGender(const GenderT g) { mGender = g; } int getRace() const A_WARN_UNUSED @@ -196,7 +196,7 @@ class Avatar notfinal int mY; int mType; int mExp; - Gender::Type mGender; + GenderT mGender; int mRace; std::string mIp; bool mOnline; diff --git a/src/being/being.cpp b/src/being/being.cpp index 7c250aac3..f433ec964 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -2452,7 +2452,7 @@ BeingCacheEntry* Being::getCacheEntry(const BeingId id) } -void Being::setGender(const Gender::Type gender) +void Being::setGender(const GenderT gender) { if (gender != mGender) { @@ -3239,7 +3239,7 @@ void Being::updatePercentHP() BLOCK_END("Being::updatePercentHP") } -uint8_t Being::genderToInt(const Gender::Type sex) +uint8_t Being::genderToInt(const GenderT sex) { switch (sex) { @@ -3254,7 +3254,7 @@ uint8_t Being::genderToInt(const Gender::Type sex) } } -Gender::Type Being::intToGender(const uint8_t sex) +GenderT Being::intToGender(const uint8_t sex) { switch (sex) { diff --git a/src/being/being.h b/src/being/being.h index d21ad8acc..63b531ff3 100644 --- a/src/being/being.h +++ b/src/being/being.h @@ -580,9 +580,9 @@ class Being notfinal : public ActorSprite, /** * Sets the gender of this being. */ - virtual void setGender(const Gender::Type gender); + virtual void setGender(const GenderT gender); - Gender::Type getGender() const A_WARN_UNUSED + GenderT getGender() const A_WARN_UNUSED { return mGender; } /** @@ -848,9 +848,9 @@ class Being notfinal : public ActorSprite, void setLook(const uint16_t look); - static uint8_t genderToInt(const Gender::Type sex) A_WARN_UNUSED; + static uint8_t genderToInt(const GenderT sex) A_WARN_UNUSED; - static Gender::Type intToGender(const uint8_t sex) A_WARN_UNUSED; + static GenderT intToGender(const uint8_t sex) A_WARN_UNUSED; NextSoundInfo mNextSound; @@ -995,7 +995,7 @@ class Being notfinal : public ActorSprite, int mPreStandTime; - Gender::Type mGender; + GenderT mGender; BeingActionT mAction; BeingTypeId mSubType; /**< Subtype (graphical view, basically) */ uint8_t mDirection; /**< Facing direction */ diff --git a/src/enums/being/gender.h b/src/enums/being/gender.h index 59fd7e304..318ef72e5 100644 --- a/src/enums/being/gender.h +++ b/src/enums/being/gender.h @@ -23,15 +23,15 @@ #ifndef ENUMS_BEING_GENDER_H #define ENUMS_BEING_GENDER_H -namespace Gender +#include "enums/simpletypes/enumdefines.h" + +enumStart(Gender) { - enum Type - { - MALE = 0, - FEMALE = 1, - UNSPECIFIED = 2, - OTHER = 3 - }; -} // nemespace Gender + MALE = 0, + FEMALE = 1, + UNSPECIFIED = 2, + OTHER = 3 +} +enumEnd(Gender); #endif // ENUMS_BEING_GENDER_H diff --git a/src/gui/onlineplayer.h b/src/gui/onlineplayer.h index d0b566ffe..dbcf45be4 100644 --- a/src/gui/onlineplayer.h +++ b/src/gui/onlineplayer.h @@ -22,6 +22,8 @@ #ifndef GUI_ONLINEPLAYER_H #define GUI_ONLINEPLAYER_H +#include "enums/being/gender.h" + #include <string> #include "localconsts.h" @@ -29,8 +31,10 @@ class OnlinePlayer final { public: - OnlinePlayer(const std::string &nick, const unsigned char status, - const signed char level, const unsigned char gender, + OnlinePlayer(const std::string &nick, + const unsigned char status, + const signed char level, + const Gender gender, const signed char version) : mNick(nick), mText(""), @@ -78,7 +82,7 @@ class OnlinePlayer final signed char mVersion; - unsigned char mGender; + Gender mGender; bool mIsGM; }; diff --git a/src/gui/windows/charcreatedialog.cpp b/src/gui/windows/charcreatedialog.cpp index 8ccd127c6..49b1e1c59 100644 --- a/src/gui/windows/charcreatedialog.cpp +++ b/src/gui/windows/charcreatedialog.cpp @@ -586,7 +586,7 @@ void CharCreateDialog::setAttributes(const StringVect &labels, setButtonsPosition(w, h); } -void CharCreateDialog::setDefaultGender(const Gender::Type gender) +void CharCreateDialog::setDefaultGender(const GenderT gender) { mDefaultGender = gender; mPlayer->setGender(gender); diff --git a/src/gui/windows/charcreatedialog.h b/src/gui/windows/charcreatedialog.h index ed1a8fcf3..7ac1980c7 100644 --- a/src/gui/windows/charcreatedialog.h +++ b/src/gui/windows/charcreatedialog.h @@ -72,7 +72,7 @@ class CharCreateDialog final : public Window, const int available, const int min, const int max); - void setDefaultGender(const Gender::Type gender = Gender::FEMALE); + void setDefaultGender(const GenderT gender = Gender::FEMALE); void logic() override final; @@ -155,8 +155,8 @@ class CharCreateDialog final : public Window, int mSlot; - Gender::Type mDefaultGender; - Gender::Type mGender; + GenderT mDefaultGender; + GenderT mGender; unsigned int maxHairColor; unsigned int minHairColor; diff --git a/src/inventory.cpp b/src/inventory.cpp index dd0e516ad..8b396e1d5 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -254,7 +254,7 @@ void Inventory::distributeSlotsChangedEvent() } const Item *Inventory::findItemBySprite(std::string spritePath, - const Gender::Type gender, + const GenderT gender, const BeingTypeId race) const { spritePath = removeSpriteIndex(spritePath); diff --git a/src/inventory.h b/src/inventory.h index f7b647780..588842d70 100644 --- a/src/inventory.h +++ b/src/inventory.h @@ -163,7 +163,7 @@ class Inventory final { return mType == InventoryType::INVENTORY; } const Item *findItemBySprite(std::string spritePath, - const Gender::Type gender, + const GenderT gender, const BeingTypeId race) const A_WARN_UNUSED; diff --git a/src/net/charserverhandler.h b/src/net/charserverhandler.h index 925346594..29f1a6f30 100644 --- a/src/net/charserverhandler.h +++ b/src/net/charserverhandler.h @@ -55,7 +55,7 @@ class CharServerHandler notfinal virtual void newCharacter(const std::string &name, const int slot, - const Gender::Type gender, + const GenderT gender, const int hairstyle, const int hairColor, const unsigned char race, diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp index 8d4937236..092dc8ca1 100644 --- a/src/net/ea/playerhandler.cpp +++ b/src/net/ea/playerhandler.cpp @@ -513,7 +513,7 @@ void PlayerHandler::processOnlineList(Net::MessageIn &msg) unsigned char ver = *buf; buf ++; - unsigned char gender = Gender::UNSPECIFIED; + GenderT gender = Gender::UNSPECIFIED; if (config.getBoolValue("showgender")) { if (status & BeingFlag::GENDER_MALE) diff --git a/src/net/ea/token.h b/src/net/ea/token.h index a62136aee..0d806656c 100644 --- a/src/net/ea/token.h +++ b/src/net/ea/token.h @@ -31,7 +31,7 @@ struct Token final BeingId account_ID; int session_ID1; int session_ID2; - Gender::Type sex; + GenderT sex; void clear() { diff --git a/src/net/eathena/charserverhandler.cpp b/src/net/eathena/charserverhandler.cpp index 94530f407..835360c64 100644 --- a/src/net/eathena/charserverhandler.cpp +++ b/src/net/eathena/charserverhandler.cpp @@ -301,7 +301,7 @@ void CharServerHandler::chooseCharacter(Net::Character *const character) } void CharServerHandler::newCharacter(const std::string &name, const int slot, - const Gender::Type gender, + const GenderT gender, const int hairstyle, const int hairColor, const unsigned char race, const uint16_t look, diff --git a/src/net/eathena/charserverhandler.h b/src/net/eathena/charserverhandler.h index 64968cee4..60f753967 100644 --- a/src/net/eathena/charserverhandler.h +++ b/src/net/eathena/charserverhandler.h @@ -47,7 +47,7 @@ class CharServerHandler final : public MessageHandler, void newCharacter(const std::string &name, const int slot, - const Gender::Type gender, + const GenderT gender, const int hairstyle, const int hairColor, const unsigned char race, diff --git a/src/net/eathena/guildhandler.cpp b/src/net/eathena/guildhandler.cpp index 85609581b..bffe95b94 100644 --- a/src/net/eathena/guildhandler.cpp +++ b/src/net/eathena/guildhandler.cpp @@ -399,7 +399,7 @@ void GuildHandler::processGuildMemberLogin(Net::MessageIn &msg) const BeingId accountId = msg.readBeingId("account id"); const int charId = msg.readInt32("char id"); const int online = msg.readInt32("flag"); - const Gender::Type gender = Being::intToGender(static_cast<uint8_t>( + const GenderT gender = Being::intToGender(static_cast<uint8_t>( msg.readInt16("sex"))); msg.readInt16("hair"); msg.readInt16("hair color"); diff --git a/src/net/logindata.h b/src/net/logindata.h index ddd3685be..acca562fd 100644 --- a/src/net/logindata.h +++ b/src/net/logindata.h @@ -66,7 +66,7 @@ class LoginData final std::string captchaResponse; std::string registerUrl; - Gender::Type gender; + GenderT gender; bool remember; // Whether to store the username. bool registerLogin; // Whether an account is being registered. diff --git a/src/net/tmwa/charserverhandler.cpp b/src/net/tmwa/charserverhandler.cpp index 6662009b3..32a09817a 100644 --- a/src/net/tmwa/charserverhandler.cpp +++ b/src/net/tmwa/charserverhandler.cpp @@ -256,7 +256,7 @@ void CharServerHandler::chooseCharacter(Net::Character *const character) } void CharServerHandler::newCharacter(const std::string &name, const int slot, - const Gender::Type gender A_UNUSED, + const GenderT gender A_UNUSED, const int hairstyle, const int hairColor, const unsigned char race, diff --git a/src/net/tmwa/charserverhandler.h b/src/net/tmwa/charserverhandler.h index 2d73d5a22..a9f99218e 100644 --- a/src/net/tmwa/charserverhandler.h +++ b/src/net/tmwa/charserverhandler.h @@ -47,7 +47,7 @@ class CharServerHandler final : public MessageHandler, void newCharacter(const std::string &name, const int slot, - const Gender::Type gender, + const GenderT gender, const int hairstyle, const int hairColor, const unsigned char race, diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp index 0cdbed04d..768825f44 100644 --- a/src/resources/iteminfo.cpp +++ b/src/resources/iteminfo.cpp @@ -86,7 +86,7 @@ ItemInfo::~ItemInfo() mSpriteToItemReplaceMap[f] = nullptr; } -const std::string &ItemInfo::getSprite(const Gender::Type gender, +const std::string &ItemInfo::getSprite(const GenderT gender, const BeingTypeId race) const { if (mView) @@ -363,7 +363,7 @@ int ItemInfo::getDrawPriority(const int direction) const } void ItemInfo::setSprite(const std::string &animationFile, - const Gender::Type gender, + const GenderT gender, const int race) { mAnimationFiles[static_cast<int>(gender) + race * 4] = animationFile; diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h index 3331d7882..4c8d90f8c 100644 --- a/src/resources/iteminfo.h +++ b/src/resources/iteminfo.h @@ -124,9 +124,9 @@ class ItemInfo final { mView = view; } void setSprite(const std::string &animationFile, - const Gender::Type gender, const int race); + const GenderT gender, const int race); - const std::string &getSprite(const Gender::Type gender, + const std::string &getSprite(const GenderT gender, const BeingTypeId race) const A_WARN_UNUSED; |