summaryrefslogtreecommitdiff
path: root/src/net/tmwa/npchandler.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-01-23 18:26:41 +0300
committerAndrei Karas <akaras@inbox.ru>2012-01-23 18:26:41 +0300
commit7d60bf1c04fce4ed16144aece76e594e0e217960 (patch)
treed2831dcbbdf6b7bd3ad89a9e0571b25afa5caad0 /src/net/tmwa/npchandler.cpp
parent20ffb556085e519f98a96f00257ee6b837116a8e (diff)
downloadmv-7d60bf1c04fce4ed16144aece76e594e0e217960.tar.gz
mv-7d60bf1c04fce4ed16144aece76e594e0e217960.tar.bz2
mv-7d60bf1c04fce4ed16144aece76e594e0e217960.tar.xz
mv-7d60bf1c04fce4ed16144aece76e594e0e217960.zip
Add support for request client language from server.
Diffstat (limited to 'src/net/tmwa/npchandler.cpp')
-rw-r--r--src/net/tmwa/npchandler.cpp33
1 files changed, 30 insertions, 3 deletions
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