diff options
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; +} |