diff options
Diffstat (limited to 'src/actormanager.cpp')
-rw-r--r-- | src/actormanager.cpp | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/src/actormanager.cpp b/src/actormanager.cpp index 9e754cae6..02eb2083b 100644 --- a/src/actormanager.cpp +++ b/src/actormanager.cpp @@ -478,8 +478,10 @@ Being *ActorManager::findBeingByPixel(const int x, const int y, if (mExtMouseTargeting) { - Being *tempBeing = nullptr; - bool noBeing(false); + // if there is no suitable being within the usual tolerance + // then return a suitable one nearby (larger tolerance). + Being *nearbyBeing = nullptr; + bool includeNearby = true; for_actorsm { @@ -492,7 +494,7 @@ Being *ActorManager::findBeingByPixel(const int x, const int y, if ((*it)->getType() == ActorType::FloorItem) { - if (!noBeing) + if (includeNearby) { const FloorItem *const floor = static_cast<const FloorItem*>(*it); @@ -503,7 +505,9 @@ Being *ActorManager::findBeingByPixel(const int x, const int y, (py - mapTileSize * 2 <= y) && (py + mapTileSize / 2 > y)) { - noBeing = true; + // flooritems cancel coarse selection, but + // we don't care about them. + includeNearby = false; } } continue; @@ -532,23 +536,26 @@ Being *ActorManager::findBeingByPixel(const int x, const int y, { return being; } - else if (!noBeing && + else if (includeNearby && (px - mapTileSize <= x) && (px + mapTileSize > x) && (py - mapTileSize * 2 <= y) && (py + mapTileSize / 2 > y)) { - if (tempBeing != nullptr) - noBeing = true; + // also disable coarse selection if more than one being + // is found nearby. + if (nearbyBeing != nullptr) + includeNearby = false; else - tempBeing = being; + nearbyBeing = being; } } } - if (noBeing) + if (includeNearby) + return nearbyBeing; + else return nullptr; - return tempBeing; } for_actorsm { |