diff options
author | remoitnane <remoit(DOT)nane(AT)gmail(DOT)com> | 2010-07-07 03:59:33 -0700 |
---|---|---|
committer | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2010-07-08 22:33:31 +0200 |
commit | 27efdd9a80c7d068f27db8725c2315fee3e10303 (patch) | |
tree | 2699a54961f6c29249c9d48747b8938b2d99dbd1 /src/localplayer.cpp | |
parent | f1cab9c5ab1d36586ae1e0d1dae3f3d1483522b5 (diff) | |
download | mana-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/localplayer.cpp')
-rw-r--r-- | src/localplayer.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 96062867..15047f5a 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -686,6 +686,9 @@ void LocalPlayer::setInvItem(int index, int id, int amount) void LocalPlayer::pickUp(FloorItem *item) { + if (!item) + return; + int dx = item->getTileX() - (int) getPosition().x / 32; int dy = item->getTileY() - (int) getPosition().y / 32; @@ -700,16 +703,24 @@ void LocalPlayer::pickUp(FloorItem *item) { setDestination(item->getPixelX() + 16, item->getPixelY() + 16); mPickUpTarget = item; + mPickUpTarget->addActorSpriteListener(this); } else { setDestination(item->getTileX(), item->getTileY()); mPickUpTarget = item; + mPickUpTarget->addActorSpriteListener(this); stopAttack(); } } } +void LocalPlayer::actorSpriteDestroyed(const ActorSprite &actorSprite) +{ + if (mPickUpTarget == &actorSprite) + mPickUpTarget = 0; +} + Being *LocalPlayer::getTarget() const { return mTarget; |