summaryrefslogtreecommitdiff
path: root/src/actormanager.cpp
diff options
context:
space:
mode:
authorFedja Beader <fedja@protonmail.ch>2024-08-24 10:26:05 +0000
committerFedja Beader <fedja@protonmail.ch>2024-08-24 10:26:05 +0000
commitb1805883e8fbb3f801564c24eee56dab0d9424e4 (patch)
tree71245198286f1ae58c6fa27474c1ee69acb1a095 /src/actormanager.cpp
parentf3457a5e0f5b803ff476172f23cff9b4fdb31cbe (diff)
downloadmv-b1805883e8fbb3f801564c24eee56dab0d9424e4.tar.gz
mv-b1805883e8fbb3f801564c24eee56dab0d9424e4.tar.bz2
mv-b1805883e8fbb3f801564c24eee56dab0d9424e4.tar.xz
mv-b1805883e8fbb3f801564c24eee56dab0d9424e4.zip
Simplify itempickup code
**** mana/plus!94
Diffstat (limited to 'src/actormanager.cpp')
-rw-r--r--src/actormanager.cpp7
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;