summaryrefslogtreecommitdiff
path: root/src/npc.cpp
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-02-25 07:54:38 -0700
committerJared Adams <jaxad0127@gmail.com>2009-02-25 07:54:38 -0700
commit7a65eb17a322cb22e7940504797844114fb77d79 (patch)
treec961a8bb4d43f557bf7b4d3b1977fd27a0f8303f /src/npc.cpp
parenta996d4bff3cc5a35ee5cdb6cb5bdef920cf44120 (diff)
downloadmana-client-7a65eb17a322cb22e7940504797844114fb77d79.tar.gz
mana-client-7a65eb17a322cb22e7940504797844114fb77d79.tar.bz2
mana-client-7a65eb17a322cb22e7940504797844114fb77d79.tar.xz
mana-client-7a65eb17a322cb22e7940504797844114fb77d79.zip
Fix some problems with deleting NPCs early
Diffstat (limited to 'src/npc.cpp')
-rw-r--r--src/npc.cpp12
1 files changed, 3 insertions, 9 deletions
diff --git a/src/npc.cpp b/src/npc.cpp
index 701e280b..658334bc 100644
--- a/src/npc.cpp
+++ b/src/npc.cpp
@@ -75,12 +75,6 @@ NPC::NPC(Uint32 id, Uint16 job, Map *map, Network *network):
NPC::~NPC()
{
- if (current_npc == this) // Don't delete if current NPC
- {
- handleDeath();
- return;
- }
-
delete mName;
}
@@ -112,7 +106,7 @@ Being::Type NPC::getType() const
void NPC::talk()
{
- if (!mNetwork) return;
+ if (!this || !mNetwork) return;
MessageOut outMsg(mNetwork);
outMsg.writeInt16(CMSG_NPC_TALK);
outMsg.writeInt32(mId);
@@ -121,7 +115,7 @@ void NPC::talk()
void NPC::nextDialog()
{
- if (!mNetwork) return;
+ if (!this || !mNetwork) return;
MessageOut outMsg(mNetwork);
outMsg.writeInt16(CMSG_NPC_NEXT_REQUEST);
outMsg.writeInt32(mId);
@@ -187,7 +181,7 @@ void NPC::handleDeath()
if (npcTextDialog->isVisible())
npcTextDialog->showCloseButton();
- else {
+ else if (current_npc) {
NPC *temp = current_npc;
current_npc = NULL;
delete temp;