From 6f2eb19e8930010892252fa3a6e14b0bc6a2d19e Mon Sep 17 00:00:00 2001 From: Fedja Beader Date: Mon, 11 Mar 2024 18:26:36 +0000 Subject: Make pickup code go to nearby tile, not on top of item. Fixes most cases of walking through doors/warps on pickup. **** --- src/being/localplayer.cpp | 22 ++++++++++++++++++---- 1 file 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); -- cgit v1.2.3-70-g09d2