summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFedja Beader <fedja@protonmail.ch>2025-04-09 14:38:56 +0200
committerFedja Beader <fedja@protonmail.ch>2025-04-11 00:23:12 +0200
commitb86ee282ef24a4b0dcfc923b8ed9c12468753588 (patch)
tree9208586bc54568cb7f60535f884882f7ea7fa75b
parent315588b76204ca3dfe15ac29b1e896b85f6c808d (diff)
downloadmanaplus-b86ee282ef24a4b0dcfc923b8ed9c12468753588.tar.gz
manaplus-b86ee282ef24a4b0dcfc923b8ed9c12468753588.tar.bz2
manaplus-b86ee282ef24a4b0dcfc923b8ed9c12468753588.tar.xz
manaplus-b86ee282ef24a4b0dcfc923b8ed9c12468753588.zip
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.
-rw-r--r--src/actormanager.cpp20
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;
}