summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFedja Beader <fedja@protonmail.ch>2025-03-22 01:30:44 +0100
committerFedja Beader <fedja@protonmail.ch>2025-03-22 01:53:07 +0100
commitb1bfba89e00f68632536c9e71f93976c889e689b (patch)
tree1ffbcd07cd94117e228b876a8a773151dde10b6d
parent57efa1ec52af28386242767f9a68abb6836a1811 (diff)
downloadmanaplus-b1bfba89e00f68632536c9e71f93976c889e689b.tar.gz
manaplus-b1bfba89e00f68632536c9e71f93976c889e689b.tar.bz2
manaplus-b1bfba89e00f68632536c9e71f93976c889e689b.tar.xz
manaplus-b1bfba89e00f68632536c9e71f93976c889e689b.zip
findNearestLivingBeing: closest* are always set to something sensible,
making special handling before first suitable being is found unnecessary.
-rw-r--r--src/actormanager.cpp17
1 files changed, 3 insertions, 14 deletions
diff --git a/src/actormanager.cpp b/src/actormanager.cpp
index 674239da0..62d438c67 100644
--- a/src/actormanager.cpp
+++ b/src/actormanager.cpp
@@ -1370,22 +1370,11 @@ Being *ActorManager::findNearestLivingBeing(const Being *const aroundBeing,
}
else
{
- if (closestBeing != nullptr)
+ if ((priority < closestPriority && distSq <= maxDistSq) ||
+ (priority == closestPriority && distSq < closestDistSq))
{
- if ((priority < closestPriority && distSq <= maxDistSq) ||
- (priority == closestPriority && distSq < closestDistSq))
- {
- closestBeing = being;
- closestDistSq = distSq;
- closestPriority = priority;
- continue;
- }
- }
-
- if (closestBeing == nullptr && distSq <= maxDistSq)
- {
- closestBeing = being;
closestDistSq = distSq;
+ closestBeing = being;
closestPriority = priority;
}
}