diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | src/net/beinghandler.cpp | 2 | ||||
-rw-r--r-- | src/net/charserverhandler.cpp | 2 | ||||
-rw-r--r-- | src/player.cpp | 11 | ||||
-rw-r--r-- | src/player.h | 7 | ||||
-rw-r--r-- | src/resources/itemdb.cpp | 8 | ||||
-rw-r--r-- | src/resources/iteminfo.cpp | 2 | ||||
-rw-r--r-- | src/resources/iteminfo.h | 6 |
8 files changed, 21 insertions, 21 deletions
@@ -5,6 +5,10 @@ on a patch by rodge) * src/gui/char_select.cpp, src/gui/char_select.h, src/player.h: Merged creation of female characters from Legend of Mazzeroth. + * src/net/beinghandler.cpp, src/net/charserverhandler.cpp, + src/player.cpp, src/player.h, src/resources/itemdb.cpp, + src/resources/iteminfo.cpp, src/resources/iteminfo.h: Handling gender + with an enum everywhere. 2008-02-21 Philipp Sehmisch <tmw@crushnet.org> diff --git a/src/net/beinghandler.cpp b/src/net/beinghandler.cpp index 24db8454..38299b8d 100644 --- a/src/net/beinghandler.cpp +++ b/src/net/beinghandler.cpp @@ -475,7 +475,7 @@ BeingHandler::handleBeingEnterMessage(MessageIn &msg) Player *p = static_cast< Player * >(being); int hs = msg.readInt8(), hc = msg.readInt8(); p->setHairStyle(hs, hc); - p->setGender(msg.readInt8()); + p->setGender(msg.readInt8() == GENDER_MALE ? GENDER_MALE : GENDER_FEMALE); handleLooks(p, msg); } break; diff --git a/src/net/charserverhandler.cpp b/src/net/charserverhandler.cpp index c83b68f1..6cc9e384 100644 --- a/src/net/charserverhandler.cpp +++ b/src/net/charserverhandler.cpp @@ -212,7 +212,7 @@ LocalPlayer* CharServerHandler::readPlayerData(MessageIn &msg, int &slot) LocalPlayer *tempPlayer = new LocalPlayer; slot = msg.readInt8(); // character slot tempPlayer->mName = msg.readString(); - tempPlayer->setGender(msg.readInt8()); + tempPlayer->setGender(msg.readInt8() == GENDER_MALE ? GENDER_MALE : GENDER_FEMALE); int hs = msg.readInt8(), hc = msg.readInt8(); tempPlayer->setHairStyle(hs, hc); tempPlayer->setLevel(msg.readInt16()); diff --git a/src/player.cpp b/src/player.cpp index b1372925..b8789256 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -37,7 +37,7 @@ Player::Player(int id, int job, Map *map): Being(id, job, map), - mGender(2), + mGender(GENDER_UNSPECIFIED), mHairStyle(0), mHairColor(0) { @@ -60,15 +60,8 @@ Player::drawName(Graphics *graphics, int offsetX, int offsetY) graphics->drawText(mName, px + 15, py + 30, gcn::Graphics::CENTER); } -void Player::setGender(int gender) +void Player::setGender(Gender gender) { - // Players can only be male or female - if (gender > 1) - { - logger->log("Warning: unsupported gender %i, assuming male.", gender); - gender = 0; - } - if (gender != mGender) { mGender = gender; diff --git a/src/player.h b/src/player.h index 7e742a7a..f6ecbd59 100644 --- a/src/player.h +++ b/src/player.h @@ -31,7 +31,8 @@ class Map; enum Gender { GENDER_MALE = 0, - GENDER_FEMALE = 1 + GENDER_FEMALE = 1, + GENDER_UNSPECIFIED = 2 }; /** @@ -56,7 +57,7 @@ class Player : public Being /** * Sets the gender for this player. */ - void setGender(int); + void setGender(Gender); /** * Gets the hair color for this player. @@ -87,7 +88,7 @@ class Player : public Being setSprite(int slot, int id, const std::string &color = ""); private: - Uint8 mGender; + Gender mGender; Uint8 mHairStyle; Uint8 mHairColor; }; diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp index 5f6846ba..d507987a 100644 --- a/src/resources/itemdb.cpp +++ b/src/resources/itemdb.cpp @@ -100,8 +100,8 @@ void ItemDB::load() mUnknown = new ItemInfo(); mUnknown->setName("Unknown item"); mUnknown->setImageName(""); - mUnknown->setSprite("error.xml", 0); - mUnknown->setSprite("error.xml", 1); + mUnknown->setSprite("error.xml", GENDER_MALE); + mUnknown->setSprite("error.xml", GENDER_FEMALE); ResourceManager *resman = ResourceManager::getInstance(); int size; @@ -241,12 +241,12 @@ void loadSpriteRef(ItemInfo *itemInfo, xmlNodePtr node) if (gender == "male" || gender == "unisex") { - itemInfo->setSprite(filename, 0); + itemInfo->setSprite(filename, GENDER_MALE); } if (gender == "female" || gender == "unisex") { - itemInfo->setSprite(filename, 1); + itemInfo->setSprite(filename, GENDER_FEMALE); } } diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp index ad4c9797..4322db8d 100644 --- a/src/resources/iteminfo.cpp +++ b/src/resources/iteminfo.cpp @@ -26,7 +26,7 @@ #include "itemdb.h" const std::string& -ItemInfo::getSprite(int gender) const +ItemInfo::getSprite(Gender gender) const { if (mView) { diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h index 90675a17..43047094 100644 --- a/src/resources/iteminfo.h +++ b/src/resources/iteminfo.h @@ -30,6 +30,8 @@ #include "spritedef.h" +#include "../player.h" + enum EquipmentSoundEvent { EQUIP_EVENT_STRIKE, @@ -131,10 +133,10 @@ class ItemInfo void setView(int view) { mView = view; } - void setSprite(const std::string &animationFile, int gender) + void setSprite(const std::string &animationFile, Gender gender) { mAnimationFiles[gender] = animationFile; } - const std::string& getSprite(int gender) const; + const std::string& getSprite(Gender gender) const; void setWeaponType(int); |