summaryrefslogtreecommitdiff
path: root/src/npc.cpp
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-02-25 07:01:04 -0700
committerJared Adams <jaxad0127@gmail.com>2009-02-25 07:01:04 -0700
commite116e2a34ec507ab0f2ab65662a7c4ae8f587341 (patch)
tree1d7c82b3554ba56729c1bc427b8b1b3d9ba1b697 /src/npc.cpp
parenta41c61706b29b0fadf1271946a76c3b3b51239f0 (diff)
downloadmana-e116e2a34ec507ab0f2ab65662a7c4ae8f587341.tar.gz
mana-e116e2a34ec507ab0f2ab65662a7c4ae8f587341.tar.bz2
mana-e116e2a34ec507ab0f2ab65662a7c4ae8f587341.tar.xz
mana-e116e2a34ec507ab0f2ab65662a7c4ae8f587341.zip
Don't delete the current NPC too early
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;
+ }
}