From 173c48498dc55e9b86bee009427fb5ae58cd9821 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 10 Sep 2014 13:02:49 +0300 Subject: Split processBeingChangeLook into tow functions with net code and without. --- src/net/eathena/beinghandler.cpp | 15 ++++++++++----- src/net/eathena/beinghandler.h | 5 +++++ src/net/tmwa/beinghandler.cpp | 24 +++++++++++++----------- src/net/tmwa/beinghandler.h | 5 +++++ 4 files changed, 33 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/net/eathena/beinghandler.cpp b/src/net/eathena/beinghandler.cpp index 82a40ee78..91a467bbf 100644 --- a/src/net/eathena/beinghandler.cpp +++ b/src/net/eathena/beinghandler.cpp @@ -289,7 +289,6 @@ void BeingHandler::processBeingChangeLook(Net::MessageIn &msg) const const uint8_t type = msg.readUInt8("type"); int id = 0; unsigned int id2 = 0U; - const std::string color; const bool look2 = msg.getId() == SMSG_BEING_CHANGE_LOOKS2; if (!look2) @@ -305,15 +304,21 @@ void BeingHandler::processBeingChangeLook(Net::MessageIn &msg) const id2 = 1; } - if (!dstBeing) + if (!localPlayer || !dstBeing) return; + processBeingChangeLookContinue(dstBeing, type, id, id2); +} + +void BeingHandler::processBeingChangeLookContinue(Being *const dstBeing, + const uint8_t type, + const int id, + const int id2) const +{ if (dstBeing->getType() == ActorType::PLAYER) dstBeing->setOtherTime(); - if (!localPlayer) - return; - + const std::string color; switch (type) { case 0: // change race diff --git a/src/net/eathena/beinghandler.h b/src/net/eathena/beinghandler.h index 9d70bd860..0d4c71a77 100644 --- a/src/net/eathena/beinghandler.h +++ b/src/net/eathena/beinghandler.h @@ -75,6 +75,11 @@ class BeingHandler final : public MessageHandler, public Ea::BeingHandler void processRanksList(Net::MessageIn &msg) const; void processBeingChangeDirection(Net::MessageIn &msg) const; + + void processBeingChangeLookContinue(Being *const dstBeing, + const uint8_t type, + const int id, + const int id2) const; }; } // namespace EAthena diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp index 00651e066..5338cd4c3 100644 --- a/src/net/tmwa/beinghandler.cpp +++ b/src/net/tmwa/beinghandler.cpp @@ -268,16 +268,10 @@ void BeingHandler::processBeingChangeLook(Net::MessageIn &msg) const Being *const dstBeing = actorManager->findBeing( msg.readInt32("being id")); - if (!dstBeing) - { - BLOCK_END("BeingHandler::processBeingChangeLook") - return; - } const uint8_t type = msg.readUInt8("type"); int16_t id = 0; int id2 = 0; - const std::string color; const bool look2 = msg.getId() == SMSG_BEING_CHANGE_LOOKS2; if (!look2) @@ -299,15 +293,24 @@ void BeingHandler::processBeingChangeLook(Net::MessageIn &msg) const } } - if (dstBeing->getType() == ActorType::PLAYER) - dstBeing->setOtherTime(); - - if (!localPlayer) + if (!localPlayer || !dstBeing) { BLOCK_END("BeingHandler::processBeingChangeLook") return; } + processBeingChangeLookContinue(dstBeing, type, id, id2); + BLOCK_END("BeingHandler::processBeingChangeLook") +} + +void BeingHandler::processBeingChangeLookContinue(Being *const dstBeing, + const uint8_t type, + const int id, + const int id2) const +{ + if (dstBeing->getType() == ActorType::PLAYER) + dstBeing->setOtherTime(); + const std::string color; switch (type) { case 0: // change race @@ -402,7 +405,6 @@ void BeingHandler::processBeingChangeLook(Net::MessageIn &msg) const logger->log("name: " + toString(dstBeing->getName())); break; } - BLOCK_END("BeingHandler::processBeingChangeLook") } void BeingHandler::processNameResponse2(Net::MessageIn &msg) diff --git a/src/net/tmwa/beinghandler.h b/src/net/tmwa/beinghandler.h index f16af835d..4f2d75f0c 100644 --- a/src/net/tmwa/beinghandler.h +++ b/src/net/tmwa/beinghandler.h @@ -67,6 +67,11 @@ class BeingHandler final : public MessageHandler, public Ea::BeingHandler void processBeingMove2(Net::MessageIn &msg) const; void processBeingChangeDirection(Net::MessageIn &msg) const; + + void processBeingChangeLookContinue(Being *const dstBeing, + const uint8_t type, + const int id, + const int id2) const; }; } // namespace TmwAthena -- cgit v1.2.3-70-g09d2