summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-09-10 12:28:01 +0300
committerAndrei Karas <akaras@inbox.ru>2014-09-10 12:28:01 +0300
commit1a2147b4970a7aab6e610e0cd83ec29a47579e80 (patch)
tree9d79afaab37e01086ca0bb26677ea704a92f5165
parentbc821a0388e887ad8585ea162a1e8e67b691ce56 (diff)
downloadplus-1a2147b4970a7aab6e610e0cd83ec29a47579e80.tar.gz
plus-1a2147b4970a7aab6e610e0cd83ec29a47579e80.tar.bz2
plus-1a2147b4970a7aab6e610e0cd83ec29a47579e80.tar.xz
plus-1a2147b4970a7aab6e610e0cd83ec29a47579e80.zip
Improve functions from previous commit.
-rw-r--r--src/net/eathena/beinghandler.cpp325
-rw-r--r--src/net/tmwa/beinghandler.cpp101
2 files changed, 95 insertions, 331 deletions
diff --git a/src/net/eathena/beinghandler.cpp b/src/net/eathena/beinghandler.cpp
index f763f2c05..82a40ee78 100644
--- a/src/net/eathena/beinghandler.cpp
+++ b/src/net/eathena/beinghandler.cpp
@@ -668,45 +668,23 @@ void BeingHandler::processBeingVisible(Net::MessageIn &msg)
if (!actorManager)
return;
- const bool visible = msg.getId() == SMSG_BEING_VISIBLE;
- const bool spawn = msg.getId() == SMSG_BEING_SPAWN;
-
msg.readInt16("len");
msg.readUInt8("object type");
// Information about a being in range
const int id = msg.readInt32("being id");
int spawnId;
- if (spawn)
- {
- mSpawnId = id;
- spawnId = id;
- }
+ if (id == mSpawnId)
+ spawnId = mSpawnId;
else
- {
- if (id == mSpawnId)
- spawnId = mSpawnId;
- else
- spawnId = 0;
- mSpawnId = 0;
- }
+ spawnId = 0;
+ mSpawnId = 0;
+
int16_t speed = msg.readInt16("speed");
-// if (visible)
-// {
- const uint16_t stunMode = msg.readInt16("opt1");
- // probably wrong effect usage
- uint32_t statusEffects = msg.readInt16("opt2");
-// }
-// else
-// {
-// commented for now, probably it can be removed after testing
-// msg.readInt16("body state");
-// msg.readInt16("health state");
-// }
- if (visible)
- msg.readInt32("option");
- else
- msg.readInt32("effect state");
+ const uint16_t stunMode = msg.readInt16("opt1");
+ // probably wrong effect usage
+ uint32_t statusEffects = msg.readInt16("opt2");
+ msg.readInt32("option");
const int16_t job = msg.readInt16("class");
@@ -752,7 +730,7 @@ void BeingHandler::processBeingVisible(Net::MessageIn &msg)
{
dstBeing->setAction(BeingAction::SPAWN, 0);
}
- else if (visible)
+ else
{
dstBeing->clearPath();
dstBeing->setActionTime(tick_time);
@@ -772,9 +750,6 @@ void BeingHandler::processBeingVisible(Net::MessageIn &msg)
const uint32_t weapon = static_cast<uint32_t>(msg.readInt32("weapon"));
const uint16_t headBottom = msg.readInt16("head bottom");
- if (!visible && !spawn)
- 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");
@@ -825,66 +800,29 @@ void BeingHandler::processBeingVisible(Net::MessageIn &msg)
}
}
- if (!visible && !spawn)
- {
- uint16_t srcX, srcY, dstX, dstY;
- msg.readCoordinatePair(srcX, srcY, dstX, dstY, "move path");
- msg.readUInt8("(sx<<4) | (sy&0x0f)");
- msg.readInt8("xs");
- msg.readInt8("ys");
- dstBeing->setAction(BeingAction::STAND, 0);
- dstBeing->setTileCoords(srcX, srcY);
- dstBeing->setDestination(dstX, dstY);
-
- // because server don't send direction in move packet,
- // we fixing it
+ uint8_t dir;
+ uint16_t x, y;
+ msg.readCoordinates(x, y, dir, "position");
+ msg.readInt8("xs");
+ msg.readInt8("ys");
+ msg.readUInt8("action type");
+ dstBeing->setTileCoords(x, y);
- int d = 0;
- if (srcX == dstX && srcY == dstY)
- { // if player did one step from invisible area to visible,
- //move path is broken
- int x2 = localPlayer->getTileX();
- int y2 = localPlayer->getTileY();
- if (abs(x2 - srcX) > abs(y2 - srcY))
- y2 = srcY;
- else
- x2 = srcX;
- d = dstBeing->calcDirection(x2, y2);
+ if (job == 45 && socialWindow && outfitWindow)
+ {
+ const int num = socialWindow->getPortalIndex(x, y);
+ if (num >= 0)
+ {
+ dstBeing->setName(keyboard.getKeyShortString(
+ outfitWindow->keyName(num)));
}
else
{
- d = dstBeing->calcDirection(dstX, dstY);
+ dstBeing->setName("");
}
- if (d && dstBeing->getDirection() != d)
- dstBeing->setDirection(d);
}
- else
- {
- uint8_t dir;
- uint16_t x, y;
- msg.readCoordinates(x, y, dir, "position");
- msg.readInt8("xs");
- msg.readInt8("ys");
- if (visible)
- msg.readUInt8("action type");
- dstBeing->setTileCoords(x, y);
-
- if (job == 45 && socialWindow && outfitWindow)
- {
- const int num = socialWindow->getPortalIndex(x, y);
- if (num >= 0)
- {
- dstBeing->setName(keyboard.getKeyShortString(
- outfitWindow->keyName(num)));
- }
- else
- {
- dstBeing->setName("");
- }
- }
- dstBeing->setDirection(dir);
- }
+ dstBeing->setDirection(dir);
const int level = static_cast<int>(msg.readInt16("level"));
if (level)
@@ -905,28 +843,17 @@ void BeingHandler::processBeingMove(Net::MessageIn &msg)
if (!actorManager)
return;
- const bool visible = msg.getId() == SMSG_BEING_VISIBLE;
- const bool spawn = msg.getId() == SMSG_BEING_SPAWN;
-
msg.readInt16("len");
msg.readUInt8("object type");
// Information about a being in range
const int id = msg.readInt32("being id");
int spawnId;
- if (spawn)
- {
- mSpawnId = id;
- spawnId = id;
- }
+ if (id == mSpawnId)
+ spawnId = mSpawnId;
else
- {
- if (id == mSpawnId)
- spawnId = mSpawnId;
- else
- spawnId = 0;
- mSpawnId = 0;
- }
+ spawnId = 0;
+ mSpawnId = 0;
int16_t speed = msg.readInt16("speed");
// if (visible)
// {
@@ -940,10 +867,7 @@ void BeingHandler::processBeingMove(Net::MessageIn &msg)
// msg.readInt16("body state");
// msg.readInt16("health state");
// }
- if (visible)
- msg.readInt32("option");
- else
- msg.readInt32("effect state");
+ msg.readInt32("effect state");
const int16_t job = msg.readInt16("class");
@@ -986,15 +910,7 @@ void BeingHandler::processBeingMove(Net::MessageIn &msg)
dstBeing->setMoveTime();
if (spawnId)
- {
dstBeing->setAction(BeingAction::SPAWN, 0);
- }
- else if (visible)
- {
- dstBeing->clearPath();
- dstBeing->setActionTime(tick_time);
- dstBeing->setAction(BeingAction::STAND, 0);
- }
// Prevent division by 0 when calculating frame
if (speed == 0)
@@ -1009,8 +925,7 @@ void BeingHandler::processBeingMove(Net::MessageIn &msg)
const uint32_t weapon = static_cast<uint32_t>(msg.readInt32("weapon"));
const uint16_t headBottom = msg.readInt16("head bottom");
- if (!visible && !spawn)
- msg.readInt32("tick");
+ msg.readInt32("tick");
const uint16_t headTop = msg.readInt16("head top");
const uint16_t headMid = msg.readInt16("head mid");
@@ -1062,66 +977,35 @@ void BeingHandler::processBeingMove(Net::MessageIn &msg)
}
}
- if (!visible && !spawn)
- {
- uint16_t srcX, srcY, dstX, dstY;
- msg.readCoordinatePair(srcX, srcY, dstX, dstY, "move path");
- msg.readUInt8("(sx<<4) | (sy&0x0f)");
- msg.readInt8("xs");
- msg.readInt8("ys");
- dstBeing->setAction(BeingAction::STAND, 0);
- dstBeing->setTileCoords(srcX, srcY);
- dstBeing->setDestination(dstX, dstY);
+ uint16_t srcX, srcY, dstX, dstY;
+ msg.readCoordinatePair(srcX, srcY, dstX, dstY, "move path");
+ msg.readUInt8("(sx<<4) | (sy&0x0f)");
+ msg.readInt8("xs");
+ msg.readInt8("ys");
+ dstBeing->setAction(BeingAction::STAND, 0);
+ dstBeing->setTileCoords(srcX, srcY);
+ dstBeing->setDestination(dstX, dstY);
- // because server don't send direction in move packet,
- // we fixing it
+ // because server don't send direction in move packet, we fixing it
- int d = 0;
- if (srcX == dstX && srcY == dstY)
- { // if player did one step from invisible area to visible,
- //move path is broken
- int x2 = localPlayer->getTileX();
- int y2 = localPlayer->getTileY();
- if (abs(x2 - srcX) > abs(y2 - srcY))
- y2 = srcY;
- else
- x2 = srcX;
- d = dstBeing->calcDirection(x2, y2);
- }
+ int d = 0;
+ if (srcX == dstX && srcY == dstY)
+ { // if player did one step from invisible area to visible,
+ //move path is broken
+ int x2 = localPlayer->getTileX();
+ int y2 = localPlayer->getTileY();
+ if (abs(x2 - srcX) > abs(y2 - srcY))
+ y2 = srcY;
else
- {
- d = dstBeing->calcDirection(dstX, dstY);
- }
- if (d && dstBeing->getDirection() != d)
- dstBeing->setDirection(d);
+ x2 = srcX;
+ d = dstBeing->calcDirection(x2, y2);
}
else
{
- uint8_t dir;
- uint16_t x, y;
- msg.readCoordinates(x, y, dir, "position");
- msg.readInt8("xs");
- msg.readInt8("ys");
- if (visible)
- msg.readUInt8("action type");
- dstBeing->setTileCoords(x, y);
-
- if (job == 45 && socialWindow && outfitWindow)
- {
- const int num = socialWindow->getPortalIndex(x, y);
- if (num >= 0)
- {
- dstBeing->setName(keyboard.getKeyShortString(
- outfitWindow->keyName(num)));
- }
- else
- {
- dstBeing->setName("");
- }
- }
-
- dstBeing->setDirection(dir);
+ d = dstBeing->calcDirection(dstX, dstY);
}
+ if (d && dstBeing->getDirection() != d)
+ dstBeing->setDirection(d);
const int level = static_cast<int>(msg.readInt16("level"));
if (level)
@@ -1142,28 +1026,13 @@ void BeingHandler::processBeingSpawn(Net::MessageIn &msg)
if (!actorManager)
return;
- const bool visible = msg.getId() == SMSG_BEING_VISIBLE;
- const bool spawn = msg.getId() == SMSG_BEING_SPAWN;
-
msg.readInt16("len");
msg.readUInt8("object type");
// Information about a being in range
const int id = msg.readInt32("being id");
- int spawnId;
- if (spawn)
- {
- mSpawnId = id;
- spawnId = id;
- }
- else
- {
- if (id == mSpawnId)
- spawnId = mSpawnId;
- else
- spawnId = 0;
- mSpawnId = 0;
- }
+ mSpawnId = id;
+ int spawnId = id;
int16_t speed = msg.readInt16("speed");
// if (visible)
// {
@@ -1177,10 +1046,7 @@ void BeingHandler::processBeingSpawn(Net::MessageIn &msg)
// msg.readInt16("body state");
// msg.readInt16("health state");
// }
- if (visible)
- msg.readInt32("option");
- else
- msg.readInt32("effect state");
+ msg.readInt32("effect state");
const int16_t job = msg.readInt16("class");
@@ -1226,12 +1092,6 @@ void BeingHandler::processBeingSpawn(Net::MessageIn &msg)
{
dstBeing->setAction(BeingAction::SPAWN, 0);
}
- else if (visible)
- {
- dstBeing->clearPath();
- dstBeing->setActionTime(tick_time);
- dstBeing->setAction(BeingAction::STAND, 0);
- }
// Prevent division by 0 when calculating frame
if (speed == 0)
@@ -1246,9 +1106,6 @@ void BeingHandler::processBeingSpawn(Net::MessageIn &msg)
const uint32_t weapon = static_cast<uint32_t>(msg.readInt32("weapon"));
const uint16_t headBottom = msg.readInt16("head bottom");
- if (!visible && !spawn)
- 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");
@@ -1299,66 +1156,28 @@ void BeingHandler::processBeingSpawn(Net::MessageIn &msg)
}
}
- if (!visible && !spawn)
- {
- uint16_t srcX, srcY, dstX, dstY;
- msg.readCoordinatePair(srcX, srcY, dstX, dstY, "move path");
- msg.readUInt8("(sx<<4) | (sy&0x0f)");
- msg.readInt8("xs");
- msg.readInt8("ys");
- dstBeing->setAction(BeingAction::STAND, 0);
- dstBeing->setTileCoords(srcX, srcY);
- dstBeing->setDestination(dstX, dstY);
-
- // because server don't send direction in move packet,
- // we fixing it
+ uint8_t dir;
+ uint16_t x, y;
+ msg.readCoordinates(x, y, dir, "position");
+ msg.readInt8("xs");
+ msg.readInt8("ys");
+ dstBeing->setTileCoords(x, y);
- int d = 0;
- if (srcX == dstX && srcY == dstY)
- { // if player did one step from invisible area to visible,
- //move path is broken
- int x2 = localPlayer->getTileX();
- int y2 = localPlayer->getTileY();
- if (abs(x2 - srcX) > abs(y2 - srcY))
- y2 = srcY;
- else
- x2 = srcX;
- d = dstBeing->calcDirection(x2, y2);
+ if (job == 45 && socialWindow && outfitWindow)
+ {
+ const int num = socialWindow->getPortalIndex(x, y);
+ if (num >= 0)
+ {
+ dstBeing->setName(keyboard.getKeyShortString(
+ outfitWindow->keyName(num)));
}
else
{
- d = dstBeing->calcDirection(dstX, dstY);
+ dstBeing->setName("");
}
- if (d && dstBeing->getDirection() != d)
- dstBeing->setDirection(d);
}
- else
- {
- uint8_t dir;
- uint16_t x, y;
- msg.readCoordinates(x, y, dir, "position");
- msg.readInt8("xs");
- msg.readInt8("ys");
- if (visible)
- msg.readUInt8("action type");
- dstBeing->setTileCoords(x, y);
- if (job == 45 && socialWindow && outfitWindow)
- {
- const int num = socialWindow->getPortalIndex(x, y);
- if (num >= 0)
- {
- dstBeing->setName(keyboard.getKeyShortString(
- outfitWindow->keyName(num)));
- }
- else
- {
- dstBeing->setName("");
- }
- }
-
- dstBeing->setDirection(dir);
- }
+ dstBeing->setDirection(dir);
const int level = static_cast<int>(msg.readInt16("level"));
if (level)
diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp
index 6e2dd3ae4..00651e066 100644
--- a/src/net/tmwa/beinghandler.cpp
+++ b/src/net/tmwa/beinghandler.cpp
@@ -757,7 +757,6 @@ void BeingHandler::processBeingVisible(Net::MessageIn &msg)
return;
}
- const bool visible = msg.getId() == SMSG_BEING_VISIBLE;
int spawnId;
// Information about a being in range
@@ -830,7 +829,7 @@ void BeingHandler::processBeingVisible(Net::MessageIn &msg)
{
dstBeing->setAction(BeingAction::SPAWN, 0);
}
- else if (visible)
+ else
{
dstBeing->clearPath();
dstBeing->setActionTime(tick_time);
@@ -850,9 +849,6 @@ void BeingHandler::processBeingVisible(Net::MessageIn &msg)
const uint16_t weapon = msg.readInt16("weapon");
const uint16_t headBottom = msg.readInt16("head bottom");
- if (!visible)
- msg.readInt32("tick");
-
const uint16_t shield = msg.readInt16("shield");
const uint16_t headTop = msg.readInt16("head top");
const uint16_t headMid = msg.readInt16("head mid");
@@ -940,42 +936,27 @@ void BeingHandler::processBeingVisible(Net::MessageIn &msg)
}
}
- if (!visible)
+ uint8_t dir;
+ uint16_t x, y;
+ msg.readCoordinates(x, y, dir, "position");
+ dstBeing->setTileCoords(x, y);
+
+ if (job == 45 && socialWindow && outfitWindow)
{
- uint16_t srcX, srcY, dstX, dstY;
- msg.readCoordinatePair(srcX, srcY, dstX, dstY, "move path");
- if (!disguiseId)
+ const int num = socialWindow->getPortalIndex(x, y);
+ if (num >= 0)
{
- dstBeing->setAction(BeingAction::STAND, 0);
- dstBeing->setTileCoords(srcX, srcY);
- if (serverVersion < 10)
- dstBeing->setDestination(dstX, dstY);
+ dstBeing->setName(keyboard.getKeyShortString(
+ outfitWindow->keyName(num)));
}
- }
- else
- {
- uint8_t dir;
- uint16_t x, y;
- msg.readCoordinates(x, y, dir, "position");
- dstBeing->setTileCoords(x, y);
-
- if (job == 45 && socialWindow && outfitWindow)
+ else
{
- const int num = socialWindow->getPortalIndex(x, y);
- if (num >= 0)
- {
- dstBeing->setName(keyboard.getKeyShortString(
- outfitWindow->keyName(num)));
- }
- else
- {
- dstBeing->setName("");
- }
+ dstBeing->setName("");
}
-
- dstBeing->setDirection(dir);
}
+ dstBeing->setDirection(dir);
+
msg.readUInt8("unknown");
msg.readUInt8("unknown");
msg.readUInt8("unknown");
@@ -999,7 +980,6 @@ void BeingHandler::processBeingMove(Net::MessageIn &msg)
return;
}
- const bool visible = msg.getId() == SMSG_BEING_VISIBLE;
int spawnId;
// Information about a being in range
@@ -1069,15 +1049,7 @@ void BeingHandler::processBeingMove(Net::MessageIn &msg)
dstBeing->setMoveTime();
if (spawnId)
- {
dstBeing->setAction(BeingAction::SPAWN, 0);
- }
- else if (visible)
- {
- dstBeing->clearPath();
- dstBeing->setActionTime(tick_time);
- dstBeing->setAction(BeingAction::STAND, 0);
- }
// Prevent division by 0 when calculating frame
if (speed == 0)
@@ -1092,8 +1064,7 @@ void BeingHandler::processBeingMove(Net::MessageIn &msg)
const uint16_t weapon = msg.readInt16("weapon");
const uint16_t headBottom = msg.readInt16("head bottom");
- if (!visible)
- msg.readInt32("tick");
+ msg.readInt32("tick");
const uint16_t shield = msg.readInt16("shield");
const uint16_t headTop = msg.readInt16("head top");
@@ -1182,40 +1153,14 @@ void BeingHandler::processBeingMove(Net::MessageIn &msg)
}
}
- if (!visible)
- {
- uint16_t srcX, srcY, dstX, dstY;
- msg.readCoordinatePair(srcX, srcY, dstX, dstY, "move path");
- if (!disguiseId)
- {
- dstBeing->setAction(BeingAction::STAND, 0);
- dstBeing->setTileCoords(srcX, srcY);
- if (serverVersion < 10)
- dstBeing->setDestination(dstX, dstY);
- }
- }
- else
+ uint16_t srcX, srcY, dstX, dstY;
+ msg.readCoordinatePair(srcX, srcY, dstX, dstY, "move path");
+ if (!disguiseId)
{
- uint8_t dir;
- uint16_t x, y;
- msg.readCoordinates(x, y, dir, "position");
- dstBeing->setTileCoords(x, y);
-
- if (job == 45 && socialWindow && outfitWindow)
- {
- const int num = socialWindow->getPortalIndex(x, y);
- if (num >= 0)
- {
- dstBeing->setName(keyboard.getKeyShortString(
- outfitWindow->keyName(num)));
- }
- else
- {
- dstBeing->setName("");
- }
- }
-
- dstBeing->setDirection(dir);
+ dstBeing->setAction(BeingAction::STAND, 0);
+ dstBeing->setTileCoords(srcX, srcY);
+ if (serverVersion < 10)
+ dstBeing->setDestination(dstX, dstY);
}
msg.readUInt8("unknown");