From 279ebfc0831051375d8b7cc2b8bf4f60a19397c9 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 10 Sep 2014 14:13:50 +0300 Subject: add function to apply being action. --- src/net/eathena/beinghandler.cpp | 92 ++++++++++++++-------------------------- 1 file changed, 33 insertions(+), 59 deletions(-) (limited to 'src/net/eathena/beinghandler.cpp') diff --git a/src/net/eathena/beinghandler.cpp b/src/net/eathena/beinghandler.cpp index 1a5adcaf9..fb0a94f64 100644 --- a/src/net/eathena/beinghandler.cpp +++ b/src/net/eathena/beinghandler.cpp @@ -559,35 +559,7 @@ void BeingHandler::processPlayerUpdate1(Net::MessageIn &msg) const if (gmstatus & 0x80) dstBeing->setGM(true); - const uint8_t type = msg.readUInt8("action type"); - switch (type) - { - case 0: - dstBeing->setAction(BeingAction::STAND, 0); - localPlayer->imitateAction(dstBeing, BeingAction::STAND); - break; - - case 1: - if (dstBeing->getCurrentAction() != BeingAction::DEAD) - { - dstBeing->setAction(BeingAction::DEAD, 0); - dstBeing->recalcSpritesOrder(); - } - break; - - case 2: - dstBeing->setAction(BeingAction::SIT, 0); - localPlayer->imitateAction(dstBeing, BeingAction::SIT); - break; - - default: - // need set stay state? - logger->log("QQQ2 SMSG_PLAYER_UPDATE_1:" - + toString(id) + " " + toString(type)); - logger->log("dstBeing id:" + toString(dstBeing->getId())); - logger->log("dstBeing name:" + dstBeing->getName()); - break; - } + applyPlayerAction(dstBeing, msg.readUInt8("action type")); const int level = static_cast(msg.readUInt8("level")); @@ -713,36 +685,7 @@ void BeingHandler::processPlayerUpdate2(Net::MessageIn &msg) const if (gmstatus & 0x80) dstBeing->setGM(true); - const uint8_t type = msg.readUInt8("action type"); - switch (type) - { - case 0: - dstBeing->setAction(BeingAction::STAND, 0); - localPlayer->imitateAction(dstBeing, BeingAction::STAND); - break; - - case 1: - if (dstBeing->getCurrentAction() != BeingAction::DEAD) - { - dstBeing->setAction(BeingAction::DEAD, 0); - dstBeing->recalcSpritesOrder(); - } - break; - - case 2: - dstBeing->setAction(BeingAction::SIT, 0); - localPlayer->imitateAction(dstBeing, BeingAction::SIT); - break; - - default: - // need set stay state? - logger->log("QQQ2 SMSG_PLAYER_UPDATE_1:" - + toString(id) + " " + toString(type)); - logger->log("dstBeing id:" + toString(dstBeing->getId())); - logger->log("dstBeing name:" + dstBeing->getName()); - break; - } - + applyPlayerAction(dstBeing, msg.readUInt8("action type")); const int level = static_cast(msg.readUInt8("level")); if (level) @@ -1659,4 +1602,35 @@ void BeingHandler::setServerGender(Being *const being, const uint8_t gender) } } +void BeingHandler::applyPlayerAction(Being *const being, const uint8_t type) +{ + switch (type) + { + case 0: + being->setAction(BeingAction::STAND, 0); + localPlayer->imitateAction(being, BeingAction::STAND); + break; + + case 1: + if (being->getCurrentAction() != BeingAction::DEAD) + { + being->setAction(BeingAction::DEAD, 0); + being->recalcSpritesOrder(); + } + break; + + case 2: + being->setAction(BeingAction::SIT, 0); + localPlayer->imitateAction(being, BeingAction::SIT); + break; + + default: + // need set stand state? + logger->log("QQQ2 SMSG_PLAYER_UPDATE_1:" + toString(type)); + logger->log("being id:" + toString(being->getId())); + logger->log("being name:" + being->getName()); + break; + } +} + } // namespace EAthena -- cgit v1.2.3-70-g09d2