diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/actormanager.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/actormanager.cpp b/src/actormanager.cpp index 7dcfdf578..f1c61318e 100644 --- a/src/actormanager.cpp +++ b/src/actormanager.cpp @@ -824,7 +824,7 @@ bool ActorManager::pickUpNearest(const int x, const int y, maxdist = maxdist * maxdist; // avoids calculating square root FloorItem *closestItem = nullptr; - int dist = 0; + int dist = maxdist + 1; // if "default" is in pickup items set, then the ignore list acts // as a blacklist. Otherwise, the pickup list acts as a whitelist. @@ -845,7 +845,7 @@ bool ActorManager::pickUpNearest(const int x, const int y, const int dy = item->getTileY() - y; const int d = dx*dx + dy*dy; - if ((d < dist || closestItem == nullptr) && + if ((d < dist) && (!mTargetOnlyReachable || localPlayer->isReachable( item->getTileX(), item->getTileY(), false))) @@ -871,7 +871,8 @@ bool ActorManager::pickUpNearest(const int x, const int y, } } } - if ((closestItem != nullptr) && dist <= maxdist) + + if (closestItem != nullptr) return localPlayer->pickUp(closestItem); return false; |