summaryrefslogtreecommitdiff
path: root/src/net/eathena
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-09-10 13:46:44 +0300
committerAndrei Karas <akaras@inbox.ru>2014-09-10 13:46:44 +0300
commitbe02f2d6d4a9afdcd2d46570cbeb97b73cc33526 (patch)
tree4da010fdbe31034eefd2d15859a9e09ed0a042cc /src/net/eathena
parent371445d133f3a1816430a9a2b38a017a959f2a0c (diff)
downloadmanaplus-be02f2d6d4a9afdcd2d46570cbeb97b73cc33526.tar.gz
manaplus-be02f2d6d4a9afdcd2d46570cbeb97b73cc33526.tar.bz2
manaplus-be02f2d6d4a9afdcd2d46570cbeb97b73cc33526.tar.xz
manaplus-be02f2d6d4a9afdcd2d46570cbeb97b73cc33526.zip
Improve functions from previous commit.
Diffstat (limited to 'src/net/eathena')
-rw-r--r--src/net/eathena/beinghandler.cpp367
1 files changed, 83 insertions, 284 deletions
diff --git a/src/net/eathena/beinghandler.cpp b/src/net/eathena/beinghandler.cpp
index eb5bf4b41..a178a244b 100644
--- a/src/net/eathena/beinghandler.cpp
+++ b/src/net/eathena/beinghandler.cpp
@@ -457,22 +457,6 @@ void BeingHandler::processPlayerUpdate1(Net::MessageIn &msg) const
if (!actorManager || !localPlayer)
return;
- int msgType;
- switch (msg.getId())
- {
- case SMSG_PLAYER_UPDATE_1:
- msgType = 1;
- break;
- case SMSG_PLAYER_UPDATE_2:
- msgType = 2;
- break;
- case SMSG_PLAYER_MOVE:
- msgType = 3;
- break;
- default:
- return;
- }
-
// An update about a player, potentially including movement.
const int id = msg.readInt32("account id");
const int16_t speed = msg.readInt16("speed");
@@ -523,10 +507,6 @@ void BeingHandler::processPlayerUpdate1(Net::MessageIn &msg) const
const uint16_t weapon = msg.readInt16("weapon");
const uint16_t shield = msg.readInt16("shield");
const uint16_t headBottom = msg.readInt16("head bottom");
-
- if (msgType == 3)
- msg.readInt32("tick");
-
const uint16_t headTop = msg.readInt16("head top");
const uint16_t headMid = msg.readInt16("head mid");
const int hairColor = msg.readInt16("hair color");
@@ -567,86 +547,46 @@ void BeingHandler::processPlayerUpdate1(Net::MessageIn &msg) const
}
localPlayer->imitateOutfit(dstBeing);
- if (msgType == 3)
- {
- uint16_t srcX, srcY, dstX, dstY;
- msg.readCoordinatePair(srcX, srcY, dstX, dstY, "move path");
- msg.readUInt8("(sx<<4) | (sy&0x0f)");
-
- localPlayer->followMoveTo(dstBeing, srcX, srcY, dstX, dstY);
-
- dstBeing->setTileCoords(srcX, srcY);
- dstBeing->setDestination(dstX, dstY);
-
- // because server don't send direction in move packet,
- // we fixing it
-
- if (srcX != dstX || srcY != dstY)
- {
- const int d = dstBeing->calcDirection(dstX, dstY);
-
- if (d && dstBeing->getDirection() != d)
- dstBeing->setDirectionDelayed(static_cast<uint8_t>(d));
- }
+ uint16_t x, y;
+ msg.readCoordinates(x, y, dir, "position");
+ dstBeing->setTileCoords(x, y);
+ dstBeing->setDirection(dir);
- if (localPlayer->getCurrentAction() != BeingAction::STAND)
- localPlayer->imitateAction(dstBeing, BeingAction::STAND);
- if (localPlayer->getDirection() != dstBeing->getDirection())
- {
- localPlayer->imitateDirection(dstBeing,
- dstBeing->getDirection());
- }
- }
- else
- {
- uint16_t x, y;
- msg.readCoordinates(x, y, dir, "position");
- dstBeing->setTileCoords(x, y);
- dstBeing->setDirection(dir);
-
- localPlayer->imitateDirection(dstBeing, dir);
- }
+ localPlayer->imitateDirection(dstBeing, dir);
const uint16_t gmstatus = msg.readInt16("gm status");
if (gmstatus & 0x80)
dstBeing->setGM(true);
- if (msgType == 1 || msgType == 2)
+ const uint8_t type = msg.readUInt8("action type");
+ switch (type)
{
- const uint8_t type = msg.readUInt8("action type");
- switch (type)
- {
- case 0:
- dstBeing->setAction(BeingAction::STAND, 0);
- localPlayer->imitateAction(dstBeing, BeingAction::STAND);
- break;
+ 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 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;
+ 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;
- }
- }
- else if (msgType == 3)
- {
- msg.readUInt8("unknown?");
+ 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;
}
const int level = static_cast<int>(msg.readUInt8("level"));
@@ -656,20 +596,13 @@ void BeingHandler::processPlayerUpdate1(Net::MessageIn &msg) const
msg.readUInt8("unknown");
- if (dstBeing->getType() != ActorType::PLAYER
- || msgType != 3)
- {
- dstBeing->setActionTime(tick_time);
- }
+ dstBeing->setActionTime(tick_time);
dstBeing->setStunMode(stunMode);
dstBeing->setStatusEffectBlock(0, static_cast<uint16_t>(
(statusEffects >> 16) & 0xffffU));
dstBeing->setStatusEffectBlock(16, static_cast<uint16_t>(
statusEffects & 0xffffU));
-
- if (msgType == 3 && dstBeing->getType() == ActorType::PLAYER)
- dstBeing->setMoveTime();
}
void BeingHandler::processPlayerUpdate2(Net::MessageIn &msg) const
@@ -677,22 +610,6 @@ void BeingHandler::processPlayerUpdate2(Net::MessageIn &msg) const
if (!actorManager || !localPlayer)
return;
- int msgType;
- switch (msg.getId())
- {
- case SMSG_PLAYER_UPDATE_1:
- msgType = 1;
- break;
- case SMSG_PLAYER_UPDATE_2:
- msgType = 2;
- break;
- case SMSG_PLAYER_MOVE:
- msgType = 3;
- break;
- default:
- return;
- }
-
// An update about a player, potentially including movement.
const int id = msg.readInt32("account id");
const int16_t speed = msg.readInt16("speed");
@@ -744,9 +661,6 @@ void BeingHandler::processPlayerUpdate2(Net::MessageIn &msg) const
const uint16_t shield = msg.readInt16("shield");
const uint16_t headBottom = msg.readInt16("head bottom");
- if (msgType == 3)
- msg.readInt32("tick");
-
const uint16_t headTop = msg.readInt16("head top");
const uint16_t headMid = msg.readInt16("head mid");
const int hairColor = msg.readInt16("hair color");
@@ -787,86 +701,46 @@ void BeingHandler::processPlayerUpdate2(Net::MessageIn &msg) const
}
localPlayer->imitateOutfit(dstBeing);
- if (msgType == 3)
- {
- uint16_t srcX, srcY, dstX, dstY;
- msg.readCoordinatePair(srcX, srcY, dstX, dstY, "move path");
- msg.readUInt8("(sx<<4) | (sy&0x0f)");
-
- localPlayer->followMoveTo(dstBeing, srcX, srcY, dstX, dstY);
-
- dstBeing->setTileCoords(srcX, srcY);
- dstBeing->setDestination(dstX, dstY);
-
- // because server don't send direction in move packet,
- // we fixing it
-
- if (srcX != dstX || srcY != dstY)
- {
- const int d = dstBeing->calcDirection(dstX, dstY);
-
- if (d && dstBeing->getDirection() != d)
- dstBeing->setDirectionDelayed(static_cast<uint8_t>(d));
- }
-
- if (localPlayer->getCurrentAction() != BeingAction::STAND)
- localPlayer->imitateAction(dstBeing, BeingAction::STAND);
- if (localPlayer->getDirection() != dstBeing->getDirection())
- {
- localPlayer->imitateDirection(dstBeing,
- dstBeing->getDirection());
- }
- }
- else
- {
- uint16_t x, y;
- msg.readCoordinates(x, y, dir, "position");
- dstBeing->setTileCoords(x, y);
- dstBeing->setDirection(dir);
+ uint16_t x, y;
+ msg.readCoordinates(x, y, dir, "position");
+ dstBeing->setTileCoords(x, y);
+ dstBeing->setDirection(dir);
- localPlayer->imitateDirection(dstBeing, dir);
- }
+ localPlayer->imitateDirection(dstBeing, dir);
const uint16_t gmstatus = msg.readInt16("gm status");
if (gmstatus & 0x80)
dstBeing->setGM(true);
- if (msgType == 1 || msgType == 2)
+ const uint8_t type = msg.readUInt8("action type");
+ switch (type)
{
- const uint8_t type = msg.readUInt8("action type");
- switch (type)
- {
- case 0:
- dstBeing->setAction(BeingAction::STAND, 0);
- localPlayer->imitateAction(dstBeing, BeingAction::STAND);
- break;
+ 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 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;
+ 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;
- }
- }
- else if (msgType == 3)
- {
- msg.readUInt8("unknown?");
+ 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;
}
const int level = static_cast<int>(msg.readUInt8("level"));
@@ -876,20 +750,12 @@ void BeingHandler::processPlayerUpdate2(Net::MessageIn &msg) const
msg.readUInt8("unknown");
- if (dstBeing->getType() != ActorType::PLAYER
- || msgType != 3)
- {
- dstBeing->setActionTime(tick_time);
- }
-
+ dstBeing->setActionTime(tick_time);
dstBeing->setStunMode(stunMode);
dstBeing->setStatusEffectBlock(0, static_cast<uint16_t>(
(statusEffects >> 16) & 0xffffU));
dstBeing->setStatusEffectBlock(16, static_cast<uint16_t>(
statusEffects & 0xffffU));
-
- if (msgType == 3 && dstBeing->getType() == ActorType::PLAYER)
- dstBeing->setMoveTime();
}
void BeingHandler::processPlayerMove(Net::MessageIn &msg) const
@@ -897,22 +763,6 @@ void BeingHandler::processPlayerMove(Net::MessageIn &msg) const
if (!actorManager || !localPlayer)
return;
- int msgType;
- switch (msg.getId())
- {
- case SMSG_PLAYER_UPDATE_1:
- msgType = 1;
- break;
- case SMSG_PLAYER_UPDATE_2:
- msgType = 2;
- break;
- case SMSG_PLAYER_MOVE:
- msgType = 3;
- break;
- default:
- return;
- }
-
// An update about a player, potentially including movement.
const int id = msg.readInt32("account id");
const int16_t speed = msg.readInt16("speed");
@@ -964,8 +814,7 @@ void BeingHandler::processPlayerMove(Net::MessageIn &msg) const
const uint16_t shield = msg.readInt16("shield");
const uint16_t headBottom = msg.readInt16("head bottom");
- if (msgType == 3)
- msg.readInt32("tick");
+ msg.readInt32("tick");
const uint16_t headTop = msg.readInt16("head top");
const uint16_t headMid = msg.readInt16("head mid");
@@ -1007,44 +856,32 @@ void BeingHandler::processPlayerMove(Net::MessageIn &msg) const
}
localPlayer->imitateOutfit(dstBeing);
- if (msgType == 3)
- {
- uint16_t srcX, srcY, dstX, dstY;
- msg.readCoordinatePair(srcX, srcY, dstX, dstY, "move path");
- msg.readUInt8("(sx<<4) | (sy&0x0f)");
-
- localPlayer->followMoveTo(dstBeing, srcX, srcY, dstX, dstY);
+ uint16_t srcX, srcY, dstX, dstY;
+ msg.readCoordinatePair(srcX, srcY, dstX, dstY, "move path");
+ msg.readUInt8("(sx<<4) | (sy&0x0f)");
- dstBeing->setTileCoords(srcX, srcY);
- dstBeing->setDestination(dstX, dstY);
+ localPlayer->followMoveTo(dstBeing, srcX, srcY, dstX, dstY);
- // because server don't send direction in move packet,
- // we fixing it
+ dstBeing->setTileCoords(srcX, srcY);
+ dstBeing->setDestination(dstX, dstY);
- if (srcX != dstX || srcY != dstY)
- {
- const int d = dstBeing->calcDirection(dstX, dstY);
+ // because server don't send direction in move packet,
+ // we fixing it
- if (d && dstBeing->getDirection() != d)
- dstBeing->setDirectionDelayed(static_cast<uint8_t>(d));
- }
+ if (srcX != dstX || srcY != dstY)
+ {
+ const int d = dstBeing->calcDirection(dstX, dstY);
- if (localPlayer->getCurrentAction() != BeingAction::STAND)
- localPlayer->imitateAction(dstBeing, BeingAction::STAND);
- if (localPlayer->getDirection() != dstBeing->getDirection())
- {
- localPlayer->imitateDirection(dstBeing,
- dstBeing->getDirection());
- }
+ if (d && dstBeing->getDirection() != d)
+ dstBeing->setDirectionDelayed(static_cast<uint8_t>(d));
}
- else
- {
- uint16_t x, y;
- msg.readCoordinates(x, y, dir, "position");
- dstBeing->setTileCoords(x, y);
- dstBeing->setDirection(dir);
- localPlayer->imitateDirection(dstBeing, dir);
+ if (localPlayer->getCurrentAction() != BeingAction::STAND)
+ localPlayer->imitateAction(dstBeing, BeingAction::STAND);
+ if (localPlayer->getDirection() != dstBeing->getDirection())
+ {
+ localPlayer->imitateDirection(dstBeing,
+ dstBeing->getDirection());
}
const uint16_t gmstatus = msg.readInt16("gm status");
@@ -1052,42 +889,7 @@ void BeingHandler::processPlayerMove(Net::MessageIn &msg) const
if (gmstatus & 0x80)
dstBeing->setGM(true);
- if (msgType == 1 || msgType == 2)
- {
- 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;
- }
- }
- else if (msgType == 3)
- {
- msg.readUInt8("unknown?");
- }
+ msg.readUInt8("unknown?");
const int level = static_cast<int>(msg.readUInt8("level"));
@@ -1096,11 +898,8 @@ void BeingHandler::processPlayerMove(Net::MessageIn &msg) const
msg.readUInt8("unknown");
- if (dstBeing->getType() != ActorType::PLAYER
- || msgType != 3)
- {
+ if (dstBeing->getType() != ActorType::PLAYER)
dstBeing->setActionTime(tick_time);
- }
dstBeing->setStunMode(stunMode);
dstBeing->setStatusEffectBlock(0, static_cast<uint16_t>(
@@ -1108,7 +907,7 @@ void BeingHandler::processPlayerMove(Net::MessageIn &msg) const
dstBeing->setStatusEffectBlock(16, static_cast<uint16_t>(
statusEffects & 0xffffU));
- if (msgType == 3 && dstBeing->getType() == ActorType::PLAYER)
+ if (dstBeing->getType() == ActorType::PLAYER)
dstBeing->setMoveTime();
}