diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/net/ea/npchandler.cpp | 15 | ||||
-rw-r--r-- | src/net/ea/npchandler.h | 2 | ||||
-rw-r--r-- | src/net/eathena/npchandler.cpp | 17 | ||||
-rw-r--r-- | src/net/eathena/npchandler.h | 4 | ||||
-rw-r--r-- | src/net/tmwa/npchandler.cpp | 35 | ||||
-rw-r--r-- | src/net/tmwa/npchandler.h | 7 |
6 files changed, 35 insertions, 45 deletions
diff --git a/src/net/ea/npchandler.cpp b/src/net/ea/npchandler.cpp index 03def7298..05f12c2bb 100644 --- a/src/net/ea/npchandler.cpp +++ b/src/net/ea/npchandler.cpp @@ -32,7 +32,8 @@ namespace Ea { NpcHandler::NpcHandler() : - mDialog(nullptr) + mDialog(nullptr), + mRequestLang(false) { } @@ -52,6 +53,9 @@ void NpcHandler::endShopping(const int beingId A_UNUSED) const void NpcHandler::processNpcChoice(Net::MessageIn &msg) { + getNpc(msg); + mRequestLang = false; + if (mDialog) { mDialog->choiceRequest(); @@ -65,6 +69,9 @@ void NpcHandler::processNpcChoice(Net::MessageIn &msg) void NpcHandler::processNpcMessage(Net::MessageIn &msg) { + getNpc(msg); + mRequestLang = false; + const std::string message = msg.readString(msg.getLength() - 8); // ignore future legacy npc commands. if (message.size() > 3 && message.substr(0, 3) == "###") @@ -76,6 +83,8 @@ void NpcHandler::processNpcMessage(Net::MessageIn &msg) void NpcHandler::processNpcClose(Net::MessageIn &msg A_UNUSED) { // Show the close button + getNpc(msg); + mRequestLang = false; if (mDialog) mDialog->showCloseButton(); } @@ -83,6 +92,8 @@ void NpcHandler::processNpcClose(Net::MessageIn &msg A_UNUSED) void NpcHandler::processNpcNext(Net::MessageIn &msg A_UNUSED) { // Show the next button + getNpc(msg); + mRequestLang = false; if (mDialog) mDialog->showNextButton(); } @@ -90,6 +101,8 @@ void NpcHandler::processNpcNext(Net::MessageIn &msg A_UNUSED) void NpcHandler::processNpcIntInput(Net::MessageIn &msg A_UNUSED) { // Request for an integer + getNpc(msg); + mRequestLang = false; if (mDialog) mDialog->integerRequest(0); } diff --git a/src/net/ea/npchandler.h b/src/net/ea/npchandler.h index c1bcd5cd1..81e92d84a 100644 --- a/src/net/ea/npchandler.h +++ b/src/net/ea/npchandler.h @@ -67,6 +67,8 @@ class NpcHandler notfinal : public Net::NpcHandler NpcHandler(); NpcDialog *mDialog; + + bool mRequestLang; }; } // namespace Ea diff --git a/src/net/eathena/npchandler.cpp b/src/net/eathena/npchandler.cpp index 5947c967b..e6428fc31 100644 --- a/src/net/eathena/npchandler.cpp +++ b/src/net/eathena/npchandler.cpp @@ -65,27 +65,22 @@ void NpcHandler::handleMessage(Net::MessageIn &msg) switch (msg.getId()) { case SMSG_NPC_CHOICE: - getNpc(msg); processNpcChoice(msg); break; case SMSG_NPC_MESSAGE: - getNpc(msg); processNpcMessage(msg); break; case SMSG_NPC_CLOSE: - getNpc(msg); processNpcClose(msg); break; case SMSG_NPC_NEXT: - getNpc(msg); processNpcNext(msg); break; case SMSG_NPC_INT_INPUT: - getNpc(msg); processNpcIntInput(msg); break; @@ -95,12 +90,11 @@ void NpcHandler::handleMessage(Net::MessageIn &msg) break; case SMSG_NPC_CUTIN: - processNpcCutin(msg, npcId); + processNpcCutin(msg); break; case SMSG_NPC_VIEWPOINT: - npcId = getNpc(msg); - processNpcViewPoint(msg, npcId); + processNpcViewPoint(msg); break; default: @@ -247,17 +241,16 @@ int NpcHandler::getNpc(Net::MessageIn &msg) return npcId; } -void NpcHandler::processNpcCutin(Net::MessageIn &msg A_UNUSED, - const int npcId A_UNUSED) +void NpcHandler::processNpcCutin(Net::MessageIn &msg A_UNUSED) { msg.readString(64); // image name msg.readUInt8(); // type } -void NpcHandler::processNpcViewPoint(Net::MessageIn &msg A_UNUSED, - const int npcId A_UNUSED) +void NpcHandler::processNpcViewPoint(Net::MessageIn &msg A_UNUSED) { // +++ probably need add nav point and start moving to it + msg.readInt32("npc id"); msg.readInt32("type"); // 0 display for 15 sec, // 1 display until teleport, // 2 remove diff --git a/src/net/eathena/npchandler.h b/src/net/eathena/npchandler.h index 68f64e072..eadba2a13 100644 --- a/src/net/eathena/npchandler.h +++ b/src/net/eathena/npchandler.h @@ -67,9 +67,9 @@ class NpcHandler final : public MessageHandler, public Ea::NpcHandler int getNpc(Net::MessageIn &msg) override final; - static void processNpcCutin(Net::MessageIn &msg, const int npcId); + static void processNpcCutin(Net::MessageIn &msg); - static void processNpcViewPoint(Net::MessageIn &msg, const int npcId); + static void processNpcViewPoint(Net::MessageIn &msg); }; } // namespace EAthena diff --git a/src/net/tmwa/npchandler.cpp b/src/net/tmwa/npchandler.cpp index 3a9ee00a9..4c96eac21 100644 --- a/src/net/tmwa/npchandler.cpp +++ b/src/net/tmwa/npchandler.cpp @@ -45,8 +45,7 @@ namespace TmwAthena NpcHandler::NpcHandler() : MessageHandler(), - Ea::NpcHandler(), - mRequestLang(false) + Ea::NpcHandler() { static const uint16_t _messages[] = { @@ -71,32 +70,22 @@ void NpcHandler::handleMessage(Net::MessageIn &msg) switch (msg.getId()) { case SMSG_NPC_CHOICE: - getNpc(msg); - mRequestLang = false; processNpcChoice(msg); break; case SMSG_NPC_MESSAGE: - getNpc(msg); - mRequestLang = false; processNpcMessage(msg); break; case SMSG_NPC_CLOSE: - getNpc(msg); - mRequestLang = false; processNpcClose(msg); break; case SMSG_NPC_NEXT: - getNpc(msg); - mRequestLang = false; processNpcNext(msg); break; case SMSG_NPC_INT_INPUT: - getNpc(msg); - mRequestLang = false; processNpcIntInput(msg); break; @@ -111,20 +100,12 @@ void NpcHandler::handleMessage(Net::MessageIn &msg) } case SMSG_NPC_COMMAND: - { - const int npcId = getNpc(msg); - mRequestLang = false; - processNpcCommand(msg, npcId); + processNpcCommand(msg); break; - } case SMSG_NPC_CHANGETITLE: - { - const int npcId = getNpc(msg); - mRequestLang = false; - processChangeTitle(msg, npcId); + processChangeTitle(msg); break; - } default: break; @@ -279,8 +260,11 @@ int NpcHandler::getNpc(Net::MessageIn &msg) return npcId; } -void NpcHandler::processNpcCommand(Net::MessageIn &msg, const int npcId) +void NpcHandler::processNpcCommand(Net::MessageIn &msg) { + const int npcId = getNpc(msg); + mRequestLang = false; + const int cmd = msg.readInt16(); switch (cmd) { @@ -368,9 +352,10 @@ void NpcHandler::processLangReuqest(Net::MessageIn &msg A_UNUSED, stringInput(npcId, getLangSimple()); } -void NpcHandler::processChangeTitle(Net::MessageIn &msg, - const int npcId A_UNUSED) const +void NpcHandler::processChangeTitle(Net::MessageIn &msg) { + const int npcId = getNpc(msg); + mRequestLang = false; const std::string str = msg.readString(); if (mDialog) mDialog->setCaption(str); diff --git a/src/net/tmwa/npchandler.h b/src/net/tmwa/npchandler.h index 55dfdd315..a7684ff07 100644 --- a/src/net/tmwa/npchandler.h +++ b/src/net/tmwa/npchandler.h @@ -67,14 +67,11 @@ class NpcHandler final : public MessageHandler, public Ea::NpcHandler int getNpc(Net::MessageIn &msg) override final; - void processNpcCommand(Net::MessageIn &msg, const int npcId); + void processNpcCommand(Net::MessageIn &msg); void processLangReuqest(Net::MessageIn &msg, const int npcId); - void processChangeTitle(Net::MessageIn &msg, const int npcId) const; - - private: - bool mRequestLang; + void processChangeTitle(Net::MessageIn &msg); }; } // namespace TmwAthena |