summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/actions/target.cpp12
-rw-r--r--src/being/localplayer.cpp16
-rw-r--r--src/being/localplayer.h4
3 files changed, 22 insertions, 10 deletions
diff --git a/src/actions/target.cpp b/src/actions/target.cpp
index f5bf636d4..a0615143c 100644
--- a/src/actions/target.cpp
+++ b/src/actions/target.cpp
@@ -35,16 +35,8 @@ namespace Actions
static bool setTarget(const ActorTypeT type, const AllowSort allowSort)
{
- if (actorManager && localPlayer)
- {
- Being *const target = actorManager->findNearestLivingBeing(
- localPlayer, 20, type, allowSort);
-
- if (target && target != localPlayer->getTarget())
- localPlayer->setTarget(target);
-
- return true;
- }
+ if (localPlayer)
+ return localPlayer->setNewTarget(type, allowSort) != nullptr;
return false;
}
diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp
index 6722d5a4b..cde59bd7a 100644
--- a/src/being/localplayer.cpp
+++ b/src/being/localplayer.cpp
@@ -554,6 +554,22 @@ void LocalPlayer::setTarget(Being *const target)
target->setShowName(true);
}
+Being *LocalPlayer::setNewTarget(const ActorTypeT type,
+ const AllowSort allowSort)
+{
+ if (actorManager)
+ {
+ Being *const target = actorManager->findNearestLivingBeing(
+ localPlayer, 20, type, allowSort);
+
+ if (target && target != mTarget)
+ localPlayer->setTarget(target);
+
+ return target;
+ }
+ return nullptr;
+}
+
void LocalPlayer::setDestination(const int x, const int y)
{
mActivityTime = cur_time;
diff --git a/src/being/localplayer.h b/src/being/localplayer.h
index c258a14f1..e47ad4d20 100644
--- a/src/being/localplayer.h
+++ b/src/being/localplayer.h
@@ -27,6 +27,7 @@
#include "enums/being/pickup.h"
+#include "enums/simpletypes/allowsort.h"
#include "enums/simpletypes/keep.h"
#include "listeners/actorspritelistener.h"
@@ -132,6 +133,9 @@ class LocalPlayer final : public Being,
*/
void setTarget(Being *const target);
+ Being *setNewTarget(const ActorTypeT type,
+ const AllowSort allowSort);
+
/**
* Sets a new destination for this being to walk to.
*/