summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2008-12-13 15:51:25 +0100
committerBjørn Lindeijer <bjorn@lindeijer.nl>2008-12-13 15:51:25 +0100
commit16106cae769f485908c15ac39d0e017167099a48 (patch)
tree7afaf56eddb2138b528fa46f8f51cc66f7c128bb
parent1eba9b1bbd2e2c5a75a71c5592069c73e106015f (diff)
downloadmana-client-16106cae769f485908c15ac39d0e017167099a48.tar.gz
mana-client-16106cae769f485908c15ac39d0e017167099a48.tar.bz2
mana-client-16106cae769f485908c15ac39d0e017167099a48.tar.xz
mana-client-16106cae769f485908c15ac39d0e017167099a48.zip
Moved gender and hair style back to Being
These properties should also apply to NPCs and possibly even monsters in the future.
-rw-r--r--src/being.cpp9
-rw-r--r--src/being.h36
-rw-r--r--src/player.cpp10
-rw-r--r--src/player.h26
4 files changed, 48 insertions, 33 deletions
diff --git a/src/being.cpp b/src/being.cpp
index a267d033..bade64b6 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -57,6 +57,9 @@ Being::Being(int id, int job, Map *map):
mSpriteDirection(DIRECTION_DOWN), mDirection(DOWN),
mMap(NULL),
mEquippedWeapon(NULL),
+ mHairStyle(0),
+ mHairColor(0),
+ mGender(GENDER_UNSPECIFIED),
mSpeechTime(0),
mSprites(VECTOREND_SPRITE, NULL),
mSpriteIDs(VECTOREND_SPRITE, 0),
@@ -286,6 +289,12 @@ void Being::setPath(const Path &path)
mPath = path;
}
+void Being::setHairStyle(int style, int color)
+{
+ mHairStyle = style < 0 ? mHairStyle : style % NR_HAIR_STYLES;
+ mHairColor = color < 0 ? mHairColor : color % NR_HAIR_COLORS;
+}
+
void Being::setSprite(int slot, int id, const std::string &color)
{
assert(slot >= BASE_SPRITE && slot < VECTOREND_SPRITE);
diff --git a/src/being.h b/src/being.h
index bf11e3ed..cce5e99f 100644
--- a/src/being.h
+++ b/src/being.h
@@ -46,6 +46,12 @@ class ImageSet;
class Particle;
class SpeechBubble;
+enum Gender {
+ GENDER_MALE = 0,
+ GENDER_FEMALE = 1,
+ GENDER_UNSPECIFIED = 2
+};
+
class Being : public Sprite
{
public:
@@ -174,6 +180,33 @@ class Being : public Sprite
setName(const std::string &name) { mName = name; }
/**
+ * Sets the gender for this being.
+ */
+ virtual void setGender(Gender gender) { mGender = gender; }
+
+ /**
+ * Gets the hair color for this being.
+ */
+ int getHairColor() const
+ { return mHairColor; }
+
+ /**
+ * Gets the hair style for this being.
+ */
+ int getHairStyle() const
+ { return mHairStyle; }
+
+ /**
+ * Sets the hair style and color for this being.
+ *
+ * NOTE: This method was necessary for convenience in the 0.0 client.
+ * It should be removed here since the server can provide the hair ID
+ * and coloring the same way it does for other equipment pieces. Then
+ * Being::setSprite can be used instead.
+ */
+ virtual void setHairStyle(int style, int color);
+
+ /**
* Sets visible equipments for this being.
*/
virtual void
@@ -353,6 +386,9 @@ class Being : public Sprite
Path mPath;
std::string mSpeech;
+ int mHairStyle;
+ int mHairColor;
+ Gender mGender;
Uint32 mSpeechTime;
std::vector<AnimatedSprite*> mSprites;
diff --git a/src/player.cpp b/src/player.cpp
index 648b330a..e24a2d8c 100644
--- a/src/player.cpp
+++ b/src/player.cpp
@@ -35,10 +35,7 @@
#include "gui/gui.h"
Player::Player(int id, int job, Map *map):
- Being(id, job, map),
- mGender(GENDER_UNSPECIFIED),
- mHairStyle(0),
- mHairColor(0)
+ Being(id, job, map)
{
}
@@ -67,7 +64,7 @@ void Player::setGender(Gender gender)
{
if (gender != mGender)
{
- mGender = gender;
+ Being::setGender(gender);
/* Human base sprite. When implementing different races remove this
* line and set the base sprite when setting the race of the player
@@ -92,8 +89,7 @@ void Player::setHairStyle(int style, int color)
color = color < 0 ? mHairColor : color % NR_HAIR_COLORS;
if (style == mHairStyle && color == mHairColor) return;
- mHairStyle = style;
- mHairColor = color;
+ Being::setHairStyle(style, color);
static char const *const colors[NR_HAIR_COLORS] =
{
diff --git a/src/player.h b/src/player.h
index 068e3cf5..12f9d268 100644
--- a/src/player.h
+++ b/src/player.h
@@ -28,12 +28,6 @@ class Graphics;
class Map;
class Guild;
-enum Gender {
- GENDER_MALE = 0,
- GENDER_FEMALE = 1,
- GENDER_UNSPECIFIED = 2
-};
-
/**
* A player being. Players have their name drawn beneath them. This class also
* implements player-specific loading of base sprite, hair sprite and equipment
@@ -61,24 +55,7 @@ class Player : public Being
void setGender(Gender);
/**
- * Gets the hair color for this player.
- */
- int getHairColor() const
- { return mHairColor; }
-
- /**
- * Gets the hair style for this player.
- */
- int getHairStyle() const
- { return mHairStyle; }
-
- /**
* Sets the hair style and color for this player.
- *
- * NOTE: This method was necessary for convenience in the 0.0 client.
- * It should be removed here since the server can provide the hair ID
- * and coloring the same way it does for other equipment pieces. Then
- * Being::setSprite can be used instead.
*/
void setHairStyle(int style, int color);
@@ -140,9 +117,6 @@ class Player : public Being
std::map<int, Guild*> mGuilds;
private:
- Gender mGender;
- Uint8 mHairStyle;
- Uint8 mHairColor;
bool mInParty;
};