summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-02-18 06:57:16 +0000
committerJared Adams <jaxad0127@gmail.com>2009-02-18 06:57:16 +0000
commit9568a305878d0c035e027c1ed6c9a24147a0adea (patch)
treeca6f2d1d61114f11057938c654ec004042412f1f /src/gui
parenta0edd2e04b263faa13f6fbfbb81dd7c64520e584 (diff)
downloadmana-9568a305878d0c035e027c1ed6c9a24147a0adea.tar.gz
mana-9568a305878d0c035e027c1ed6c9a24147a0adea.tar.bz2
mana-9568a305878d0c035e027c1ed6c9a24147a0adea.tar.xz
mana-9568a305878d0c035e027c1ed6c9a24147a0adea.zip
Centralize current_npc cleanup
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/buy.cpp2
-rw-r--r--src/gui/buysell.cpp2
-rw-r--r--src/gui/npc_text.cpp22
-rw-r--r--src/gui/sell.cpp2
4 files changed, 12 insertions, 16 deletions
diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp
index 27f738c7..b31d48e1 100644
--- a/src/gui/buy.cpp
+++ b/src/gui/buy.cpp
@@ -132,7 +132,7 @@ void BuyDialog::action(const gcn::ActionEvent &event)
if (event.getId() == "quit")
{
setVisible(false);
- current_npc = 0;
+ if (current_npc) current_npc->handleDeath();
return;
}
diff --git a/src/gui/buysell.cpp b/src/gui/buysell.cpp
index d060db85..2d39eac7 100644
--- a/src/gui/buysell.cpp
+++ b/src/gui/buysell.cpp
@@ -58,7 +58,7 @@ void BuySellDialog::action(const gcn::ActionEvent &event)
} else if (event.getId() == "Sell") {
current_npc->sell();
} else if (event.getId() == "Cancel") {
- current_npc = 0;
+ if (current_npc) current_npc->handleDeath();
}
setVisible(false);
}
diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp
index 0a8a4e4d..e6f039a0 100644
--- a/src/gui/npc_text.cpp
+++ b/src/gui/npc_text.cpp
@@ -91,19 +91,15 @@ void NpcTextDialog::action(const gcn::ActionEvent &event)
{
if (event.getId() == "ok")
{
- switch (mState) {
- case NPC_TEXT_STATE_NEXT:
- current_npc->nextDialog();
- addText("\n> Next\n");
- break;
- case NPC_TEXT_STATE_CLOSE:
- setText("");
- setVisible(false);
- current_npc = NULL;
- break;
- default:
- return;
- }
+ if (mState == NPC_TEXT_STATE_NEXT && current_npc) {
+ current_npc->nextDialog();
+ addText("\n> Next\n");
+ } else if (mState == NPC_TEXT_STATE_CLOSE ||
+ mState == NPC_TEXT_STATE_NEXT && !current_npc) {
+ setText("");
+ setVisible(false);
+ if (current_npc) current_npc->handleDeath();
+ } else return;
}
else return;
diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp
index 1d7cb52f..dad6af21 100644
--- a/src/gui/sell.cpp
+++ b/src/gui/sell.cpp
@@ -131,7 +131,7 @@ void SellDialog::action(const gcn::ActionEvent &event)
if (event.getId() == "quit")
{
setVisible(false);
- current_npc = 0;
+ if (current_npc) current_npc->handleDeath();
return;
}