summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-05-06 17:00:00 +0300
committerAndrei Karas <akaras@inbox.ru>2015-05-06 17:00:00 +0300
commit21e0c15d56438f2d7f3e15736c00dd8b8ac6bd1c (patch)
tree2e366420e85c18fc4c687cc7ab5d1dd2f46df365 /src
parent5b0c6c5c95645813f96ea413b1c14f2ffc18a481 (diff)
downloadplus-21e0c15d56438f2d7f3e15736c00dd8b8ac6bd1c.tar.gz
plus-21e0c15d56438f2d7f3e15736c00dd8b8ac6bd1c.tar.bz2
plus-21e0c15d56438f2d7f3e15736c00dd8b8ac6bd1c.tar.xz
plus-21e0c15d56438f2d7f3e15736c00dd8b8ac6bd1c.zip
Add strong typed bool type AllowSort.
Diffstat (limited to 'src')
-rw-r--r--src/actions/actions.cpp10
-rw-r--r--src/actions/target.cpp14
-rw-r--r--src/actormanager.cpp10
-rw-r--r--src/actormanager.h4
-rw-r--r--src/enums/simpletypes.h1
-rw-r--r--src/utils/chatutils.cpp4
6 files changed, 22 insertions, 21 deletions
diff --git a/src/actions/actions.cpp b/src/actions/actions.cpp
index d80949865..d2905a27e 100644
--- a/src/actions/actions.cpp
+++ b/src/actions/actions.cpp
@@ -196,7 +196,7 @@ static Being *findBeing(const std::string &name)
if (!being)
{
being = actorManager->findNearestLivingBeing(
- localPlayer, 1, ActorType::Npc, true);
+ localPlayer, 1, ActorType::Npc, AllowSort_true);
if (being)
{
if (abs(being->getTileX() - localPlayer->getTileX()) > 1
@@ -209,7 +209,7 @@ static Being *findBeing(const std::string &name)
if (!being)
{
being = actorManager->findNearestLivingBeing(
- localPlayer, 1, ActorType::Player, true);
+ localPlayer, 1, ActorType::Player, AllowSort_true);
if (being)
{
if (abs(being->getTileX() - localPlayer->getTileX()) > 1
@@ -499,7 +499,7 @@ impHandler(heal)
if (!target || target->getType() != ActorType::Player)
{
target = actorManager->findNearestLivingBeing(
- localPlayer, 10, ActorType::Player, true);
+ localPlayer, 10, ActorType::Player, AllowSort_true);
}
}
else
@@ -788,7 +788,7 @@ impHandler(targetAttack)
{
// Only auto target Monsters
target = actorManager->findNearestLivingBeing(
- localPlayer, 90, ActorType::Monster, true);
+ localPlayer, 90, ActorType::Monster, AllowSort_true);
}
localPlayer->attack2(target, newTarget);
@@ -803,7 +803,7 @@ impHandler0(attackHuman)
return false;
Being *const target = actorManager->findNearestLivingBeing(
- localPlayer, 10, ActorType::Player, true);
+ localPlayer, 10, ActorType::Player, AllowSort_true);
if (target)
{
if (localPlayer->checAttackPermissions(target))
diff --git a/src/actions/target.cpp b/src/actions/target.cpp
index b4a2c8058..2c18b80f2 100644
--- a/src/actions/target.cpp
+++ b/src/actions/target.cpp
@@ -33,7 +33,7 @@
namespace Actions
{
-static bool setTarget(const ActorType::Type type, const bool allowSort)
+static bool setTarget(const ActorType::Type type, const AllowSort allowSort)
{
if (actorManager && localPlayer)
{
@@ -50,28 +50,28 @@ static bool setTarget(const ActorType::Type type, const bool allowSort)
impHandler0(targetPlayer)
{
- return setTarget(ActorType::Player, true);
+ return setTarget(ActorType::Player, AllowSort_true);
}
impHandler0(targetMonster)
{
- return setTarget(ActorType::Monster, true);
+ return setTarget(ActorType::Monster, AllowSort_true);
}
impHandler0(targetClosestMonster)
{
- return setTarget(ActorType::Monster, false);
+ return setTarget(ActorType::Monster, AllowSort_false);
}
impHandler0(targetNPC)
{
- return setTarget(ActorType::Npc, true);
+ return setTarget(ActorType::Npc, AllowSort_true);
}
impHandler0(targetMercenary)
{
#ifdef EATHENA_SUPPORT
- return setTarget(ActorType::Mercenary, true);
+ return setTarget(ActorType::Mercenary, AllowSort_true);
#else
return false;
#endif
@@ -80,7 +80,7 @@ impHandler0(targetMercenary)
impHandler0(targetPet)
{
#ifdef EATHENA_SUPPORT
- return setTarget(ActorType::Pet, true);
+ return setTarget(ActorType::Pet, AllowSort_true);
#else
return false;
#endif
diff --git a/src/actormanager.cpp b/src/actormanager.cpp
index 1df31fbeb..e32eda6f1 100644
--- a/src/actormanager.cpp
+++ b/src/actormanager.cpp
@@ -891,13 +891,13 @@ Being *ActorManager::findNearestLivingBeing(const int x, const int y,
type,
x, y,
excluded,
- true);
+ AllowSort_true);
}
Being *ActorManager::findNearestLivingBeing(const Being *const aroundBeing,
const int maxDist,
const ActorType::Type type,
- const bool allowSort) const
+ const AllowSort allowSort) const
{
if (!aroundBeing)
return nullptr;
@@ -916,7 +916,7 @@ Being *ActorManager::findNearestLivingBeing(const Being *const aroundBeing,
const ActorType::Type &type,
const int x, const int y,
const Being *const excluded,
- const bool allowSort) const
+ const AllowSort allowSort) const
{
if (!aroundBeing || !localPlayer)
return nullptr;
@@ -939,12 +939,12 @@ Being *ActorManager::findNearestLivingBeing(const Being *const aroundBeing,
maxDist = maxDist * maxDist;
- const bool cycleSelect = allowSort
+ const bool cycleSelect = allowSort == AllowSort_true
&& ((mCyclePlayers && type == ActorType::Player)
|| (mCycleMonsters && type == ActorType::Monster)
|| (mCycleNPC && type == ActorType::Npc));
- const bool filtered = allowSort
+ const bool filtered = allowSort == AllowSort_true
&& config.getBoolValue("enableAttackFilter")
&& type == ActorType::Monster;
const bool modActive = inputManager.isActionActive(
diff --git a/src/actormanager.h b/src/actormanager.h
index ae4b7217f..9d0bc261c 100644
--- a/src/actormanager.h
+++ b/src/actormanager.h
@@ -158,7 +158,7 @@ class ActorManager final: public ConfigListener
Being *findNearestLivingBeing(const Being *const aroundBeing,
const int maxTileDist,
const ActorType::Type type,
- const bool allowSort)
+ const AllowSort allowSort)
const A_WARN_UNUSED;
/**
@@ -341,7 +341,7 @@ class ActorManager final: public ConfigListener
const ActorType::Type &type,
const int x, const int y,
const Being *const excluded,
- const bool allowSort)
+ const AllowSort allowSort)
const A_WARN_UNUSED;
void loadAttackList();
diff --git a/src/enums/simpletypes.h b/src/enums/simpletypes.h
index 21b0e03cc..a86e2629b 100644
--- a/src/enums/simpletypes.h
+++ b/src/enums/simpletypes.h
@@ -60,5 +60,6 @@ defBoolEnum(Sfx);
defBoolEnum(Keep);
defBoolEnum(Modifiable);
defBoolEnum(AllPlayers);
+defBoolEnum(AllowSort);
#endif // ENUMS_SIMPLETYPES_H
diff --git a/src/utils/chatutils.cpp b/src/utils/chatutils.cpp
index 903c6eefa..794a21330 100644
--- a/src/utils/chatutils.cpp
+++ b/src/utils/chatutils.cpp
@@ -115,7 +115,7 @@ void replaceVars(std::string &str)
if (!target || target->getType() != ActorType::Player)
{
target = actorManager->findNearestLivingBeing(
- localPlayer, 20, ActorType::Player, true);
+ localPlayer, 20, ActorType::Player, AllowSort_true);
}
if (target)
replaceAll(str, "<PLAYER>", target->getName());
@@ -128,7 +128,7 @@ void replaceVars(std::string &str)
if (!target || target->getType() != ActorType::Monster)
{
target = actorManager->findNearestLivingBeing(
- localPlayer, 20, ActorType::Monster, true);
+ localPlayer, 20, ActorType::Monster, AllowSort_true);
}
if (target)
replaceAll(str, "<MONSTER>", target->getName());