summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFedja Beader <fedja@protonmail.ch>2025-04-06 00:17:58 +0000
committerFedja Beader <fedja@protonmail.ch>2025-04-06 00:17:58 +0000
commit0bcc88159aee0e680d4cdc2949b24b10b571135f (patch)
tree26db8ef24ef5386c945e424fe0d8489b47739364
parent149b7407b7951d289f5c41e015f1321aabc324e0 (diff)
downloadmv-0bcc88159aee0e680d4cdc2949b24b10b571135f.tar.gz
mv-0bcc88159aee0e680d4cdc2949b24b10b571135f.tar.bz2
mv-0bcc88159aee0e680d4cdc2949b24b10b571135f.tar.xz
mv-0bcc88159aee0e680d4cdc2949b24b10b571135f.zip
Refactor ActorManager::validateBeing()
Squashed with: * More docs for validateBeing * addendum documentation for validateBeing **** mana/plus!154
-rw-r--r--src/actormanager.cpp32
-rw-r--r--src/actormanager.h14
2 files changed, 40 insertions, 6 deletions
diff --git a/src/actormanager.cpp b/src/actormanager.cpp
index 2e1079487..e33798bab 100644
--- a/src/actormanager.cpp
+++ b/src/actormanager.cpp
@@ -1386,12 +1386,32 @@ bool ActorManager::validateBeing(const Being *const aroundBeing,
{
if (localPlayer == nullptr)
return false;
- return (being != nullptr) && ((being->getType() == type
- || type == ActorType::Unknown) && (being->isAlive()
- || (mTargetDeadPlayers && type == ActorType::Player))
- && being != aroundBeing) && being != excluded
- && (type != ActorType::Monster || !mTargetOnlyReachable
- || localPlayer->isReachable(being, maxCost));
+
+ if (being == nullptr)
+ return false;
+
+ if (being == aroundBeing)
+ return false;
+
+ if (being == excluded)
+ return false;
+
+ // If specific being type is given, it must match.
+ if (!(being->getType() == type || type == ActorType::Unknown))
+ return false;
+
+ if (!being->isAlive())
+ if (!mTargetDeadPlayers || type != ActorType::Player)
+ return false;
+
+ // Why are we ignoring real reachability checks for non-monsters?
+ if (type != ActorType::Monster)
+ return true;
+
+ if (!mTargetOnlyReachable)
+ return true;
+
+ return localPlayer->isReachable(being, maxCost);
}
#ifdef TMWA_SUPPORT
diff --git a/src/actormanager.h b/src/actormanager.h
index 43b9341b9..15841f61d 100644
--- a/src/actormanager.h
+++ b/src/actormanager.h
@@ -393,6 +393,20 @@ class ActorManager final : public ConfigListener
#ifndef UNITTESTS
protected:
#endif // UNITTESTS
+ /*
+ * General checks if a being is valid for selection.
+ * Additionally, localPlayer is checked to exist
+ *
+ * @param aroundBeing being must not equal this one
+ * @param being being under scrutiny. Nullptr check performed
+ * it must be alive unless a player and
+ * mTargetDeadPlayers is true.
+ * @param type pass ActorType::Unknown if no matching desired
+ * @param exluded being must not equal this one
+ * @param maxCost allowed max pathfinder distance, if applicable
+ * (only if being is a monster and
+ * mTargetOnlyReachable is true)
+ */
bool validateBeing(const Being *const aroundBeing,
Being *const being,
const ActorTypeT &type,