diff options
Diffstat (limited to 'src/actormanager.cpp')
-rw-r--r-- | src/actormanager.cpp | 71 |
1 files changed, 44 insertions, 27 deletions
diff --git a/src/actormanager.cpp b/src/actormanager.cpp index e33798bab..db5e8313f 100644 --- a/src/actormanager.cpp +++ b/src/actormanager.cpp @@ -1,11 +1,11 @@ /* - * The ManaPlus Client + * The ManaVerse Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers * Copyright (C) 2011-2020 The ManaPlus Developers - * Copyright (C) 2020-2023 The ManaVerse Developers + * Copyright (C) 2020-2025 The ManaVerse Developers * - * This file is part of The ManaPlus Client. + * This file is part of The ManaVerse Client. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -48,6 +48,7 @@ #include "utils/foreach.h" #include "utils/mathutils.h" #include "utils/gettext.h" +#include "utils/performance.h" #include "net/beinghandler.h" #include "net/charserverhandler.h" @@ -473,14 +474,15 @@ Being *ActorManager::findBeingByPixel(const int x, const int y, if (mMap == nullptr) return nullptr; - const bool targetDead = mTargetDeadPlayers; const bool modActive = inputManager.isActionActive( InputAction::STOP_ATTACK); 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 { @@ -493,7 +495,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); @@ -504,7 +506,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; @@ -518,8 +522,10 @@ Being *ActorManager::findBeingByPixel(const int x, const int y, continue; } - if ((being->mAction != BeingAction::DEAD || - (targetDead && being->getType() == ActorType::Player)) && + // dead players have to be returned so you can still see + // their equipment, do whisper or trade (yes you can trade + // with the dead :D) or use any other option in the menu. + if ((being->isAlive() || being->getType() == ActorType::Player) && (allPlayers == AllPlayers_true || being != localPlayer)) { const int px = being->getPixelX(); @@ -531,23 +537,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 { @@ -636,11 +645,11 @@ void ActorManager::findBeingsByPixel(STD_VECTOR<ActorSprite*> &beings, { continue; } - if ((being->isAlive() || - (mTargetDeadPlayers && - actorType == ActorType::Player)) && - (allPlayers == AllPlayers_true || - being != localPlayer)) + // dead players have to be returned so you can still see + // their equipment, do whisper or trade (yes you can trade + // with the dead :D) or use any other option in the menu. + if ((being->isAlive() || actorType == ActorType::Player) && + (allPlayers == AllPlayers_true || being != localPlayer)) { if ((actor->getPixelX() - xtol <= x) && (actor->getPixelX() + xtol > x) && @@ -2071,18 +2080,26 @@ void ActorManager::storeAttackList() const bool ActorManager::checkForPickup(const FloorItem *const item) const { - if (mPickupItemsSet.find(std::string()) != mPickupItemsSet.end()) + // if "default" is in pickup items set, then the ignore list acts + // as a blacklist. Otherwise, the pickup list acts as a whitelist. + const bool allowAll = mPickupItemsSet.find(std::string()) + != mPickupItemsSet.end(); + + if (allowAll) { - if (mIgnorePickupItemsSet.find(item->getName()) - == mIgnorePickupItemsSet.end()) + if (mIgnorePickupItemsSet.find(item->getName()) == + mIgnorePickupItemsSet.end()) { return true; } } - else if ((item != nullptr) && mPickupItemsSet.find(item->getName()) - != mPickupItemsSet.end()) + else { - return true; + if (mPickupItemsSet.find(item->getName()) != + mPickupItemsSet.end()) + { + return true; + } } return false; } |