diff options
author | Jared Adams <jaxad0127@gmail.com> | 2009-02-18 06:57:16 +0000 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2009-02-18 06:57:16 +0000 |
commit | 9568a305878d0c035e027c1ed6c9a24147a0adea (patch) | |
tree | ca6f2d1d61114f11057938c654ec004042412f1f /src/npc.cpp | |
parent | a0edd2e04b263faa13f6fbfbb81dd7c64520e584 (diff) | |
download | mana-9568a305878d0c035e027c1ed6c9a24147a0adea.tar.gz mana-9568a305878d0c035e027c1ed6c9a24147a0adea.tar.bz2 mana-9568a305878d0c035e027c1ed6c9a24147a0adea.tar.xz mana-9568a305878d0c035e027c1ed6c9a24147a0adea.zip |
Centralize current_npc cleanup
Diffstat (limited to 'src/npc.cpp')
-rw-r--r-- | src/npc.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/npc.cpp b/src/npc.cpp index b3dd7b11..92db9373 100644 --- a/src/npc.cpp +++ b/src/npc.cpp @@ -24,12 +24,16 @@ #include "particle.h" #include "text.h" +#include "gui/npc_text.h" + #include "net/messageout.h" #include "net/protocol.h" #include "resources/npcdb.h" -NPC *current_npc = 0; +extern NpcTextDialog *npcTextDialog; + +NPC *current_npc = NULL; static const int NAME_X_OFFSET = 15; static const int NAME_Y_OFFSET = 30; @@ -72,6 +76,8 @@ NPC::NPC(Uint32 id, Uint16 job, Map *map, Network *network): NPC::~NPC() { delete mName; + + if (current_npc == this) handleDeath(); } void NPC::setName(const std::string &name) @@ -169,3 +175,13 @@ void NPC::updateCoords() mName->adviseXY(mPx + NAME_X_OFFSET, mPy + NAME_Y_OFFSET); } } + +void NPC::handleDeath() +{ + printf("NPC::handleDeath\n"); + if (this != current_npc) return; + + if (npcTextDialog->isVisible()) + npcTextDialog->showCloseButton(); + else current_npc = NULL; +} |