diff options
Diffstat (limited to 'src/beingmanager.cpp')
-rw-r--r-- | src/beingmanager.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/beingmanager.cpp b/src/beingmanager.cpp index 631aadab..a92e3faf 100644 --- a/src/beingmanager.cpp +++ b/src/beingmanager.cpp @@ -193,7 +193,8 @@ void BeingManager::clear() Being *BeingManager::findNearestLivingBeing(int x, int y, int maxTileDist, - ActorSprite::Type type) const + ActorSprite::Type type, + Being *excluded) const { Being *closestBeing = 0; int dist = 0; @@ -210,8 +211,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 == ActorSprite::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; @@ -225,7 +227,8 @@ Being *BeingManager::findNearestLivingBeing(Being *aroundBeing, int maxDist, ActorSprite::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 |