diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-06-10 22:46:50 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-06-10 22:46:50 +0300 |
commit | b6df3c3999d4be067e7314e3887e583c13ad1624 (patch) | |
tree | f7f39237cbf1e08440882c295cf3d7a494a2585a | |
parent | 83a142e6917bed619aeb96e217850299eb2a63be (diff) | |
download | plus-b6df3c3999d4be067e7314e3887e583c13ad1624.tar.gz plus-b6df3c3999d4be067e7314e3887e583c13ad1624.tar.bz2 plus-b6df3c3999d4be067e7314e3887e583c13ad1624.tar.xz plus-b6df3c3999d4be067e7314e3887e583c13ad1624.zip |
add partial support for player looks.
Can get packets from server, but cant draw player.
-rw-r--r-- | src/being.cpp | 14 | ||||
-rw-r--r-- | src/being.h | 8 | ||||
-rw-r--r-- | src/gui/charcreatedialog.cpp | 3 | ||||
-rw-r--r-- | src/gui/charcreatedialog.h | 1 | ||||
-rw-r--r-- | src/net/ea/beinghandler.cpp | 9 | ||||
-rw-r--r-- | src/net/eathena/beinghandler.cpp | 6 | ||||
-rw-r--r-- | src/net/eathena/charserverhandler.cpp | 4 | ||||
-rw-r--r-- | src/net/tmwa/beinghandler.cpp | 14 | ||||
-rw-r--r-- | src/net/tmwa/charserverhandler.cpp | 11 |
9 files changed, 46 insertions, 24 deletions
diff --git a/src/being.cpp b/src/being.cpp index 309069a5a..37a1cb84d 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -167,6 +167,7 @@ Being::Being(const int id, const Type type, const uint16_t subtype, mHairColor(0), mPet(nullptr), mPetId(0), + mLook(0), mOwner(nullptr), mSpecialParticle(nullptr) { @@ -177,7 +178,7 @@ Being::Being(const int id, const Type type, const uint16_t subtype, } setMap(map); - setSubtype(subtype); + setSubtype(subtype, 0); if (mType == PLAYER) mShowName = config.getBoolValue("visiblenames"); @@ -224,15 +225,16 @@ Being::~Being() mPet->setOwner(nullptr); } -void Being::setSubtype(const uint16_t subtype) +void Being::setSubtype(const uint16_t subtype, const uint8_t look) { if (!mInfo) return; - if (subtype == mSubType) + if (subtype == mSubType && mLook == look) return; mSubType = subtype; + mLook = look; if (mType == MONSTER) { @@ -2893,3 +2895,9 @@ void Being::playSfx(const SoundInfo &sound, Being *const being, soundManager.playSfx(sound.sound, x, y); } } + +void Being::setLook(const int look) +{ + if (mType == PLAYER) + setSubtype(mSubType, look); +} diff --git a/src/being.h b/src/being.h index 6911f830b..e1ffaff31 100644 --- a/src/being.h +++ b/src/being.h @@ -429,7 +429,7 @@ class Being : public ActorSprite, public ConfigListener /** * Set Being's subtype (mostly for view for monsters and NPCs) */ - void setSubtype(const uint16_t subtype); + void setSubtype(const uint16_t subtype, const uint8_t look); const BeingInfo *getInfo() const A_WARN_UNUSED { return mInfo; } @@ -877,6 +877,11 @@ class Being : public ActorSprite, public ConfigListener void playSfx(const SoundInfo &sound, Being *const being, const bool main, const int x, const int y); + int getLook() + { return mLook; } + + void setLook(const int look); + static uint8_t genderToInt(const Gender sex) A_WARN_UNUSED; static Gender intToGender(uint8_t sex) A_WARN_UNUSED; @@ -1041,6 +1046,7 @@ class Being : public ActorSprite, public ConfigListener unsigned char mHairColor; Being *mPet; int mPetId; + int mLook; Being *mOwner; Particle *mSpecialParticle; }; diff --git a/src/gui/charcreatedialog.cpp b/src/gui/charcreatedialog.cpp index 7ccfeb6f1..dc65f6ae1 100644 --- a/src/gui/charcreatedialog.cpp +++ b/src/gui/charcreatedialog.cpp @@ -119,6 +119,7 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent, // TRANSLATORS: char create dialog button mCancelButton(new Button(this, _("Cancel"), "cancel", this)), mRace(0), + mLook(0), mPlayer(new Being(0, ActorSprite::PLAYER, static_cast<uint16_t>(mRace), nullptr)), mPlayerBox(new PlayerBox(mPlayer, "charcreate_playerbox.xml", @@ -561,7 +562,7 @@ void CharCreateDialog::updateRace() else if (mRace >= Being::getNumOfRaces()) mRace = 0; - mPlayer->setSubtype(static_cast<uint16_t>(mRace)); + mPlayer->setSubtype(static_cast<uint16_t>(mRace), mLook); const ItemInfo &item = ItemDB::get(-100 - mRace); mRaceNameLabel->setCaption(item.getName()); mRaceNameLabel->adjustSize(); diff --git a/src/gui/charcreatedialog.h b/src/gui/charcreatedialog.h index 69ae1af1a..a7cb5105c 100644 --- a/src/gui/charcreatedialog.h +++ b/src/gui/charcreatedialog.h @@ -136,6 +136,7 @@ class CharCreateDialog final : public Window, Button *mCancelButton; int mRace; + int mLook; Being *mPlayer; PlayerBox *mPlayerBox; diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp index 05b7c348a..ea74bc6a2 100644 --- a/src/net/ea/beinghandler.cpp +++ b/src/net/ea/beinghandler.cpp @@ -195,13 +195,12 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, if (speed == 0) speed = 150; - dstBeing->setWalkSpeed(Vector(speed, speed, 0)); - dstBeing->setSubtype(job); + const int hairStyle = msg.readInt8(); + const int look = msg.readInt8(); + dstBeing->setSubtype(job, look); if (dstBeing->getType() == ActorSprite::MONSTER && player_node) player_node->checkNewName(dstBeing); - - const int hairStyle = msg.readInt8(); - msg.readInt8(); // free + dstBeing->setWalkSpeed(Vector(speed, speed, 0)); const uint16_t weapon = msg.readInt16(); const uint16_t headBottom = msg.readInt16(); diff --git a/src/net/eathena/beinghandler.cpp b/src/net/eathena/beinghandler.cpp index 633dfff56..3c85fb352 100644 --- a/src/net/eathena/beinghandler.cpp +++ b/src/net/eathena/beinghandler.cpp @@ -298,7 +298,7 @@ void BeingHandler::processBeingChangeLook(Net::MessageIn &msg, switch (type) { case 0: // change race - dstBeing->setSubtype(static_cast<uint16_t>(id)); + dstBeing->setSubtype(static_cast<uint16_t>(id), 0); break; case 1: // eAthena LOOK_HAIR dstBeing->setSpriteID(SPRITE_HAIR, id *-1); @@ -475,7 +475,7 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, } dstBeing->setWalkSpeed(Vector(speed, speed, 0)); - dstBeing->setSubtype(job); + dstBeing->setSubtype(job, 0); const int hairStyle = msg.readInt16(); const uint16_t weapon = msg.readInt16(); @@ -705,7 +705,7 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, speed = 150; dstBeing->setWalkSpeed(Vector(speed, speed, 0)); - dstBeing->setSubtype(job); + dstBeing->setSubtype(job, 0); if (dstBeing->getType() == ActorSprite::MONSTER && player_node) player_node->checkNewName(dstBeing); diff --git a/src/net/eathena/charserverhandler.cpp b/src/net/eathena/charserverhandler.cpp index 6fafb3aa0..8c82ed85d 100644 --- a/src/net/eathena/charserverhandler.cpp +++ b/src/net/eathena/charserverhandler.cpp @@ -154,8 +154,8 @@ void CharServerHandler::readPlayerData(Net::MessageIn &msg, data.mAttributes[PlayerInfo::MP] = msg.readInt16(); data.mAttributes[PlayerInfo::MAX_MP] = msg.readInt16(); - msg.readInt16(); // speed - tempPlayer->setSubtype(msg.readInt16()); // class (used for race) + msg.readInt16(); // speed + tempPlayer->setSubtype(msg.readInt16(), 0); // class (used for race) const int hairStyle = msg.readInt16(); const uint16_t weapon = msg.readInt16(); diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp index 738a81651..e68e9f80b 100644 --- a/src/net/tmwa/beinghandler.cpp +++ b/src/net/tmwa/beinghandler.cpp @@ -299,11 +299,17 @@ void BeingHandler::processBeingChangeLook(Net::MessageIn &msg, switch (type) { case 0: // change race - dstBeing->setSubtype(static_cast<uint16_t>(id)); + dstBeing->setSubtype(static_cast<uint16_t>(id), + dstBeing->getLook()); break; case 1: // eAthena LOOK_HAIR - dstBeing->setHairStyle(SPRITE_HAIR, id * -1); + { + const int look = id / 256; + const int hair = id % 256; + dstBeing->setHairStyle(SPRITE_HAIR, hair * -1); + dstBeing->setLook(look); break; + } case 2: // Weapon ID in id, Shield ID in id2 dstBeing->setSprite(SPRITE_WEAPON, id, "", 1, true); if (!mHideShield) @@ -475,10 +481,10 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, } dstBeing->setWalkSpeed(Vector(speed, speed, 0)); - dstBeing->setSubtype(job); const int hairStyle = msg.readInt8(); - msg.readInt8(); // free + const int look = msg.readInt8(); + dstBeing->setSubtype(job, look); const uint16_t weapon = msg.readInt16(); const uint16_t shield = msg.readInt16(); const uint16_t headBottom = msg.readInt16(); diff --git a/src/net/tmwa/charserverhandler.cpp b/src/net/tmwa/charserverhandler.cpp index 10be5edf8..68699e327 100644 --- a/src/net/tmwa/charserverhandler.cpp +++ b/src/net/tmwa/charserverhandler.cpp @@ -157,11 +157,12 @@ void CharServerHandler::readPlayerData(Net::MessageIn &msg, data.mAttributes[PlayerInfo::MP] = msg.readInt16(); data.mAttributes[PlayerInfo::MAX_MP] = msg.readInt16(); - msg.readInt16(); // speed - tempPlayer->setSubtype(msg.readInt16()); // class (used for race) + msg.readInt16(); // speed + const int race = msg.readInt16(); // class (used for race) const int hairStyle = msg.readInt8(); - msg.readInt8(); // free - const uint16_t weapon = msg.readInt16(); // unused on server. need use? + const int look = msg.readInt8(); + tempPlayer->setSubtype(race, look); + const uint16_t weapon = msg.readInt16(); // unused on server. need use? tempPlayer->setSprite(SPRITE_WEAPON, weapon, "", 1, true); data.mAttributes[PlayerInfo::LEVEL] = msg.readInt16(); @@ -258,7 +259,7 @@ void CharServerHandler::newCharacter(const std::string &name, const int slot, outMsg.writeInt8(static_cast<int8_t>(hairColor)); outMsg.writeInt8(0); // unused outMsg.writeInt8(static_cast<int8_t>(hairstyle)); - outMsg.writeInt8(0); // unused + outMsg.writeInt8(123); // look if (serverVersion >= 2) outMsg.writeInt8(race); } |