summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/net/ea/npchandler.cpp87
-rw-r--r--src/net/ea/npchandler.h2
-rw-r--r--src/net/eathena/npchandler.cpp5
-rw-r--r--src/net/eathena/packets.h21
-rw-r--r--src/net/eathena/protocol.h2
-rw-r--r--src/net/tmwa/npchandler.cpp85
-rw-r--r--src/net/tmwa/npchandler.h2
7 files changed, 116 insertions, 88 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();
diff --git a/src/net/eathena/npchandler.cpp b/src/net/eathena/npchandler.cpp
index 503dc642e..1dd6f1906 100644
--- a/src/net/eathena/npchandler.cpp
+++ b/src/net/eathena/npchandler.cpp
@@ -54,6 +54,7 @@ NpcHandler::NpcHandler() :
SMSG_NPC_VIEWPOINT,
SMSG_NPC_SHOW_PROGRESS_BAR,
SMSG_NPC_CLOSE_TIMEOUT,
+ SMSG_NPC_COMMAND,
0
};
handledMessages = _messages;
@@ -104,6 +105,10 @@ void NpcHandler::handleMessage(Net::MessageIn &msg)
processNpcCloseTimeout(msg);
break;
+ case SMSG_NPC_COMMAND:
+ processNpcCommand(msg);
+ break;
+
default:
break;
}
diff --git a/src/net/eathena/packets.h b/src/net/eathena/packets.h
index 6d7a99762..cdc21e72a 100644
--- a/src/net/eathena/packets.h
+++ b/src/net/eathena/packets.h
@@ -263,6 +263,27 @@ int16_t packet_lengths[] =
0, 0, 0, 0, 0,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/src/net/eathena/protocol.h
index 09e615cfd..bdf254d04 100644
--- a/src/net/eathena/protocol.h
+++ b/src/net/eathena/protocol.h
@@ -279,7 +279,7 @@
#define SMSG_MAP_TYPE 0x01d6
#define SMSG_IGNORE_ALL_RESPONSE 0x00d2
#define SMSG_ONLINE_LIST 0x0211
-#define SMSG_NPC_COMMAND 0x0212
+#define SMSG_NPC_COMMAND 0x0B00
#define SMSG_MAP_ACCOUNT_ID 0x0283
#define SMSG_PLAYER_SHORTCUTS 0x0a00
diff --git a/src/net/tmwa/npchandler.cpp b/src/net/tmwa/npchandler.cpp
index 812416948..74cb9d78f 100644
--- a/src/net/tmwa/npchandler.cpp
+++ b/src/net/tmwa/npchandler.cpp
@@ -291,91 +291,6 @@ int NpcHandler::getNpc(Net::MessageIn &msg)
return npcId;
}
-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;
- }
-}
-
void NpcHandler::processChangeTitle(Net::MessageIn &msg)
{
npcHandler->getNpc(msg);
diff --git a/src/net/tmwa/npchandler.h b/src/net/tmwa/npchandler.h
index 476e62a64..f399a98d9 100644
--- a/src/net/tmwa/npchandler.h
+++ b/src/net/tmwa/npchandler.h
@@ -69,8 +69,6 @@ class NpcHandler final : public MessageHandler, public Ea::NpcHandler
int getNpc(Net::MessageIn &msg) override final;
- static void processNpcCommand(Net::MessageIn &msg);
-
static void processChangeTitle(Net::MessageIn &msg);
void produceMix(const int nameId,