summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-02-24 22:25:30 +0300
committerAndrei Karas <akaras@inbox.ru>2015-02-24 22:25:30 +0300
commitc551238526f12f0c28bf44bc131c7e95d675b61d (patch)
tree116cb5d1e9aa796c57e627e3614ae60e2f09e605 /src/net
parentc657038680882389f5ba6e3d138b2cb11578092b (diff)
downloadmanaplus-c551238526f12f0c28bf44bc131c7e95d675b61d.tar.gz
manaplus-c551238526f12f0c28bf44bc131c7e95d675b61d.tar.bz2
manaplus-c551238526f12f0c28bf44bc131c7e95d675b61d.tar.xz
manaplus-c551238526f12f0c28bf44bc131c7e95d675b61d.zip
Read whole bytes from packet SMSG_NPC_COMMAND.
Diffstat (limited to 'src/net')
-rw-r--r--src/net/ea/npchandler.cpp18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/net/ea/npchandler.cpp b/src/net/ea/npchandler.cpp
index d35cc5d60..40c6b5256 100644
--- a/src/net/ea/npchandler.cpp
+++ b/src/net/ea/npchandler.cpp
@@ -122,6 +122,9 @@ void NpcHandler::processNpcCommand(Net::MessageIn &msg)
mRequestLang = false;
const int cmd = msg.readInt16("cmd");
+ const int id = msg.readInt32("id");
+ const int x = msg.readInt16("x");
+ const int y = msg.readInt16("y");
switch (cmd)
{
case 0:
@@ -136,9 +139,6 @@ void NpcHandler::processNpcCommand(Net::MessageIn &msg)
case 2:
if (viewport)
{
- const int id = msg.readInt32("id");
- const int x = msg.readInt16("x");
- const int y = msg.readInt16("y");
if (!id)
viewport->moveCameraToPosition(x, y);
else
@@ -154,9 +154,6 @@ void NpcHandler::processNpcCommand(Net::MessageIn &msg)
case 4:
if (viewport)
{
- msg.readInt32("id");
- const int x = msg.readInt16("x");
- const int y = msg.readInt16("y");
viewport->moveCameraRelative(x, y);
}
break;
@@ -168,8 +165,7 @@ void NpcHandler::processNpcCommand(Net::MessageIn &msg)
case 6: // show avatar
if (mDialog)
{
- mDialog->showAvatar(static_cast<uint16_t>(
- msg.readInt32("avatar id")));
+ mDialog->showAvatar(static_cast<uint16_t>(id));
}
break;
case 7: // set avatar direction
@@ -177,12 +173,12 @@ void NpcHandler::processNpcCommand(Net::MessageIn &msg)
{
mDialog->setAvatarDirection(
Net::MessageIn::fromServerDirection(
- static_cast<uint8_t>(msg.readInt32("avatar direction"))));
+ static_cast<uint8_t>(id)));
}
break;
case 8: // set avatar action
if (mDialog)
- mDialog->setAvatarAction(msg.readInt32("avatar action"));
+ mDialog->setAvatarAction(id);
break;
case 9: // clear npc dialog
if (mDialog)
@@ -190,7 +186,7 @@ void NpcHandler::processNpcCommand(Net::MessageIn &msg)
break;
case 10: // send selected item id
{
- int invSize = msg.readInt32("npc inventory size");
+ int invSize = id;
if (!invSize)
invSize = 1;
if (mDialog)