diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-06-21 14:48:50 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-06-21 14:48:50 +0300 |
commit | 71cccfd289845fcd31e64f35d600ebafd4aa29c6 (patch) | |
tree | 92aa5ed488968288b4308276e2ce889b872d14d1 /src | |
parent | 2db418d196b1778c0160420201066af824f6eae1 (diff) | |
download | mv-71cccfd289845fcd31e64f35d600ebafd4aa29c6.tar.gz mv-71cccfd289845fcd31e64f35d600ebafd4aa29c6.tar.bz2 mv-71cccfd289845fcd31e64f35d600ebafd4aa29c6.tar.xz mv-71cccfd289845fcd31e64f35d600ebafd4aa29c6.zip |
Split in Being setSprite into setSprite and setSpriteId.
Diffstat (limited to 'src')
-rw-r--r-- | src/being/being.cpp | 102 | ||||
-rw-r--r-- | src/being/being.h | 3 | ||||
-rw-r--r-- | src/gui/windows/charcreatedialog.cpp | 6 | ||||
-rw-r--r-- | src/net/eathena/beinghandler.cpp | 90 | ||||
-rw-r--r-- | src/net/eathena/beingrecv.cpp | 6 | ||||
-rw-r--r-- | src/net/eathena/charserverrecv.cpp | 54 | ||||
-rw-r--r-- | src/net/tmwa/beinghandler.cpp | 30 | ||||
-rw-r--r-- | src/net/tmwa/beingrecv.cpp | 6 | ||||
-rw-r--r-- | src/net/tmwa/charserverrecv.cpp | 60 |
9 files changed, 181 insertions, 176 deletions
diff --git a/src/being/being.cpp b/src/being/being.cpp index 84716dd8f..19678cf64 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -494,10 +494,8 @@ void Being::setSubtype(const BeingTypeId subtype, setRaceName(_("Human")); if (charServerHandler) { - setSprite(charServerHandler->baseSprite(), - id, - std::string(), - ItemColor_one); + setSpriteId(charServerHandler->baseSprite(), + id); } } else @@ -2490,6 +2488,95 @@ void Being::updateSprite(const unsigned int slot, mSlots[slot].cardsId); } +// set sprite id, reset colors, reset cards +void Being::setSpriteId(const unsigned int slot, + const int id) restrict2 +{ + if (!charServerHandler || slot >= charServerHandler->maxSprite()) + return; + + if (slot >= CAST_U32(mSprites.size())) + ensureSize(slot + 1); + + if (slot >= CAST_U32(mSlots.size())) + mSlots.resize(slot + 1, BeingSlot()); + + // id = 0 means unequip + if (id == 0) + { + removeSprite(slot); + mSpriteDraw[slot] = 0; + + const int id1 = mSlots[slot].spriteId; + if (id1) + { + const ItemInfo &info = ItemDB::get(id1); + if (mMap && + mType == ActorType::Player) + { + const BeingId pet = fromInt(info.getPet(), BeingId); + if (pet != BeingId_zero) + removePet(pet); + } + removeItemParticles(id1); + } + } + else + { + const ItemInfo &info = ItemDB::get(id); + const std::string &restrict filename = info.getSprite( + mGender, mSubType); + int lastTime = 0; + int startTime = 0; + AnimatedSprite *restrict equipmentSprite = nullptr; + + if (mType == ActorType::Player) + { + const BeingId pet = fromInt(info.getPet(), BeingId); + if (pet != BeingId_zero) + addPet(pet); + } + + if (!filename.empty()) + { + equipmentSprite = AnimatedSprite::delayedLoad( + paths.getStringValue("sprites").append(filename)); + } + + if (equipmentSprite) + { + equipmentSprite->setSpriteDirection(getSpriteDirection()); + startTime = getStartTime(); + lastTime = getLastTime(); + } + + CompoundSprite::setSprite(slot, equipmentSprite); + mSpriteDraw[slot] = id; + + addItemParticles(id, info.getDisplay()); + + setAction(mAction, 0); + if (equipmentSprite) + { + if (lastTime > 0) + { + equipmentSprite->setLastTime(startTime); + equipmentSprite->update(lastTime); + } + } + } + + BeingSlot &beingSlot = mSlots[slot]; + beingSlot.spriteId = id; + beingSlot.color = ""; + beingSlot.colorId = ItemColor_one; + beingSlot.cardsId = CardsList(nullptr); + recalcSpritesOrder(); + if (beingEquipmentWindow) + beingEquipmentWindow->updateBeing(this); +} + +// set sprite id, colors, reset cards void Being::setSprite(const unsigned int slot, const int id, std::string color, @@ -2587,6 +2674,7 @@ void Being::setSprite(const unsigned int slot, beingEquipmentWindow->updateBeing(this); } +// set sprite id, colors, cards void Being::setSpriteCards(const unsigned int slot, const int id, std::string color, @@ -3848,10 +3936,8 @@ void Being::undressItemById(const int id) restrict2 { if (id == mSlots[f].spriteId) { - setSprite(CAST_U32(f), - 0, - std::string(), - ItemColor_one); + setSpriteId(CAST_U32(f), + 0); break; } } diff --git a/src/being/being.h b/src/being/being.h index 825e4ab84..79068b255 100644 --- a/src/being/being.h +++ b/src/being/being.h @@ -326,6 +326,9 @@ class Being notfinal : public ActorSprite, ItemColor colorId, CardsList cards) restrict2; + void setSpriteId(const unsigned int slot, + const int id) restrict2; + void setWeaponId(const int id) restrict2; void setTempSprite(const unsigned int slot, diff --git a/src/gui/windows/charcreatedialog.cpp b/src/gui/windows/charcreatedialog.cpp index c58be3e02..762d76c00 100644 --- a/src/gui/windows/charcreatedialog.cpp +++ b/src/gui/windows/charcreatedialog.cpp @@ -156,10 +156,8 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent, it != it_fend; ++ it, i ++) { - mPlayer->setSprite(i, - *it, - std::string(), - ItemColor_one); + mPlayer->setSpriteId(i, + *it); } if (!maxHairColor) diff --git a/src/net/eathena/beinghandler.cpp b/src/net/eathena/beinghandler.cpp index 0243f1899..dbf797e2b 100644 --- a/src/net/eathena/beinghandler.cpp +++ b/src/net/eathena/beinghandler.cpp @@ -50,66 +50,36 @@ void BeingHandler::undress(Being *const being) const { if (!being) return; - being->setSprite(SPRITE_WEAPON, - 0, - std::string(), - ItemColor_one); - being->setSprite(SPRITE_HEAD_BOTTOM, - 0, - std::string(), - ItemColor_one); - being->setSprite(SPRITE_HEAD_TOP, - 0, - std::string(), - ItemColor_one); - being->setSprite(SPRITE_HEAD_MID, - 0, - std::string(), - ItemColor_one); - being->setSprite(SPRITE_CLOTHES_COLOR, - 0, - std::string(), - ItemColor_one); - being->setSprite(SPRITE_SHIELD, - 0, - std::string(), - ItemColor_one); - being->setSprite(SPRITE_FLOOR, - 0, - std::string(), - ItemColor_one); - being->setSprite(SPRITE_ROBE, - 0, - std::string(), - ItemColor_one); - being->setSprite(SPRITE_EVOL2, - 0, - std::string(), - ItemColor_one); - being->setSprite(SPRITE_EVOL3, - 0, - std::string(), - ItemColor_one); - being->setSprite(SPRITE_EVOL4, - 0, - std::string(), - ItemColor_one); - being->setSprite(SPRITE_EVOL5, - 0, - std::string(), - ItemColor_one); - being->setSprite(SPRITE_EVOL6, - 0, - std::string(), - ItemColor_one); - being->setSprite(SPRITE_HAIR, - 0, - std::string(), - ItemColor_one); - being->setSprite(SPRITE_SHOES, - 0, - std::string(), - ItemColor_one); + being->setSpriteId(SPRITE_WEAPON, + 0); + being->setSpriteId(SPRITE_HEAD_BOTTOM, + 0); + being->setSpriteId(SPRITE_HEAD_TOP, + 0); + being->setSpriteId(SPRITE_HEAD_MID, + 0); + being->setSpriteId(SPRITE_CLOTHES_COLOR, + 0); + being->setSpriteId(SPRITE_SHIELD, + 0); + being->setSpriteId(SPRITE_FLOOR, + 0); + being->setSpriteId(SPRITE_ROBE, + 0); + being->setSpriteId(SPRITE_EVOL2, + 0); + being->setSpriteId(SPRITE_EVOL3, + 0); + being->setSpriteId(SPRITE_EVOL4, + 0); + being->setSpriteId(SPRITE_EVOL5, + 0); + being->setSpriteId(SPRITE_EVOL6, + 0); + being->setSpriteId(SPRITE_HAIR, + 0); + being->setSpriteId(SPRITE_SHOES, + 0); } void BeingHandler::requestRanks(const RankT rank) const diff --git a/src/net/eathena/beingrecv.cpp b/src/net/eathena/beingrecv.cpp index 2a06e899b..bffa9d274 100644 --- a/src/net/eathena/beingrecv.cpp +++ b/src/net/eathena/beingrecv.cpp @@ -165,10 +165,8 @@ void BeingRecv::processBeingChangeLookContinue(const Net::MessageIn &msg, itemColor, CardsList(cards)); dstBeing->setWeaponId(id); - dstBeing->setSprite(SPRITE_FLOOR, - id2, - std::string(), - ItemColor_one); + dstBeing->setSpriteId(SPRITE_FLOOR, + id2); if (localPlayer) localPlayer->imitateOutfit(dstBeing, SPRITE_FLOOR); break; diff --git a/src/net/eathena/charserverrecv.cpp b/src/net/eathena/charserverrecv.cpp index 321745312..555a876be 100644 --- a/src/net/eathena/charserverrecv.cpp +++ b/src/net/eathena/charserverrecv.cpp @@ -147,10 +147,8 @@ void CharServerRecv::readPlayerData(Net::MessageIn &msg, tempPlayer->setHairColor(color); if (hairStyle == 0) { - tempPlayer->setSprite(SPRITE_HAIR_COLOR, - 0, - std::string(), - ItemColor_one); + tempPlayer->setSpriteId(SPRITE_HAIR_COLOR, + 0); } else { @@ -187,38 +185,22 @@ void CharServerRecv::readPlayerData(Net::MessageIn &msg, shoes = msg.readInt32("robe"); if (!serverFeatures->haveAdvancedSprites()) { - tempPlayer->setSprite(SPRITE_HAIR, - shoes, - std::string(), - ItemColor_one); - tempPlayer->setSprite(SPRITE_SHOES, - gloves, - std::string(), - ItemColor_one); - tempPlayer->setSprite(SPRITE_SHIELD, - cape, - std::string(), - ItemColor_one); - tempPlayer->setSprite(SPRITE_HEAD_TOP, - misc1, - std::string(), - ItemColor_one); - tempPlayer->setSprite(SPRITE_WEAPON, - bottomClothes, - std::string(), - ItemColor_one); - tempPlayer->setSprite(SPRITE_FLOOR, - shield, - std::string(), - ItemColor_one); - tempPlayer->setSprite(SPRITE_CLOTHES_COLOR, - hat, - std::string(), - ItemColor_one); - tempPlayer->setSprite(SPRITE_HEAD_BOTTOM, - topClothes, - std::string(), - ItemColor_one); + tempPlayer->setSpriteId(SPRITE_HAIR, + shoes); + tempPlayer->setSpriteId(SPRITE_SHOES, + gloves); + tempPlayer->setSpriteId(SPRITE_SHIELD, + cape); + tempPlayer->setSpriteId(SPRITE_HEAD_TOP, + misc1); + tempPlayer->setSpriteId(SPRITE_WEAPON, + bottomClothes); + tempPlayer->setSpriteId(SPRITE_FLOOR, + shield); + tempPlayer->setSpriteId(SPRITE_CLOTHES_COLOR, + hat); + tempPlayer->setSpriteId(SPRITE_HEAD_BOTTOM, + topClothes); // tempPlayer->setSprite(SPRITE_HEAD_MID, misc2); } if (packetVersion >= 20110928) diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp index 159e56fb8..346aedf58 100644 --- a/src/net/tmwa/beinghandler.cpp +++ b/src/net/tmwa/beinghandler.cpp @@ -49,26 +49,16 @@ void BeingHandler::undress(Being *const being) const { if (!being) return; - being->setSprite(SPRITE_WEAPON, - 0, - std::string(), - ItemColor_one); - being->setSprite(SPRITE_HEAD_BOTTOM, - 0, - std::string(), - ItemColor_one); - being->setSprite(SPRITE_CLOTHES_COLOR, - 0, - std::string(), - ItemColor_one); - being->setSprite(SPRITE_HAIR, - 0, - std::string(), - ItemColor_one); - being->setSprite(SPRITE_SHOES, - 0, - std::string(), - ItemColor_one); + being->setSpriteId(SPRITE_WEAPON, + 0); + being->setSpriteId(SPRITE_HEAD_BOTTOM, + 0); + being->setSpriteId(SPRITE_CLOTHES_COLOR, + 0); + being->setSpriteId(SPRITE_HAIR, + 0); + being->setSpriteId(SPRITE_SHOES, + 0); } #ifdef EATHENA_SUPPORT diff --git a/src/net/tmwa/beingrecv.cpp b/src/net/tmwa/beingrecv.cpp index d86d8b2ec..2ece0e993 100644 --- a/src/net/tmwa/beingrecv.cpp +++ b/src/net/tmwa/beingrecv.cpp @@ -148,10 +148,8 @@ void BeingRecv::processBeingChangeLookContinue(const Net::MessageIn &msg, "", ItemColor_one); dstBeing->setWeaponId(id); - dstBeing->setSprite(SPRITE_FLOOR, - id2, - std::string(), - ItemColor_one); + dstBeing->setSpriteId(SPRITE_FLOOR, + id2); localPlayer->imitateOutfit(dstBeing, SPRITE_FLOOR); break; case 3: // Change lower headgear for eAthena, pants for us diff --git a/src/net/tmwa/charserverrecv.cpp b/src/net/tmwa/charserverrecv.cpp index 982779a23..85f06159d 100644 --- a/src/net/tmwa/charserverrecv.cpp +++ b/src/net/tmwa/charserverrecv.cpp @@ -124,10 +124,8 @@ void CharServerRecv::readPlayerData(Net::MessageIn &msg, msg.readUInt8("unused"); if (hairStyle == 0) { - tempPlayer->setSprite(SPRITE_HAIR_COLOR, - 0, - std::string(), - ItemColor_one); + tempPlayer->setSpriteId(SPRITE_HAIR_COLOR, + 0); } else { @@ -150,42 +148,24 @@ void CharServerRecv::readPlayerData(Net::MessageIn &msg, character->data.mStats[Attributes::DEX].base = msg.readUInt8("dex"); character->data.mStats[Attributes::LUK].base = msg.readUInt8("luk"); - tempPlayer->setSprite(SPRITE_HAIR, - shoes, - std::string(), - ItemColor_one); - tempPlayer->setSprite(SPRITE_SHOES, - gloves, - std::string(), - ItemColor_one); - tempPlayer->setSprite(SPRITE_SHIELD, - cape, - std::string(), - ItemColor_one); - tempPlayer->setSprite(SPRITE_HEAD_TOP, - misc1, - std::string(), - ItemColor_one); - tempPlayer->setSprite(SPRITE_WEAPON, - bottomClothes, - std::string(), - ItemColor_one); - tempPlayer->setSprite(SPRITE_FLOOR, - shield, - std::string(), - ItemColor_one); - tempPlayer->setSprite(SPRITE_CLOTHES_COLOR, - hat, - std::string(), - ItemColor_one); - tempPlayer->setSprite(SPRITE_HEAD_BOTTOM, - topClothes, - std::string(), - ItemColor_one); - tempPlayer->setSprite(SPRITE_HEAD_MID, - misc2, - std::string(), - ItemColor_one); + tempPlayer->setSpriteId(SPRITE_HAIR, + shoes); + tempPlayer->setSpriteId(SPRITE_SHOES, + gloves); + tempPlayer->setSpriteId(SPRITE_SHIELD, + cape); + tempPlayer->setSpriteId(SPRITE_HEAD_TOP, + misc1); + tempPlayer->setSpriteId(SPRITE_WEAPON, + bottomClothes); + tempPlayer->setSpriteId(SPRITE_FLOOR, + shield); + tempPlayer->setSpriteId(SPRITE_CLOTHES_COLOR, + hat); + tempPlayer->setSpriteId(SPRITE_HEAD_BOTTOM, + topClothes); + tempPlayer->setSpriteId(SPRITE_HEAD_MID, + misc2); character->slot = msg.readUInt8("slot"); const uint8_t sex = CAST_U8(msg.readUInt8("gender")); |