From 84b67aacfdedd8d526d246e3d3c0914a899d491c Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 17 Oct 2014 23:03:03 +0300 Subject: Add static in npchandler. --- src/net/ea/npchandler.cpp | 23 +++++++++++++---------- src/net/ea/npchandler.h | 18 ++++++++---------- src/net/eathena/npchandler.cpp | 4 ++-- src/net/eathena/npchandler.h | 4 ++-- src/net/npchandler.h | 4 ++++ src/net/tmwa/npchandler.cpp | 6 +++--- src/net/tmwa/npchandler.h | 4 ++-- 7 files changed, 34 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/net/ea/npchandler.cpp b/src/net/ea/npchandler.cpp index fedc7c744..9a1592576 100644 --- a/src/net/ea/npchandler.cpp +++ b/src/net/ea/npchandler.cpp @@ -33,10 +33,13 @@ namespace Ea { -NpcHandler::NpcHandler() : - mDialog(nullptr), - mRequestLang(false) +NpcDialog *NpcHandler::mDialog = nullptr; +bool NpcHandler::mRequestLang = false; + +NpcHandler::NpcHandler() { + mDialog = nullptr; + mRequestLang = false; } void NpcHandler::sendLetter(const int npcId A_UNUSED, @@ -55,7 +58,7 @@ void NpcHandler::endShopping(const int beingId A_UNUSED) const void NpcHandler::processNpcChoice(Net::MessageIn &msg) { - getNpc(msg); + npcHandler->getNpc(msg); mRequestLang = false; if (mDialog) @@ -71,7 +74,7 @@ void NpcHandler::processNpcChoice(Net::MessageIn &msg) void NpcHandler::processNpcMessage(Net::MessageIn &msg) { - getNpc(msg); + npcHandler->getNpc(msg); mRequestLang = false; const std::string message = msg.readString(msg.getLength() - 8); @@ -85,7 +88,7 @@ void NpcHandler::processNpcMessage(Net::MessageIn &msg) void NpcHandler::processNpcClose(Net::MessageIn &msg) { // Show the close button - getNpc(msg); + npcHandler->getNpc(msg); mRequestLang = false; if (mDialog) mDialog->showCloseButton(); @@ -94,7 +97,7 @@ void NpcHandler::processNpcClose(Net::MessageIn &msg) void NpcHandler::processNpcNext(Net::MessageIn &msg) { // Show the next button - getNpc(msg); + npcHandler->getNpc(msg); mRequestLang = false; if (mDialog) mDialog->showNextButton(); @@ -103,7 +106,7 @@ void NpcHandler::processNpcNext(Net::MessageIn &msg) void NpcHandler::processNpcIntInput(Net::MessageIn &msg) { // Request for an integer - getNpc(msg); + npcHandler->getNpc(msg); mRequestLang = false; if (mDialog) mDialog->integerRequest(0); @@ -112,11 +115,11 @@ void NpcHandler::processNpcIntInput(Net::MessageIn &msg) void NpcHandler::processNpcStrInput(Net::MessageIn &msg) { // Request for a string - int npcId = getNpc(msg); + int npcId = npcHandler->getNpc(msg); if (mRequestLang) { mRequestLang = false; - stringInput(npcId, getLangSimple()); + npcHandler->stringInput(npcId, getLangSimple()); } else if (mDialog) { diff --git a/src/net/ea/npchandler.h b/src/net/ea/npchandler.h index 81e92d84a..901ee9148 100644 --- a/src/net/ea/npchandler.h +++ b/src/net/ea/npchandler.h @@ -49,26 +49,24 @@ class NpcHandler notfinal : public Net::NpcHandler void endShopping(const int beingId) const override final; - virtual int getNpc(Net::MessageIn &msg) = 0; + static void processNpcChoice(Net::MessageIn &msg); - void processNpcChoice(Net::MessageIn &msg); + static void processNpcMessage(Net::MessageIn &msg); - void processNpcMessage(Net::MessageIn &msg); + static void processNpcClose(Net::MessageIn &msg); - void processNpcClose(Net::MessageIn &msg); + static void processNpcNext(Net::MessageIn &msg); - void processNpcNext(Net::MessageIn &msg); + static void processNpcIntInput(Net::MessageIn &msg); - void processNpcIntInput(Net::MessageIn &msg); - - void processNpcStrInput(Net::MessageIn &msg); + static void processNpcStrInput(Net::MessageIn &msg); protected: NpcHandler(); - NpcDialog *mDialog; + static NpcDialog *mDialog; - bool mRequestLang; + static bool mRequestLang; }; } // namespace Ea diff --git a/src/net/eathena/npchandler.cpp b/src/net/eathena/npchandler.cpp index 27c8c6903..873982750 100644 --- a/src/net/eathena/npchandler.cpp +++ b/src/net/eathena/npchandler.cpp @@ -322,14 +322,14 @@ void NpcHandler::processNpcViewPoint(Net::MessageIn &msg) msg.readInt32("color"); } -void NpcHandler::processNpcShowProgressBar(Net::MessageIn &msg) const +void NpcHandler::processNpcShowProgressBar(Net::MessageIn &msg) { // +++ probably need show progress bar in npc dialog msg.readInt32("color"); msg.readInt32("seconds"); } -void NpcHandler::processNpcCloseTimeout(Net::MessageIn &msg) const +void NpcHandler::processNpcCloseTimeout(Net::MessageIn &msg) { // this packet send after npc closed by timeout. msg.readInt32("npc id"); diff --git a/src/net/eathena/npchandler.h b/src/net/eathena/npchandler.h index 2e8c00181..529d397ef 100644 --- a/src/net/eathena/npchandler.h +++ b/src/net/eathena/npchandler.h @@ -92,9 +92,9 @@ class NpcHandler final : public MessageHandler, public Ea::NpcHandler static void processNpcViewPoint(Net::MessageIn &msg); - void processNpcShowProgressBar(Net::MessageIn &msg) const; + static void processNpcShowProgressBar(Net::MessageIn &msg); - void processNpcCloseTimeout(Net::MessageIn &msg) const; + static void processNpcCloseTimeout(Net::MessageIn &msg); }; } // namespace EAthena diff --git a/src/net/npchandler.h b/src/net/npchandler.h index 706f6d7c3..9ba358068 100644 --- a/src/net/npchandler.h +++ b/src/net/npchandler.h @@ -32,12 +32,16 @@ namespace Net { +class MessageIn; + class NpcHandler notfinal { public: virtual ~NpcHandler() { } + virtual int getNpc(Net::MessageIn &msg) = 0; + virtual void talk(const int npcId) const = 0; virtual void nextDialog(const int npcId) const = 0; diff --git a/src/net/tmwa/npchandler.cpp b/src/net/tmwa/npchandler.cpp index 0cc7c6dbf..5f8ff0b21 100644 --- a/src/net/tmwa/npchandler.cpp +++ b/src/net/tmwa/npchandler.cpp @@ -291,7 +291,7 @@ int NpcHandler::getNpc(Net::MessageIn &msg) void NpcHandler::processNpcCommand(Net::MessageIn &msg) { - const int npcId = getNpc(msg); + const int npcId = npcHandler->getNpc(msg); mRequestLang = false; const int cmd = msg.readInt16(); @@ -334,7 +334,7 @@ void NpcHandler::processNpcCommand(Net::MessageIn &msg) } break; case 5: // close dialog - closeDialog(npcId); + npcHandler->closeDialog(npcId); break; case 6: // show avatar if (mDialog) @@ -376,7 +376,7 @@ void NpcHandler::processNpcCommand(Net::MessageIn &msg) void NpcHandler::processChangeTitle(Net::MessageIn &msg) { - getNpc(msg); + npcHandler->getNpc(msg); mRequestLang = false; const std::string str = msg.readString(); if (mDialog) diff --git a/src/net/tmwa/npchandler.h b/src/net/tmwa/npchandler.h index d73e9c71d..476e62a64 100644 --- a/src/net/tmwa/npchandler.h +++ b/src/net/tmwa/npchandler.h @@ -69,9 +69,9 @@ class NpcHandler final : public MessageHandler, public Ea::NpcHandler int getNpc(Net::MessageIn &msg) override final; - void processNpcCommand(Net::MessageIn &msg); + static void processNpcCommand(Net::MessageIn &msg); - void processChangeTitle(Net::MessageIn &msg); + static void processChangeTitle(Net::MessageIn &msg); void produceMix(const int nameId, const int materialId1, -- cgit v1.2.3-70-g09d2