summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-02-25 13:50:47 -0700
committerJared Adams <jaxad0127@gmail.com>2009-02-25 13:50:47 -0700
commit3ad6ac47d4967870a54fddd66aa9996724115b94 (patch)
tree6f0a5931a193e2942a0988964f9324f715f303db /src
parentf04a8713ffc83db8b3dc4a472b28aad25a2b2bd1 (diff)
downloadmana-client-3ad6ac47d4967870a54fddd66aa9996724115b94.tar.gz
mana-client-3ad6ac47d4967870a54fddd66aa9996724115b94.tar.bz2
mana-client-3ad6ac47d4967870a54fddd66aa9996724115b94.tar.xz
mana-client-3ad6ac47d4967870a54fddd66aa9996724115b94.zip
Prevent duplicate NPC talking when using keyboard
Based on commit a1e483913672e55704e8fbafeff5ea0ccc0c9b07 from Aethyra.
Diffstat (limited to 'src')
-rw-r--r--src/gui/npc_text.cpp1
-rw-r--r--src/npc.cpp7
-rw-r--r--src/npc.h2
3 files changed, 8 insertions, 2 deletions
diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp
index db0015e9..520efad4 100644
--- a/src/gui/npc_text.cpp
+++ b/src/gui/npc_text.cpp
@@ -108,6 +108,7 @@ void NpcTextDialog::action(const gcn::ActionEvent &event)
if (current_npc) nextDialog();
setVisible(false);
current_npc = 0;
+ NPC::isTalking = false;
} else return;
}
else return;
diff --git a/src/npc.cpp b/src/npc.cpp
index 8fd8a86b..5132e0dc 100644
--- a/src/npc.cpp
+++ b/src/npc.cpp
@@ -34,7 +34,8 @@
extern NpcTextDialog *npcTextDialog;
-int current_npc = NULL;
+int current_npc = 0;
+bool NPC::isTalking = false;
static const int NAME_X_OFFSET = 15;
static const int NAME_Y_OFFSET = 30;
@@ -107,7 +108,9 @@ Being::Type NPC::getType() const
void NPC::talk()
{
- if (!this || !mNetwork) return;
+ if (isTalking || !this || !mNetwork) return;
+
+ isTalking = true;
MessageOut outMsg(mNetwork);
outMsg.writeInt16(CMSG_NPC_TALK);
outMsg.writeInt32(mId);
diff --git a/src/npc.h b/src/npc.h
index ef9fdc7d..182da3e5 100644
--- a/src/npc.h
+++ b/src/npc.h
@@ -42,6 +42,8 @@ class NPC : public Player
virtual Type getType() const;
void talk();
+
+ static bool isTalking;
protected:
Network *mNetwork;
void updateCoords();