diff options
author | Jared Adams <jaxad0127@gmail.com> | 2010-01-10 17:53:54 +0000 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2010-01-10 20:48:37 +0000 |
commit | 023ca895db6aaf1c4ed5a2240cf85443f83e84db (patch) | |
tree | 90b1a76df122231d9f4ced473544e1e8e5f93ca9 | |
parent | f5a394a5051384a930d635da22ccafc6beb1cb84 (diff) | |
download | mana-023ca895db6aaf1c4ed5a2240cf85443f83e84db.tar.gz mana-023ca895db6aaf1c4ed5a2240cf85443f83e84db.tar.bz2 mana-023ca895db6aaf1c4ed5a2240cf85443f83e84db.tar.xz mana-023ca895db6aaf1c4ed5a2240cf85443f83e84db.zip |
Fix handling of NPC talking status
-rw-r--r-- | src/gui/buysell.cpp | 2 | ||||
-rw-r--r-- | src/gui/npcdialog.cpp | 1 | ||||
-rw-r--r-- | src/npc.cpp | 17 | ||||
-rw-r--r-- | src/npc.h | 4 |
4 files changed, 15 insertions, 9 deletions
diff --git a/src/gui/buysell.cpp b/src/gui/buysell.cpp index c96c9f24..be6b75f1 100644 --- a/src/gui/buysell.cpp +++ b/src/gui/buysell.cpp @@ -81,8 +81,6 @@ void BuySellDialog::action(const gcn::ActionEvent &event) { setVisible(false); - NPC::isTalking = false; - if (event.getId() == "Buy") { Net::getNpcHandler()->buy(current_npc); diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp index 12ea61a6..52c60c74 100644 --- a/src/gui/npcdialog.cpp +++ b/src/gui/npcdialog.cpp @@ -165,7 +165,6 @@ void NpcDialog::action(const gcn::ActionEvent &event) closeDialog(); setVisible(false); current_npc = 0; - NPC::isTalking = false; } else if (mActionState == NPC_ACTION_INPUT) { diff --git a/src/npc.cpp b/src/npc.cpp index a79e5bac..5304bc93 100644 --- a/src/npc.cpp +++ b/src/npc.cpp @@ -25,14 +25,18 @@ #include "particle.h" #include "text.h" +#include "gui/buy.h" +#include "gui/buysell.h" +#include "gui/npcdialog.h" +#include "gui/npcpostdialog.h" #include "gui/palette.h" +#include "gui/sell.h" #include "net/net.h" #include "net/npchandler.h" #include "resources/npcdb.h" -bool NPC::isTalking = false; int current_npc = 0; NPC::NPC(int id, int job, Map *map): @@ -76,11 +80,9 @@ void NPC::setName(const std::string &name) void NPC::talk() { - if (isTalking) + if (isTalking()) return; - isTalking = true; - Net::getNpcHandler()->talk(mId); } @@ -88,3 +90,10 @@ void NPC::setSprite(unsigned int slot, int id, const std::string &color) { // Do nothing } + +const bool NPC::isTalking() +{ + return npcDialog->isVisible() || buyDialog->isVisible() || + sellDialog->isVisible() || buySellDialog->isVisible() || + npcPostDialog->isVisible(); +} @@ -51,11 +51,11 @@ class NPC : public Player | Map::BLOCKMASK_MONSTER; } - static bool isTalking; - /** We consider NPCs (at least for now) to be one layer-sprites */ virtual int getNumberOfLayers() const { return 1; } + + static const bool isTalking(); protected: /** |