diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-06-13 00:43:25 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-06-13 00:43:25 +0300 |
commit | 9233c3936657f6dc4ca9c73d84ea8c045b3fc09d (patch) | |
tree | a7def2f0e6c8fcdaefd6f0f330da7e7eb6c9c0b0 /src | |
parent | d3af59b8eedae98a49367e2ac37f2ab1b79c0557 (diff) | |
download | mv-9233c3936657f6dc4ca9c73d84ea8c045b3fc09d.tar.gz mv-9233c3936657f6dc4ca9c73d84ea8c045b3fc09d.tar.bz2 mv-9233c3936657f6dc4ca9c73d84ea8c045b3fc09d.tar.xz mv-9233c3936657f6dc4ca9c73d84ea8c045b3fc09d.zip |
move npc dialogs array from netcode.
Diffstat (limited to 'src')
-rw-r--r-- | src/client.cpp | 4 | ||||
-rw-r--r-- | src/gui/npcdialog.cpp | 13 | ||||
-rw-r--r-- | src/gui/npcdialog.h | 7 | ||||
-rw-r--r-- | src/net/ea/npchandler.cpp | 13 | ||||
-rw-r--r-- | src/net/ea/npchandler.h | 4 | ||||
-rw-r--r-- | src/net/ea/playerhandler.cpp | 5 | ||||
-rw-r--r-- | src/net/eathena/npchandler.cpp | 12 | ||||
-rw-r--r-- | src/net/npchandler.h | 2 | ||||
-rw-r--r-- | src/net/tmwa/npchandler.cpp | 12 |
9 files changed, 36 insertions, 36 deletions
diff --git a/src/client.cpp b/src/client.cpp index fef51e24f..7b0756623 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -1183,7 +1183,7 @@ int Client::gameExec() resman->cleanOrphans(); Party::clearParties(); Guild::clearGuilds(); - Net::getNpcHandler()->clearDialogs(); + NpcDialog::clearDialogs(); Net::getGuildHandler()->clear(); Net::getPartyHandler()->clear(); if (chatLogger) @@ -2752,7 +2752,7 @@ int Client::getFramerate() void Client::closeDialogs() { - Net::getNpcHandler()->clearDialogs(); + NpcDialog::clearDialogs(); BuyDialog::closeAll(); BuySellDialog::closeAll(); NpcDialog::closeAll(); diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp index f4d99cc79..2271a0bc7 100644 --- a/src/gui/npcdialog.cpp +++ b/src/gui/npcdialog.cpp @@ -66,6 +66,7 @@ #define CAPTION_SUBMIT _("Submit") NpcDialog::DialogList NpcDialog::instances; +NpcDialogs NpcDialog::mNpcDialogs; typedef std::vector<Image *>::iterator ImageVectorIter; @@ -774,3 +775,15 @@ void NpcDialog::clearRows() { mTextBox->clearRows(); } + +void NpcDialog::clearDialogs() +{ + NpcDialogs::iterator it = mNpcDialogs.begin(); + const NpcDialogs::iterator it_end = mNpcDialogs.end(); + while (it != it_end) + { + delete (*it).second; + ++ it; + } + mNpcDialogs.clear(); +} diff --git a/src/gui/npcdialog.h b/src/gui/npcdialog.h index 3cdb39511..8a4e5b614 100644 --- a/src/gui/npcdialog.h +++ b/src/gui/npcdialog.h @@ -41,11 +41,14 @@ class BrowserBox; class ExtendedListBox; class ItemLinkHandler; class IntTextField; +class NpcDialog; class PlayerBox; class ScrollArea; class TextBox; class TextField; +typedef std::map<int, NpcDialog*> NpcDialogs; + /** * The npc dialog. * @@ -202,6 +205,10 @@ class NpcDialog final : public Window, void clearRows(); + static NpcDialogs mNpcDialogs; + + static void clearDialogs(); + private: typedef std::list<NpcDialog*> DialogList; static DialogList instances; diff --git a/src/net/ea/npchandler.cpp b/src/net/ea/npchandler.cpp index 78a46f630..654a783b3 100644 --- a/src/net/ea/npchandler.cpp +++ b/src/net/ea/npchandler.cpp @@ -30,7 +30,6 @@ namespace Ea { NpcHandler::NpcHandler() : - mNpcDialogs(), mDialog(nullptr) { } @@ -49,18 +48,6 @@ void NpcHandler::endShopping(const int beingId A_UNUSED) const { } -void NpcHandler::clearDialogs() -{ - NpcDialogs::iterator it = mNpcDialogs.begin(); - const NpcDialogs::iterator it_end = mNpcDialogs.end(); - while (it != it_end) - { - delete (*it).second; - ++ it; - } - mNpcDialogs.clear(); -} - void NpcHandler::processNpcChoice(Net::MessageIn &msg) { if (mDialog) diff --git a/src/net/ea/npchandler.h b/src/net/ea/npchandler.h index 9fe07f531..9c50b8c50 100644 --- a/src/net/ea/npchandler.h +++ b/src/net/ea/npchandler.h @@ -48,8 +48,6 @@ class NpcHandler : public Net::NpcHandler void endShopping(int beingId) const override; - void clearDialogs() override; - virtual int getNpc(Net::MessageIn &msg, bool haveLength) A_WARN_UNUSED = 0; @@ -66,8 +64,6 @@ class NpcHandler : public Net::NpcHandler void processNpcStrInput(Net::MessageIn &msg); protected: - typedef std::map<int, NpcDialog*> NpcDialogs; - NpcDialogs mNpcDialogs; NpcDialog *mDialog; }; diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp index 309888d50..c52febaf9 100644 --- a/src/net/ea/playerhandler.cpp +++ b/src/net/ea/playerhandler.cpp @@ -30,6 +30,7 @@ #include "gui/ministatuswindow.h" #include "gui/okdialog.h" +#include "gui/npcdialog.h" #include "gui/skilldialog.h" #include "gui/statuswindow.h" #include "gui/viewport.h" @@ -77,9 +78,7 @@ namespace if (viewport) viewport->closePopupMenu(); - Net::NpcHandler *const handler = Net::getNpcHandler(); - if (handler) - handler->clearDialogs(); + NpcDialog::clearDialogs(); if (player_node) player_node->respawn(); } diff --git a/src/net/eathena/npchandler.cpp b/src/net/eathena/npchandler.cpp index fc5744bfd..2543c3b41 100644 --- a/src/net/eathena/npchandler.cpp +++ b/src/net/eathena/npchandler.cpp @@ -130,15 +130,15 @@ void NpcHandler::closeDialog(const int npcId) MessageOut outMsg(CMSG_NPC_CLOSE); outMsg.writeInt32(npcId); - const NpcDialogs::iterator it = mNpcDialogs.find(npcId); - if (it != mNpcDialogs.end()) + const NpcDialogs::iterator it = NpcDialog::mNpcDialogs.find(npcId); + if (it != NpcDialog::mNpcDialogs.end()) { NpcDialog *const dialog = (*it).second; if (dialog) dialog->close(); if (dialog == mDialog) mDialog = nullptr; - mNpcDialogs.erase(it); + NpcDialog::mNpcDialogs.erase(it); } } @@ -205,10 +205,10 @@ int NpcHandler::getNpc(Net::MessageIn &msg, const bool haveLength) const int npcId = msg.readInt32(); - const NpcDialogs::const_iterator diag = mNpcDialogs.find(npcId); + const NpcDialogs::const_iterator diag = NpcDialog::mNpcDialogs.find(npcId); mDialog = nullptr; - if (diag == mNpcDialogs.end()) + if (diag == NpcDialog::mNpcDialogs.end()) { // Empty dialogs don't help if (msg.getId() == SMSG_NPC_CLOSE) @@ -227,7 +227,7 @@ int NpcHandler::getNpc(Net::MessageIn &msg, const bool haveLength) mDialog->saveCamera(); if (player_node) player_node->stopWalking(false); - mNpcDialogs[npcId] = mDialog; + NpcDialog::mNpcDialogs[npcId] = mDialog; } } else diff --git a/src/net/npchandler.h b/src/net/npchandler.h index ae53e8d0e..8ed0c26c6 100644 --- a/src/net/npchandler.h +++ b/src/net/npchandler.h @@ -65,8 +65,6 @@ class NpcHandler const int amount) const = 0; virtual void endShopping(const int beingId) const = 0; - - virtual void clearDialogs() = 0; }; } // namespace Net diff --git a/src/net/tmwa/npchandler.cpp b/src/net/tmwa/npchandler.cpp index 36eca01aa..ddbc6a220 100644 --- a/src/net/tmwa/npchandler.cpp +++ b/src/net/tmwa/npchandler.cpp @@ -129,15 +129,15 @@ void NpcHandler::closeDialog(const int npcId) MessageOut outMsg(CMSG_NPC_CLOSE); outMsg.writeInt32(npcId); - const NpcDialogs::iterator it = mNpcDialogs.find(npcId); - if (it != mNpcDialogs.end()) + const NpcDialogs::iterator it = NpcDialog::mNpcDialogs.find(npcId); + if (it != NpcDialog::mNpcDialogs.end()) { NpcDialog *const dialog = (*it).second; if (dialog) dialog->close(); if (dialog == mDialog) mDialog = nullptr; - mNpcDialogs.erase(it); + NpcDialog::mNpcDialogs.erase(it); } } @@ -214,10 +214,10 @@ int NpcHandler::getNpc(Net::MessageIn &msg, const bool haveLength) const int npcId = msg.readInt32(); - const NpcDialogs::const_iterator diag = mNpcDialogs.find(npcId); + const NpcDialogs::const_iterator diag = NpcDialog::mNpcDialogs.find(npcId); mDialog = nullptr; - if (diag == mNpcDialogs.end()) + if (diag == NpcDialog::mNpcDialogs.end()) { // Empty dialogs don't help if (msg.getId() == SMSG_NPC_CLOSE) @@ -236,7 +236,7 @@ int NpcHandler::getNpc(Net::MessageIn &msg, const bool haveLength) mDialog->saveCamera(); if (player_node) player_node->stopWalking(false); - mNpcDialogs[npcId] = mDialog; + NpcDialog::mNpcDialogs[npcId] = mDialog; } } else |