From c551238526f12f0c28bf44bc131c7e95d675b61d Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 24 Feb 2015 22:25:30 +0300 Subject: Read whole bytes from packet SMSG_NPC_COMMAND. --- src/net/ea/npchandler.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'src') 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( - msg.readInt32("avatar id"))); + mDialog->showAvatar(static_cast(id)); } break; case 7: // set avatar direction @@ -177,12 +173,12 @@ void NpcHandler::processNpcCommand(Net::MessageIn &msg) { mDialog->setAvatarDirection( Net::MessageIn::fromServerDirection( - static_cast(msg.readInt32("avatar direction")))); + static_cast(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) -- cgit v1.2.3-60-g2f50