summaryrefslogtreecommitdiff
path: root/src/net/ea
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-11-15 00:30:36 +0300
committerAndrei Karas <akaras@inbox.ru>2014-11-15 00:30:36 +0300
commitd08bd96a8358ad9e399e9f7770d5265c81ff0b4e (patch)
tree221d3fb3d5fbcc956f100824643c0974dd0b06cb /src/net/ea
parent17a6ccbd6a52fd4dbf85a8f9ea0e20fc215a41a2 (diff)
downloadplus-d08bd96a8358ad9e399e9f7770d5265c81ff0b4e.tar.gz
plus-d08bd96a8358ad9e399e9f7770d5265c81ff0b4e.tar.bz2
plus-d08bd96a8358ad9e399e9f7770d5265c81ff0b4e.tar.xz
plus-d08bd96a8358ad9e399e9f7770d5265c81ff0b4e.zip
eathena: add packet SMSG_NPC_COMMAND 0x0B00.
Diffstat (limited to 'src/net/ea')
-rw-r--r--src/net/ea/npchandler.cpp87
-rw-r--r--src/net/ea/npchandler.h2
2 files changed, 89 insertions, 0 deletions
diff --git a/src/net/ea/npchandler.cpp b/src/net/ea/npchandler.cpp
index 553209f59..a436b6cbe 100644
--- a/src/net/ea/npchandler.cpp
+++ b/src/net/ea/npchandler.cpp
@@ -22,6 +22,8 @@
#include "net/ea/npchandler.h"
+#include "gui/viewport.h"
+
#include "gui/windows/npcdialog.h"
#include "net/messagein.h"
@@ -114,4 +116,89 @@ void NpcHandler::processNpcStrInput(Net::MessageIn &msg)
}
}
+void NpcHandler::processNpcCommand(Net::MessageIn &msg)
+{
+ const int npcId = npcHandler->getNpc(msg);
+ mRequestLang = false;
+
+ const int cmd = msg.readInt16("cmd");
+ switch (cmd)
+ {
+ case 0:
+ mRequestLang = true;
+ break;
+
+ case 1:
+ if (viewport)
+ viewport->moveCameraToActor(npcId);
+ break;
+
+ 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
+ viewport->moveCameraToActor(id, x, y);
+ }
+ break;
+
+ case 3:
+ if (viewport)
+ viewport->returnCamera();
+ break;
+
+ case 4:
+ if (viewport)
+ {
+ msg.readInt32("id");
+ const int x = msg.readInt16("x");
+ const int y = msg.readInt16("y");
+ viewport->moveCameraRelative(x, y);
+ }
+ break;
+ case 5: // close dialog
+ npcHandler->closeDialog(npcId);
+ break;
+ case 6: // show avatar
+ if (mDialog)
+ {
+ mDialog->showAvatar(static_cast<uint16_t>(
+ msg.readInt32("avatar id")));
+ }
+ break;
+ case 7: // set avatar direction
+ if (mDialog)
+ {
+ mDialog->setAvatarDirection(
+ Net::MessageIn::fromServerDirection(
+ static_cast<uint8_t>(msg.readInt32("avatar direction"))));
+ }
+ break;
+ case 8: // set avatar action
+ if (mDialog)
+ mDialog->setAvatarAction(msg.readInt32("avatar action"));
+ break;
+ case 9: // clear npc dialog
+ if (mDialog)
+ mDialog->clearRows();
+ break;
+ case 10: // send selected item id
+ {
+ int invSize = msg.readInt32("npc inventory size");
+ if (!invSize)
+ invSize = 1;
+ if (mDialog)
+ mDialog->itemRequest(invSize);
+ break;
+ }
+ default:
+ logger->log("unknown npc command: %d", cmd);
+ break;
+ }
+}
+
} // namespace Ea
diff --git a/src/net/ea/npchandler.h b/src/net/ea/npchandler.h
index 08c5727f2..d518c6416 100644
--- a/src/net/ea/npchandler.h
+++ b/src/net/ea/npchandler.h
@@ -54,6 +54,8 @@ class NpcHandler notfinal : public Net::NpcHandler
static void processNpcStrInput(Net::MessageIn &msg);
+ static void processNpcCommand(Net::MessageIn &msg);
+
protected:
NpcHandler();