diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-11-25 18:18:57 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-11-25 18:18:57 +0300 |
commit | e29c49d5f84544ef8178b7240b30485bfaf9ebce (patch) | |
tree | abba3ad42514cd14adc988ff37012c4361f2727e | |
parent | 488428c6dba3d1e82b017bfb3b08ba85ced82be2 (diff) | |
download | plus-e29c49d5f84544ef8178b7240b30485bfaf9ebce.tar.gz plus-e29c49d5f84544ef8178b7240b30485bfaf9ebce.tar.bz2 plus-e29c49d5f84544ef8178b7240b30485bfaf9ebce.tar.xz plus-e29c49d5f84544ef8178b7240b30485bfaf9ebce.zip |
prevent update some sprites from move packets and some other.
-rw-r--r-- | src/being/being.cpp | 15 | ||||
-rw-r--r-- | src/being/being.h | 6 | ||||
-rw-r--r-- | src/net/ea/beinghandler.cpp | 5 | ||||
-rw-r--r-- | src/net/eathena/beinghandler.cpp | 12 | ||||
-rw-r--r-- | src/net/tmwa/beinghandler.cpp | 18 |
5 files changed, 38 insertions, 18 deletions
diff --git a/src/being/being.cpp b/src/being/being.cpp index f3976a20e..c503e94d5 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -1902,6 +1902,21 @@ void Being::updateColors() } } +void Being::updateSprite(const unsigned int slot, const int id, + std::string color, const unsigned char colorId, + const bool isWeapon, const bool isTempSprite) +{ + if (slot >= Net::getCharServerHandler()->maxSprite()) + return; + + if (slot >= mSpriteIDs.size()) + mSpriteIDs.resize(slot + 1, 0); + + if (slot && mSpriteIDs[slot] == id) + return; + setSprite(slot, id, color, colorId, isWeapon, isTempSprite); +} + void Being::setSprite(const unsigned int slot, const int id, std::string color, const unsigned char colorId, const bool isWeapon, const bool isTempSprite) diff --git a/src/being/being.h b/src/being/being.h index a2316d607..41957ceca 100644 --- a/src/being/being.h +++ b/src/being/being.h @@ -378,6 +378,12 @@ class Being : public ActorSprite, public ConfigListener const bool isWeapon = false, const bool isTempSprite = false); + void updateSprite(const unsigned int slot, const int id, + std::string color = "", + const unsigned char colorId = 1, + const bool isWeapon = false, + const bool isTempSprite = false); + void setSpriteID(const unsigned int slot, const int id); void setSpriteColor(const unsigned int slot, diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp index daef49b42..0a864bbac 100644 --- a/src/net/ea/beinghandler.cpp +++ b/src/net/ea/beinghandler.cpp @@ -110,7 +110,7 @@ void BeingHandler::setSprite(Being *const being, const unsigned int slot, { if (!being) return; - being->setSprite(slot, id, color, colorId, isWeapon, isTempSprite); + being->updateSprite(slot, id, color, colorId, isWeapon, isTempSprite); } void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, @@ -255,10 +255,9 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, } uint8_t gender = msg.readInt8(); - // reserving bits for future usage - if (!disguiseId && dstBeing->getType() == ActorSprite::PLAYER) { + // reserving bits for future usage gender &= 3; dstBeing->setGender(Being::intToGender(gender)); // Set these after the gender, as the sprites may be gender-specific diff --git a/src/net/eathena/beinghandler.cpp b/src/net/eathena/beinghandler.cpp index 652776e28..108e6b50f 100644 --- a/src/net/eathena/beinghandler.cpp +++ b/src/net/eathena/beinghandler.cpp @@ -511,13 +511,13 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, if (!disguiseId) { // Set these after the gender, as the sprites may be gender-specific - dstBeing->setSprite(SPRITE_WEAPON, weapon, "", 1, true); + dstBeing->updateSprite(SPRITE_WEAPON, weapon, "", 1, true); if (!mHideShield) - dstBeing->setSprite(SPRITE_SHIELD, shield); - dstBeing->setSprite(SPRITE_BOTTOMCLOTHES, headBottom); - dstBeing->setSprite(SPRITE_TOPCLOTHES, headMid); - dstBeing->setSprite(SPRITE_HAT, headTop); - dstBeing->setSprite(SPRITE_HAIR, hairStyle * -1, + dstBeing->updateSprite(SPRITE_SHIELD, shield); + dstBeing->updateSprite(SPRITE_BOTTOMCLOTHES, headBottom); + dstBeing->updateSprite(SPRITE_TOPCLOTHES, headMid); + dstBeing->updateSprite(SPRITE_HAT, headTop); + dstBeing->updateSprite(SPRITE_HAIR, hairStyle * -1, ItemDB::get(-hairStyle).getDyeColorsString(hairColor)); } player_node->imitateOutfit(dstBeing); diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp index 47d86a240..cfb25fa49 100644 --- a/src/net/tmwa/beinghandler.cpp +++ b/src/net/tmwa/beinghandler.cpp @@ -525,23 +525,23 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, if (!disguiseId) { // Set these after the gender, as the sprites may be gender-specific - dstBeing->setSprite(SPRITE_WEAPON, weapon, "", 1, true); + dstBeing->updateSprite(SPRITE_WEAPON, weapon, "", 1, true); if (!mHideShield) - dstBeing->setSprite(SPRITE_SHIELD, shield); + dstBeing->updateSprite(SPRITE_SHIELD, shield); if (serverVersion > 0) { - dstBeing->setSprite(SPRITE_BOTTOMCLOTHES, headBottom, + dstBeing->updateSprite(SPRITE_BOTTOMCLOTHES, headBottom, "", colors[0]); - dstBeing->setSprite(SPRITE_TOPCLOTHES, headMid, "", colors[2]); - dstBeing->setSprite(SPRITE_HAT, headTop, "", colors[1]); + dstBeing->updateSprite(SPRITE_TOPCLOTHES, headMid, "", colors[2]); + dstBeing->updateSprite(SPRITE_HAT, headTop, "", colors[1]); } else { - dstBeing->setSprite(SPRITE_BOTTOMCLOTHES, headBottom); - dstBeing->setSprite(SPRITE_TOPCLOTHES, headMid); - dstBeing->setSprite(SPRITE_HAT, headTop); + dstBeing->updateSprite(SPRITE_BOTTOMCLOTHES, headBottom); + dstBeing->updateSprite(SPRITE_TOPCLOTHES, headMid); + dstBeing->updateSprite(SPRITE_HAT, headTop); } - dstBeing->setSprite(SPRITE_HAIR, hairStyle * -1, + dstBeing->updateSprite(SPRITE_HAIR, hairStyle * -1, ItemDB::get(-hairStyle).getDyeColorsString(hairColor)); dstBeing->setHairColor(hairColor); } |