summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFedja Beader <fedja@protonmail.ch>2025-03-22 01:30:44 +0100
committerFedja Beader <fedja@protonmail.ch>2025-04-06 01:44:21 +0200
commitc9d7b8b46cb59b0505efbb163b15d8c503cec3fb (patch)
treec7c42ac4186bcd918cceea3b780a0ead4f793b62
parent8c2e9a74037e673c3cd9c11294fd48255c52706e (diff)
downloadplus-c9d7b8b46cb59b0505efbb163b15d8c503cec3fb.tar.gz
plus-c9d7b8b46cb59b0505efbb163b15d8c503cec3fb.tar.bz2
plus-c9d7b8b46cb59b0505efbb163b15d8c503cec3fb.tar.xz
plus-c9d7b8b46cb59b0505efbb163b15d8c503cec3fb.zip
findNearestLivingBeing: closest* are always set to something sensible,
making special handling before first suitable being is found unnecessary. **** mana/plus!145
-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;
}
}