From b86ee282ef24a4b0dcfc923b8ed9c12468753588 Mon Sep 17 00:00:00 2001 From: Fedja Beader Date: Wed, 9 Apr 2025 14:38:56 +0200 Subject: Reformat ActorManager::checkForPickup for (visual) consistency with similar blocks in pickup search functions This block repeats many times.. but cannot be deduplicated without that pesky search for empty string. perhaps I should make an inline function that takes all these lists or a scoped functor that does the lookup in constructor. --- src/actormanager.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/actormanager.cpp b/src/actormanager.cpp index e33798bab..73248cab3 100644 --- a/src/actormanager.cpp +++ b/src/actormanager.cpp @@ -2071,18 +2071,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; } -- cgit v1.2.3-70-g09d2