diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/actormanager.cpp | 27 | ||||
-rw-r--r-- | src/actormanager.h | 15 |
2 files changed, 30 insertions, 12 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 { diff --git a/src/actormanager.h b/src/actormanager.h index 15841f61d..43c47ea91 100644 --- a/src/actormanager.h +++ b/src/actormanager.h @@ -136,14 +136,25 @@ class ActorManager final : public ConfigListener const ActorTypeT type) const A_WARN_UNUSED; /** - * Returns a being at the specific pixel. + * Returns a being roughly under the specified pixel (or nullptr). + * + * if Extended Mouse Targetting is enabled and no being is found + * using the usual tolerance, then a larger tolerance will be used. + * + * @param x,y pixel position + * @param allPlayers true to include localPlayer (ignored when + * Extended mouse targetting is disabled) */ Being *findBeingByPixel(const int x, const int y, const AllPlayers allPlayers) const A_WARN_UNUSED; /** - * Returns a beings at the specific pixel. + * Returns beings roughly under the specified pixel. + * + * @param beings return vector of beings found under pixel. + * @param x,y pixel position + * @param allPlayers true to include localPlayer */ void findBeingsByPixel(STD_VECTOR<ActorSprite*> &beings, const int x, const int y, |