diff options
author | Jared Adams <jaxad0127@gmail.com> | 2009-02-25 07:01:04 -0700 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2009-02-25 07:01:04 -0700 |
commit | e116e2a34ec507ab0f2ab65662a7c4ae8f587341 (patch) | |
tree | 1d7c82b3554ba56729c1bc427b8b1b3d9ba1b697 | |
parent | a41c61706b29b0fadf1271946a76c3b3b51239f0 (diff) | |
download | mana-e116e2a34ec507ab0f2ab65662a7c4ae8f587341.tar.gz mana-e116e2a34ec507ab0f2ab65662a7c4ae8f587341.tar.bz2 mana-e116e2a34ec507ab0f2ab65662a7c4ae8f587341.tar.xz mana-e116e2a34ec507ab0f2ab65662a7c4ae8f587341.zip |
Don't delete the current NPC too early
-rw-r--r-- | src/npc.cpp | 14 |
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; + } } |