summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFedja Beader <fedja@protonmail.ch>2024-03-11 18:26:36 +0000
committerFedja Beader <fedja@protonmail.ch>2024-03-11 18:26:36 +0000
commit6f2eb19e8930010892252fa3a6e14b0bc6a2d19e (patch)
treeefaacdf11f431d4f37c703f4415ea09a2339906c /src
parent5278bef1049758777c3a0d653edb5de2340a78b5 (diff)
downloadmanaverse-6f2eb19e8930010892252fa3a6e14b0bc6a2d19e.tar.gz
manaverse-6f2eb19e8930010892252fa3a6e14b0bc6a2d19e.tar.bz2
manaverse-6f2eb19e8930010892252fa3a6e14b0bc6a2d19e.tar.xz
manaverse-6f2eb19e8930010892252fa3a6e14b0bc6a2d19e.zip
Make pickup code go to nearby tile, not on top of item.
Fixes most cases of walking through doors/warps on pickup. ****
Diffstat (limited to 'src')
-rw-r--r--src/being/localplayer.cpp22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp
index 15d33d484..a8ffc6175 100644
--- a/src/being/localplayer.cpp
+++ b/src/being/localplayer.cpp
@@ -541,10 +541,24 @@ bool LocalPlayer::pickUp(FloorItem *const item)
item->getTileY(),
getBlockWalkMask(),
0);
- if (!debugPath.empty())
- navigateTo(item->getTileX(), item->getTileY());
- else
- setDestination(item->getTileX(), item->getTileY());
+
+ switch (debugPath.size())
+ {
+ case 0:
+ setDestination(item->getTileX(), item->getTileY());
+ break;
+ case 1:// should never happen due to above check for adjecent-tile
+ // pickup, but you never know.
+ navigateTo(item->getTileX(), item->getTileY());
+ break;
+ default:
+ {
+ // at least two spots, move nearby.
+ const Position& nearby = *(++debugPath.rbegin());
+ navigateTo(nearby.x, nearby.y);
+ break;
+ }
+ }
mPickUpTarget = item;
mPickUpTarget->addActorSpriteListener(this);