summaryrefslogtreecommitdiff
path: root/src/beingmanager.cpp
diff options
context:
space:
mode:
authorNo Name <remoit(DOT)nane(AT)gmail(DOT)com>2010-04-22 05:41:08 -0700
committerJared Adams <jaxad0127@gmail.com>2010-04-22 20:58:23 -0600
commit4fb390a44431f3984cf21a4b719803a1977593c2 (patch)
tree6342ad006823c314732223fcb0e9066424717b26 /src/beingmanager.cpp
parent93d4de19fdffb6d568c907729449f169c3520c7b (diff)
downloadmana-4fb390a44431f3984cf21a4b719803a1977593c2.tar.gz
mana-4fb390a44431f3984cf21a4b719803a1977593c2.tar.bz2
mana-4fb390a44431f3984cf21a4b719803a1977593c2.tar.xz
mana-4fb390a44431f3984cf21a4b719803a1977593c2.zip
Fix keyboard target selection to allow player targeting
Modifies BeingManager::findNearestLivingBeing() behaviour to exclude an optional being from the search. Signed-off-by: Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> Signed-off-by: Jared Adams <jaxad0127@gmail.com>
Diffstat (limited to 'src/beingmanager.cpp')
-rw-r--r--src/beingmanager.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/beingmanager.cpp b/src/beingmanager.cpp
index 26672de0..656b297e 100644
--- a/src/beingmanager.cpp
+++ b/src/beingmanager.cpp
@@ -213,8 +213,8 @@ void BeingManager::clear()
}
Being *BeingManager::findNearestLivingBeing(int x, int y,
- int maxTileDist,
- Being::Type type) const
+ int maxTileDist, Being::Type type,
+ Being *excluded) const
{
Being *closestBeing = 0;
int dist = 0;
@@ -231,8 +231,9 @@ Being *BeingManager::findNearestLivingBeing(int x, int y,
int d = abs(((int) pos.x) - x) + abs(((int) pos.y) - y);
if ((being->getType() == type || type == Being::UNKNOWN)
- && (d < dist || !closestBeing) // it is closer
- && being->isAlive()) // no dead beings
+ && (d < dist || !closestBeing) // it is closer
+ && being->isAlive() // no dead beings
+ && being != excluded)
{
dist = d;
closestBeing = being;
@@ -246,7 +247,8 @@ Being *BeingManager::findNearestLivingBeing(Being *aroundBeing, int maxDist,
Being::Type type) const
{
const Vector &pos = aroundBeing->getPosition();
- return findNearestLivingBeing((int)pos.x, (int)pos.y, maxDist, type);
+ return findNearestLivingBeing((int)pos.x, (int)pos.y, maxDist, type,
+ aroundBeing);
}
bool BeingManager::hasBeing(Being *being) const