summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
Diffstat (limited to 'src/net')
-rw-r--r--src/net/tmwa/network.cpp2
-rw-r--r--src/net/tmwa/network.h2
-rw-r--r--src/net/tmwa/npchandler.cpp33
-rw-r--r--src/net/tmwa/npchandler.h7
-rw-r--r--src/net/tmwa/protocol.h1
5 files changed, 40 insertions, 5 deletions
diff --git a/src/net/tmwa/network.cpp b/src/net/tmwa/network.cpp
index addc737ee..08ba1db10 100644
--- a/src/net/tmwa/network.cpp
+++ b/src/net/tmwa/network.cpp
@@ -83,7 +83,7 @@ short packet_lengths[] =
-1, -1, 20, 10, 32, 9, 34, 14, 2, 6, 48, 56, -1, 4, 5, 10,
// #0x0200
26, 0, 0, 0, 18, 0, 0, 0, 0, 0, 0, 19, 10, 0, 0, 0,
- 2, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 2, -1, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-1, 122, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
diff --git a/src/net/tmwa/network.h b/src/net/tmwa/network.h
index 17a4f7370..c0ec6ef3c 100644
--- a/src/net/tmwa/network.h
+++ b/src/net/tmwa/network.h
@@ -39,7 +39,7 @@
* Protocol version, reported to the eAthena char and mapserver who can adjust
* the protocol accordingly.
*/
-#define CLIENT_PROTOCOL_VERSION 4
+#define CLIENT_PROTOCOL_VERSION 5
#define CLIENT_TMW_PROTOCOL_VERSION 1
namespace TmwAthena
diff --git a/src/net/tmwa/npchandler.cpp b/src/net/tmwa/npchandler.cpp
index 574f34d55..5e305070e 100644
--- a/src/net/tmwa/npchandler.cpp
+++ b/src/net/tmwa/npchandler.cpp
@@ -41,7 +41,8 @@ extern Net::NpcHandler *npcHandler;
namespace TmwAthena
{
-NpcHandler::NpcHandler()
+NpcHandler::NpcHandler() :
+ mRequestLang(false)
{
static const Uint16 _messages[] =
{
@@ -51,6 +52,7 @@ NpcHandler::NpcHandler()
SMSG_NPC_CLOSE,
SMSG_NPC_INT_INPUT,
SMSG_NPC_STR_INPUT,
+ SMSG_NPC_COMMAND,
0
};
handledMessages = _messages;
@@ -59,9 +61,12 @@ NpcHandler::NpcHandler()
void NpcHandler::handleMessage(Net::MessageIn &msg)
{
- getNpc(msg, msg.getId() == SMSG_NPC_CHOICE
+ int npcId = getNpc(msg, msg.getId() == SMSG_NPC_CHOICE
|| msg.getId() == SMSG_NPC_MESSAGE);
+ if (msg.getId() != SMSG_NPC_STR_INPUT)
+ mRequestLang = false;
+
switch (msg.getId())
{
case SMSG_NPC_CHOICE:
@@ -85,7 +90,14 @@ void NpcHandler::handleMessage(Net::MessageIn &msg)
break;
case SMSG_NPC_STR_INPUT:
- processNpcStrInput(msg);
+ if (mRequestLang)
+ processLangReuqest(msg, npcId);
+ else
+ processNpcStrInput(msg);
+ break;
+
+ case SMSG_NPC_COMMAND:
+ processNpcCommand(msg);
break;
default:
@@ -227,4 +239,19 @@ int NpcHandler::getNpc(Net::MessageIn &msg, bool haveLength)
return npcId;
}
+void NpcHandler::processNpcCommand(Net::MessageIn &msg)
+{
+ const int cmd = msg.readInt16();
+ if (cmd == 0)
+ mRequestLang = true;
+ else
+ logger->log("unknown npc command: %d", cmd);
+}
+
+void NpcHandler::processLangReuqest(Net::MessageIn &msg A_UNUSED, int npcId)
+{
+ mRequestLang = false;
+ stringInput(npcId, getLangSimple());
+}
+
} // namespace TmwAthena
diff --git a/src/net/tmwa/npchandler.h b/src/net/tmwa/npchandler.h
index 967829ddc..648b1e5d9 100644
--- a/src/net/tmwa/npchandler.h
+++ b/src/net/tmwa/npchandler.h
@@ -65,6 +65,13 @@ class NpcHandler : public MessageHandler, public Ea::NpcHandler
void sellItem(int beingId, int itemId, int amount);
int getNpc(Net::MessageIn &msg, bool haveLength);
+
+ void processNpcCommand(Net::MessageIn &msg);
+
+ void processLangReuqest(Net::MessageIn &msg, int npcId);
+
+ private:
+ bool mRequestLang;
};
} // namespace TmwAthena
diff --git a/src/net/tmwa/protocol.h b/src/net/tmwa/protocol.h
index 0f124cc20..ddc642101 100644
--- a/src/net/tmwa/protocol.h
+++ b/src/net/tmwa/protocol.h
@@ -335,5 +335,6 @@ enum
#define SMSG_IGNORE_ALL_RESPONSE 0x00d2
#define CMSG_ONLINE_LIST 0x0210
#define SMSG_ONLINE_LIST 0x0211
+#define SMSG_NPC_COMMAND 0x0212
#endif