From 9568a305878d0c035e027c1ed6c9a24147a0adea Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Wed, 18 Feb 2009 06:57:16 +0000 Subject: Centralize current_npc cleanup --- src/gui/npc_text.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'src/gui/npc_text.cpp') 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; -- cgit v1.2.3-70-g09d2