summaryrefslogtreecommitdiff
path: root/src/actorsprite.cpp
diff options
context:
space:
mode:
authorremoitnane <remoit(DOT)nane(AT)gmail(DOT)com>2010-07-07 03:59:33 -0700
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2010-07-08 22:33:31 +0200
commit27efdd9a80c7d068f27db8725c2315fee3e10303 (patch)
tree2699a54961f6c29249c9d48747b8938b2d99dbd1 /src/actorsprite.cpp
parentf1cab9c5ab1d36586ae1e0d1dae3f3d1483522b5 (diff)
downloadmana-27efdd9a80c7d068f27db8725c2315fee3e10303.tar.gz
mana-27efdd9a80c7d068f27db8725c2315fee3e10303.tar.bz2
mana-27efdd9a80c7d068f27db8725c2315fee3e10303.tar.xz
mana-27efdd9a80c7d068f27db8725c2315fee3e10303.zip
Fix crash in picking up an item that no longer exists
Adds ActorSpriteListener to manage ActorSprite destruction as recommended by Jaxad0127. This likewise includes the changes made by Bertram. Reviewed-by: Jaxad0127, Bertram. Resolves: Manasource Mantis #160
Diffstat (limited to 'src/actorsprite.cpp')
-rw-r--r--src/actorsprite.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/actorsprite.cpp b/src/actorsprite.cpp
index 13b7abf2..6a1dcbc7 100644
--- a/src/actorsprite.cpp
+++ b/src/actorsprite.cpp
@@ -19,6 +19,7 @@
*/
#include "actorsprite.h"
+#include "actorspritelistener.h"
#include "client.h"
#include "effectmanager.h"
@@ -64,6 +65,11 @@ ActorSprite::~ActorSprite()
if (player_node && player_node->getTarget() == this)
player_node->setTarget(NULL);
+
+ // Notify listeners of the destruction.
+ for (ActorSpriteListenerIterator iter = mActorSpriteListeners.begin(),
+ end = mActorSpriteListeners.end(); iter != end; ++iter)
+ (*iter)->actorSpriteDestroyed(*this);
}
bool ActorSprite::draw(Graphics *graphics, int offsetX, int offsetY) const
@@ -358,6 +364,16 @@ void ActorSprite::unload()
loaded = false;
}
+void ActorSprite::addActorSpriteListener(ActorSpriteListener *listener)
+{
+ mActorSpriteListeners.push_front(listener);
+}
+
+void ActorSprite::removeActorSpriteListener(ActorSpriteListener *listener)
+{
+ mActorSpriteListeners.remove(listener);
+}
+
static const char *cursorType(int type)
{
switch (type)