From e116e2a34ec507ab0f2ab65662a7c4ae8f587341 Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Wed, 25 Feb 2009 07:01:04 -0700 Subject: Don't delete the current NPC too early --- src/npc.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/npc.cpp') diff --git a/src/npc.cpp b/src/npc.cpp index dff1e299..0d568309 100644 --- a/src/npc.cpp +++ b/src/npc.cpp @@ -75,9 +75,13 @@ NPC::NPC(Uint32 id, Uint16 job, Map *map, Network *network): NPC::~NPC() { - delete mName; + if (current_npc == this) // Don't delete if current NPC + { + handleDeath(); + return; + } - if (current_npc == this) handleDeath(); + delete mName; } void NPC::setName(const std::string &name) @@ -181,5 +185,9 @@ void NPC::handleDeath() if (npcTextDialog->isVisible()) npcTextDialog->showCloseButton(); - else current_npc = NULL; + else { + NPC *temp = current_npc; + current_npc = NULL; + delete temp; + } } -- cgit v1.2.3-70-g09d2