summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIra Rice <irarice@gmail.com>2009-02-16 18:26:35 -0700
committerIra Rice <irarice@gmail.com>2009-02-16 18:26:35 -0700
commitfb0626ebec688dfd1b4fe4d8c324c2f7b34fada2 (patch)
treeafcf3c4dd7d8d9a76f2865a0fa2296d00bcc350d
parenta739b7d2936bc1074edc4703bd06605162efd166 (diff)
downloadmana-client-fb0626ebec688dfd1b4fe4d8c324c2f7b34fada2.tar.gz
mana-client-fb0626ebec688dfd1b4fe4d8c324c2f7b34fada2.tar.bz2
mana-client-fb0626ebec688dfd1b4fe4d8c324c2f7b34fada2.tar.xz
mana-client-fb0626ebec688dfd1b4fe4d8c324c2f7b34fada2.zip
Moved target unsetting on NPCs and monsters to the being class. This is
done to ensure that the client doesn't crash if the target dies and is removed from the map (since target drawing is based off of the specific target reporting its x and y coordinates). Signed-off-by: Ira Rice <irarice@gmail.com>
-rw-r--r--src/being.cpp4
-rw-r--r--src/monster.cpp6
-rw-r--r--src/npc.cpp4
3 files changed, 5 insertions, 9 deletions
diff --git a/src/being.cpp b/src/being.cpp
index 8e07514f..c944bcf9 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -29,6 +29,7 @@
#include "effectmanager.h"
#include "game.h"
#include "graphics.h"
+#include "localplayer.h"
#include "log.h"
#include "map.h"
#include "particle.h"
@@ -128,6 +129,9 @@ Being::~Being()
delete_all(mSprites);
clearPath();
+ if (player_node->getTarget() == this)
+ player_node->setTarget(NULL);
+
setMap(NULL);
instances--;
diff --git a/src/monster.cpp b/src/monster.cpp
index cc529196..f5687ef6 100644
--- a/src/monster.cpp
+++ b/src/monster.cpp
@@ -77,11 +77,7 @@ Monster::Monster(Uint32 id, Uint16 job, Map *map):
Monster::~Monster()
{
- if (mText)
- {
- delete mText;
- player_node->setTarget(NULL);
- }
+ delete mText;
}
void Monster::logic()
diff --git a/src/npc.cpp b/src/npc.cpp
index 1088a082..5540350a 100644
--- a/src/npc.cpp
+++ b/src/npc.cpp
@@ -21,7 +21,6 @@
*/
#include "animatedsprite.h"
-#include "localplayer.h"
#include "npc.h"
#include "particle.h"
#include "text.h"
@@ -74,9 +73,6 @@ NPC::NPC(Uint32 id, Uint16 job, Map *map, Network *network):
NPC::~NPC()
{
delete mName;
-
- if (player_node->getTarget() == this)
- player_node->setTarget(NULL);
}
void NPC::setName(const std::string &name)