diff options
author | Fedja Beader <fedja@protonmail.ch> | 2025-04-14 15:30:51 +0000 |
---|---|---|
committer | Fedja Beader <fedja@protonmail.ch> | 2025-04-14 15:30:51 +0000 |
commit | 46e7eb648e9121b53c274b69ddb3301877fc480d (patch) | |
tree | 31af9e98a472c95075d708aa6b617de0234f7815 | |
parent | f9722872ce079aee96f41431616c2d6fc61d85d2 (diff) | |
download | manaplus-46e7eb648e9121b53c274b69ddb3301877fc480d.tar.gz manaplus-46e7eb648e9121b53c274b69ddb3301877fc480d.tar.bz2 manaplus-46e7eb648e9121b53c274b69ddb3301877fc480d.tar.xz manaplus-46e7eb648e9121b53c274b69ddb3301877fc480d.zip |
Reformat ActorManager::checkForPickup for (visual) consistency with similar blocks in pickup search functions
This block repeats many times.. but cannot be de-duplicated without that
pesky search for empty string. perhaps I should make an (inline) function
that takes allowAll and the item or a scoped functor that does the lookup in
constructor.
****
mana/plus!166
-rw-r--r-- | src/actormanager.cpp | 20 |
1 files 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; } |