summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-09-10 14:13:50 +0300
committerAndrei Karas <akaras@inbox.ru>2014-09-10 14:13:50 +0300
commit279ebfc0831051375d8b7cc2b8bf4f60a19397c9 (patch)
tree934387899184b1800282730337fa1c938822a9f7 /src
parente16fca5b58bbe867b63050e880ba8c156c6fe268 (diff)
downloadplus-279ebfc0831051375d8b7cc2b8bf4f60a19397c9.tar.gz
plus-279ebfc0831051375d8b7cc2b8bf4f60a19397c9.tar.bz2
plus-279ebfc0831051375d8b7cc2b8bf4f60a19397c9.tar.xz
plus-279ebfc0831051375d8b7cc2b8bf4f60a19397c9.zip
add function to apply being action.
Diffstat (limited to 'src')
-rw-r--r--src/net/eathena/beinghandler.cpp92
-rw-r--r--src/net/eathena/beinghandler.h3
-rw-r--r--src/net/tmwa/beinghandler.cpp97
-rw-r--r--src/net/tmwa/beinghandler.h3
4 files changed, 72 insertions, 123 deletions
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<int>(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<int>(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
diff --git a/src/net/eathena/beinghandler.h b/src/net/eathena/beinghandler.h
index 3b2760c07..18c95be45 100644
--- a/src/net/eathena/beinghandler.h
+++ b/src/net/eathena/beinghandler.h
@@ -89,6 +89,9 @@ class BeingHandler final : public MessageHandler, public Ea::BeingHandler
static void setServerGender(Being *const being,
const uint8_t gender);
+
+ static void applyPlayerAction(Being *const being,
+ const uint8_t type);
};
} // namespace EAthena
diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp
index 2768cd3e1..ee431acbe 100644
--- a/src/net/tmwa/beinghandler.cpp
+++ b/src/net/tmwa/beinghandler.cpp
@@ -599,38 +599,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 stand 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<int>(msg.readUInt8("level"));
if (level)
dstBeing->setLevel(level);
@@ -781,38 +750,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 stand 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<int>(msg.readUInt8("level"));
if (level)
dstBeing->setLevel(level);
@@ -1585,4 +1523,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 TmwAthena
diff --git a/src/net/tmwa/beinghandler.h b/src/net/tmwa/beinghandler.h
index 841f1e14c..755447175 100644
--- a/src/net/tmwa/beinghandler.h
+++ b/src/net/tmwa/beinghandler.h
@@ -81,6 +81,9 @@ class BeingHandler final : public MessageHandler, public Ea::BeingHandler
static void setServerGender(Being *const being,
const uint8_t gender);
+
+ static void applyPlayerAction(Being *const being,
+ const uint8_t type);
};
} // namespace TmwAthena