summaryrefslogtreecommitdiff
path: root/src/npc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/npc.cpp')
-rw-r--r--src/npc.cpp14
1 files changed, 11 insertions, 3 deletions
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;
+ }
}