diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2006-08-26 16:01:24 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2006-08-26 16:01:24 +0000 |
commit | ef4486580fc7b8293555fcabc398ed0c2b90d78e (patch) | |
tree | 41312f2ab68ceaa95ca0cc235f6b612c790bb90e /src | |
parent | 5cc5c903df7b535c6bf27987b89a405812d89735 (diff) | |
download | mana-client-ef4486580fc7b8293555fcabc398ed0c2b90d78e.tar.gz mana-client-ef4486580fc7b8293555fcabc398ed0c2b90d78e.tar.bz2 mana-client-ef4486580fc7b8293555fcabc398ed0c2b90d78e.tar.xz mana-client-ef4486580fc7b8293555fcabc398ed0c2b90d78e.zip |
Got rid of numerous additions and substractions to the hair style and color.
Hair style 0 was added and defined as being bald (so bald is no longer a
hardcoded style).
Diffstat (limited to 'src')
-rw-r--r-- | src/being.cpp | 12 | ||||
-rw-r--r-- | src/being.h | 2 | ||||
-rw-r--r-- | src/gui/char_select.cpp | 11 | ||||
-rw-r--r-- | src/gui/playerbox.cpp | 5 | ||||
-rw-r--r-- | src/main.cpp | 2 | ||||
-rw-r--r-- | src/net/beinghandler.cpp | 4 | ||||
-rw-r--r-- | src/player.cpp | 8 |
7 files changed, 18 insertions, 26 deletions
diff --git a/src/being.cpp b/src/being.cpp index 7755d4e5..70e3eb8e 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -104,21 +104,13 @@ Being::setPath(const Path &path) void Being::setHairColor(Uint16 color) { - mHairColor = color; - if (mHairColor < 1 || mHairColor > NR_HAIR_COLORS + 1) - { - mHairColor = 1; - } + mHairColor = (color < NR_HAIR_COLORS) ? color : 0; } void Being::setHairStyle(Uint16 style) { - mHairStyle = style; - if (mHairStyle < 1 || mHairStyle > NR_HAIR_STYLES) - { - mHairStyle = 1; - } + mHairStyle = (style < NR_HAIR_STYLES) ? style : 0; } void diff --git a/src/being.h b/src/being.h index 055ea0d4..496f183d 100644 --- a/src/being.h +++ b/src/being.h @@ -33,7 +33,7 @@ #include "map.h" #include "animatedsprite.h" -#define NR_HAIR_STYLES 7 +#define NR_HAIR_STYLES 8 #define NR_HAIR_COLORS 10 class AnimatedSprite; diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp index 2fa6c68e..3db82287 100644 --- a/src/gui/char_select.cpp +++ b/src/gui/char_select.cpp @@ -183,8 +183,8 @@ void CharSelectDialog::updatePlayerInfo() mDelCharButton->setEnabled(true); mSelectButton->setEnabled(true); } - mPlayerBox->mHairStyle = pi->getHairStyle() - 1; - mPlayerBox->mHairColor = pi->getHairColor() - 1; + mPlayerBox->mHairStyle = pi->getHairStyle(); + mPlayerBox->mHairColor = pi->getHairColor(); mPlayerBox->mSex = pi->getSex(); mPlayerBox->mShowPlayer = true; } else { @@ -324,11 +324,10 @@ std::string CharCreateDialog::getName() void CharCreateDialog::attemptCharCreate() { // Send character infos - MessageOut outMsg; - outMsg.writeShort(PAMSG_CHAR_CREATE); + MessageOut outMsg(PAMSG_CHAR_CREATE); outMsg.writeString(getName()); - outMsg.writeByte(mPlayerBox->mHairStyle + 1); - outMsg.writeByte(mPlayerBox->mHairColor + 1); + outMsg.writeByte(mPlayerBox->mHairStyle); + outMsg.writeByte(mPlayerBox->mHairColor); // TODO: send selected sex outMsg.writeByte(0); // Player sex outMsg.writeShort(10); // STR diff --git a/src/gui/playerbox.cpp b/src/gui/playerbox.cpp index d8faff99..ba97d54c 100644 --- a/src/gui/playerbox.cpp +++ b/src/gui/playerbox.cpp @@ -94,12 +94,13 @@ void PlayerBox::draw(gcn::Graphics *graphics) playerset[mSex]->get(0), 23, 12); // Draw his hair - if (mHairColor < NR_HAIR_COLORS && mHairStyle < NR_HAIR_STYLES) + if (mHairStyle > 0 && mHairColor < NR_HAIR_COLORS && + mHairStyle < NR_HAIR_STYLES) { int hf = 9 * mHairColor; if (hf >= 0 && hf < (int)hairset[mHairStyle]->size()) { dynamic_cast<Graphics*>(graphics)->drawImage( - hairset[mHairStyle]->get(hf), 35, 7); + hairset[mHairStyle - 1]->get(hf), 35, 7); } } } diff --git a/src/main.cpp b/src/main.cpp index ef5557ec..4e65e4fc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -257,7 +257,7 @@ void init_engine() if (!playerset[1]) logger->error("Couldn't load female player spriteset!"); - for (int i = 0; i < NR_HAIR_STYLES; i++) + for (int i = 0; i < NR_HAIR_STYLES - 1; i++) { Spriteset *tmp = ResourceManager::getInstance()->getSpriteset( "graphics/sprites/hairstyle" + toString(i + 1) + ".png", diff --git a/src/net/beinghandler.cpp b/src/net/beinghandler.cpp index 10de5351..c85e8893 100644 --- a/src/net/beinghandler.cpp +++ b/src/net/beinghandler.cpp @@ -398,7 +398,7 @@ BeingHandler::handleBeingEnterMessage(MessageIn &msg) being = beingManager->createBeing(id, 0); being->setName(name); } - being->setHairStyle(msg.readByte() + 1); - being->setHairColor(msg.readByte() + 1); + being->setHairStyle(msg.readByte()); + being->setHairColor(msg.readByte()); being->setSex(msg.readByte()); } diff --git a/src/player.cpp b/src/player.cpp index b864dd0e..3f4abebb 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -114,12 +114,12 @@ Player::setSex(Uint8 sex) void Player::setHairColor(Uint16 color) { - if (color != mHairColor && mHairStyle > 0) + if (color != mHairColor) { delete mSprites[HAIR_SPRITE]; AnimatedSprite *newHairSprite = new AnimatedSprite( "graphics/sprites/hairstyle" + toString(mHairStyle) + ".xml", - color - 1); + color); newHairSprite->setDirection(getSpriteDirection()); mSprites[HAIR_SPRITE] = newHairSprite; @@ -133,12 +133,12 @@ Player::setHairColor(Uint16 color) void Player::setHairStyle(Uint16 style) { - if (style != mHairStyle && mHairColor > 0) + if (style != mHairStyle) { delete mSprites[HAIR_SPRITE]; AnimatedSprite *newHairSprite = new AnimatedSprite( "graphics/sprites/hairstyle" + toString(style) + ".xml", - mHairColor - 1); + mHairColor); newHairSprite->setDirection(getSpriteDirection()); mSprites[HAIR_SPRITE] = newHairSprite; |