From 814e88e5ca69bc54837be27429dbf42dd41f7ac6 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 12 May 2014 19:12:15 +0300 Subject: Move being action into separate file. --- src/net/ea/beinghandler.cpp | 31 +++++++++++++++++-------------- src/net/ea/playerhandler.cpp | 6 +++--- src/net/eathena/beinghandler.cpp | 22 +++++++++++----------- src/net/eathena/playerhandler.cpp | 16 ++++++++-------- src/net/eathena/playerhandler.h | 3 ++- src/net/playerhandler.h | 2 +- src/net/tmwa/beinghandler.cpp | 16 ++++++++-------- src/net/tmwa/playerhandler.cpp | 16 ++++++++-------- src/net/tmwa/playerhandler.h | 3 ++- 9 files changed, 60 insertions(+), 55 deletions(-) (limited to 'src/net') diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp index dd38dfdf7..34beab5ad 100644 --- a/src/net/ea/beinghandler.cpp +++ b/src/net/ea/beinghandler.cpp @@ -182,13 +182,13 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, if (spawnId) { - dstBeing->setAction(Being::SPAWN, 0); + dstBeing->setAction(BeingAction::SPAWN, 0); } else if (visible) { dstBeing->clearPath(); dstBeing->setActionTime(tick_time); - dstBeing->setAction(Being::STAND, 0); + dstBeing->setAction(BeingAction::STAND, 0); } // Prevent division by 0 when calculating frame @@ -300,7 +300,7 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, msg.readCoordinatePair(srcX, srcY, dstX, dstY); if (!disguiseId) { - dstBeing->setAction(Being::STAND, 0); + dstBeing->setAction(BeingAction::STAND, 0); dstBeing->setTileCoords(srcX, srcY); if (serverVersion < 10) dstBeing->setDestination(dstX, dstY); @@ -366,7 +366,7 @@ void BeingHandler::processBeingMove2(Net::MessageIn &msg) const msg.readCoordinatePair(srcX, srcY, dstX, dstY); msg.readInt32(); // Server tick - dstBeing->setAction(Being::STAND, 0); + dstBeing->setAction(BeingAction::STAND, 0); dstBeing->setTileCoords(srcX, srcY); dstBeing->setDestination(dstX, dstY); if (dstBeing->getType() == Being::PLAYER) @@ -405,9 +405,9 @@ void BeingHandler::processBeingRemove(Net::MessageIn &msg) const if (msg.readInt8() == 1) { - if (dstBeing->getCurrentAction() != Being::DEAD) + if (dstBeing->getCurrentAction() != BeingAction::DEAD) { - dstBeing->setAction(Being::DEAD, 0); + dstBeing->setAction(BeingAction::DEAD, 0); dstBeing->recalcSpritesOrder(); } if (dstBeing->getName() == "Jack O" && killStats) @@ -443,7 +443,7 @@ void BeingHandler::processBeingResurrect(Net::MessageIn &msg) const player_node->stopAttack(); if (msg.readInt8() == 1) - dstBeing->setAction(Being::STAND, 0); + dstBeing->setAction(BeingAction::STAND, 0); } @@ -511,17 +511,17 @@ void BeingHandler::processBeingAction(Net::MessageIn &msg) const break; // tmw server can send here garbage? // if (srcBeing) -// srcBeing->setAction(Being::DEAD, 0); +// srcBeing->setAction(BeingAction::DEAD, 0); case 0x02: // Sit if (srcBeing) { - srcBeing->setAction(Being::SIT, 0); + srcBeing->setAction(BeingAction::SIT, 0); if (srcBeing->getType() == Being::PLAYER) { srcBeing->setMoveTime(); if (player_node) - player_node->imitateAction(srcBeing, Being::SIT); + player_node->imitateAction(srcBeing, BeingAction::SIT); } } break; @@ -529,12 +529,15 @@ void BeingHandler::processBeingAction(Net::MessageIn &msg) const case 0x03: // Stand up if (srcBeing) { - srcBeing->setAction(Being::STAND, 0); + srcBeing->setAction(BeingAction::STAND, 0); if (srcBeing->getType() == Being::PLAYER) { srcBeing->setMoveTime(); if (player_node) - player_node->imitateAction(srcBeing, Being::STAND); + { + player_node->imitateAction(srcBeing, + BeingAction::STAND); + } } } break; @@ -702,8 +705,8 @@ void BeingHandler::processPlayerStop(Net::MessageIn &msg) const const uint16_t x = msg.readInt16(); const uint16_t y = msg.readInt16(); dstBeing->setTileCoords(x, y); - if (dstBeing->getCurrentAction() == Being::MOVE) - dstBeing->setAction(Being::STAND, 0); + if (dstBeing->getCurrentAction() == BeingAction::MOVE) + dstBeing->setAction(BeingAction::STAND, 0); } } } diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp index b299edd5f..efaee8857 100644 --- a/src/net/ea/playerhandler.cpp +++ b/src/net/ea/playerhandler.cpp @@ -203,7 +203,7 @@ void PlayerHandler::processPlayerWarp(Net::MessageIn &msg) } } - player_node->setAction(Being::STAND, 0); + player_node->setAction(BeingAction::STAND, 0); player_node->setTileCoords(x, y); player_node->updatePets(); player_node->navigateClean(); @@ -400,9 +400,9 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg) deathNotice = new OkDialog(_("Message"), DeadDB::getRandomString(), DIALOG_OK, false); deathNotice->addActionListener(&deathListener); - if (player_node->getCurrentAction() != Being::DEAD) + if (player_node->getCurrentAction() != BeingAction::DEAD) { - player_node->setAction(Being::DEAD, 0); + player_node->setAction(BeingAction::DEAD, 0); player_node->recalcSpritesOrder(); } } diff --git a/src/net/eathena/beinghandler.cpp b/src/net/eathena/beinghandler.cpp index efa22e490..a6716a661 100644 --- a/src/net/eathena/beinghandler.cpp +++ b/src/net/eathena/beinghandler.cpp @@ -544,8 +544,8 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, dstBeing->setDirectionDelayed(static_cast(d)); } - if (player_node->getCurrentAction() != Being::STAND) - player_node->imitateAction(dstBeing, Being::STAND); + if (player_node->getCurrentAction() != BeingAction::STAND) + player_node->imitateAction(dstBeing, BeingAction::STAND); if (player_node->getDirection() != dstBeing->getDirection()) { player_node->imitateDirection(dstBeing, @@ -573,21 +573,21 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, switch (type) { case 0: - dstBeing->setAction(Being::STAND, 0); - player_node->imitateAction(dstBeing, Being::STAND); + dstBeing->setAction(BeingAction::STAND, 0); + player_node->imitateAction(dstBeing, BeingAction::STAND); break; case 1: - if (dstBeing->getCurrentAction() != Being::DEAD) + if (dstBeing->getCurrentAction() != BeingAction::DEAD) { - dstBeing->setAction(Being::DEAD, 0); + dstBeing->setAction(BeingAction::DEAD, 0); dstBeing->recalcSpritesOrder(); } break; case 2: - dstBeing->setAction(Being::SIT, 0); - player_node->imitateAction(dstBeing, Being::SIT); + dstBeing->setAction(BeingAction::SIT, 0); + player_node->imitateAction(dstBeing, BeingAction::SIT); break; default: @@ -690,13 +690,13 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, if (spawnId) { - dstBeing->setAction(Being::SPAWN, 0); + dstBeing->setAction(BeingAction::SPAWN, 0); } else if (visible) { dstBeing->clearPath(); dstBeing->setActionTime(tick_time); - dstBeing->setAction(Being::STAND, 0); + dstBeing->setAction(BeingAction::STAND, 0); } // Prevent division by 0 when calculating frame @@ -776,7 +776,7 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, { uint16_t srcX, srcY, dstX, dstY; msg.readCoordinatePair(srcX, srcY, dstX, dstY); - dstBeing->setAction(Being::STAND, 0); + dstBeing->setAction(BeingAction::STAND, 0); dstBeing->setTileCoords(srcX, srcY); dstBeing->setDestination(dstX, dstY); } diff --git a/src/net/eathena/playerhandler.cpp b/src/net/eathena/playerhandler.cpp index 627e5479f..17c8a6a41 100644 --- a/src/net/eathena/playerhandler.cpp +++ b/src/net/eathena/playerhandler.cpp @@ -183,23 +183,23 @@ void PlayerHandler::setDestination(const int x, const int y, static_cast(direction)); } -void PlayerHandler::changeAction(const Being::Action &action) const +void PlayerHandler::changeAction(const BeingAction::Action &action) const { unsigned char type; switch (action) { - case Being::SIT: + case BeingAction::SIT: type = 2; break; - case Being::STAND: + case BeingAction::STAND: type = 3; break; default: - case Being::MOVE: - case Being::ATTACK: - case Being::DEAD: - case Being::HURT: - case Being::SPAWN: + case BeingAction::MOVE: + case BeingAction::ATTACK: + case BeingAction::DEAD: + case BeingAction::HURT: + case BeingAction::SPAWN: return; } diff --git a/src/net/eathena/playerhandler.h b/src/net/eathena/playerhandler.h index 087c42973..3881150cb 100644 --- a/src/net/eathena/playerhandler.h +++ b/src/net/eathena/playerhandler.h @@ -50,7 +50,8 @@ class PlayerHandler final : public MessageHandler, public Ea::PlayerHandler void setDirection(const unsigned char direction) const override final; void setDestination(const int x, const int y, const int direction) const override final; - void changeAction(const Being::Action &action) const override final; + void changeAction(const BeingAction::Action &action) + const override final; void updateStatus(const uint8_t status) const override final; static void processPlayerShortcuts(Net::MessageIn &msg); diff --git a/src/net/playerhandler.h b/src/net/playerhandler.h index fcb853198..de1314ddb 100644 --- a/src/net/playerhandler.h +++ b/src/net/playerhandler.h @@ -56,7 +56,7 @@ class PlayerHandler virtual void setDestination(const int x, const int y, const int direction) const = 0; - virtual void changeAction(const Being::Action &action) const = 0; + virtual void changeAction(const BeingAction::Action &action) const = 0; virtual void respawn() const = 0; diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp index cd3a2cc15..314f9ee49 100644 --- a/src/net/tmwa/beinghandler.cpp +++ b/src/net/tmwa/beinghandler.cpp @@ -567,8 +567,8 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, dstBeing->setDirectionDelayed(static_cast(d)); } - if (player_node->getCurrentAction() != Being::STAND) - player_node->imitateAction(dstBeing, Being::STAND); + if (player_node->getCurrentAction() != BeingAction::STAND) + player_node->imitateAction(dstBeing, BeingAction::STAND); if (player_node->getDirection() != dstBeing->getDirection()) { player_node->imitateDirection(dstBeing, @@ -597,21 +597,21 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, switch (type) { case 0: - dstBeing->setAction(Being::STAND, 0); - player_node->imitateAction(dstBeing, Being::STAND); + dstBeing->setAction(BeingAction::STAND, 0); + player_node->imitateAction(dstBeing, BeingAction::STAND); break; case 1: - if (dstBeing->getCurrentAction() != Being::DEAD) + if (dstBeing->getCurrentAction() != BeingAction::DEAD) { - dstBeing->setAction(Being::DEAD, 0); + dstBeing->setAction(BeingAction::DEAD, 0); dstBeing->recalcSpritesOrder(); } break; case 2: - dstBeing->setAction(Being::SIT, 0); - player_node->imitateAction(dstBeing, Being::SIT); + dstBeing->setAction(BeingAction::SIT, 0); + player_node->imitateAction(dstBeing, BeingAction::SIT); break; default: diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp index f9a8580df..550d0e89d 100644 --- a/src/net/tmwa/playerhandler.cpp +++ b/src/net/tmwa/playerhandler.cpp @@ -201,23 +201,23 @@ void PlayerHandler::setDestination(const int x, const int y, static_cast(direction)); } -void PlayerHandler::changeAction(const Being::Action &action) const +void PlayerHandler::changeAction(const BeingAction::Action &action) const { char type; switch (action) { - case Being::SIT: + case BeingAction::SIT: type = 2; break; - case Being::STAND: + case BeingAction::STAND: type = 3; break; default: - case Being::MOVE: - case Being::ATTACK: - case Being::DEAD: - case Being::HURT: - case Being::SPAWN: + case BeingAction::MOVE: + case BeingAction::ATTACK: + case BeingAction::DEAD: + case BeingAction::HURT: + case BeingAction::SPAWN: return; } diff --git a/src/net/tmwa/playerhandler.h b/src/net/tmwa/playerhandler.h index 125eea0ba..83dacf0ae 100644 --- a/src/net/tmwa/playerhandler.h +++ b/src/net/tmwa/playerhandler.h @@ -50,7 +50,8 @@ class PlayerHandler final : public MessageHandler, public Ea::PlayerHandler void setDirection(const unsigned char direction) const override final; void setDestination(const int x, const int y, const int direction) const override final; - void changeAction(const Being::Action &action) const override final; + void changeAction(const BeingAction::Action &action) + const override final; static void processOnlineList(Net::MessageIn &msg); void requestOnlineList() const override final; void updateStatus(const uint8_t status) const override final; -- cgit v1.2.3-70-g09d2