diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/being/localplayer.cpp | 22 |
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); |