External iterators for player items
Implements external iterators for player items.
This commit is contained in:
parent
c099f6c86c
commit
032eaf7491
4 changed files with 300 additions and 31 deletions
|
|
@ -2169,32 +2169,4 @@ bool DropItemBeforeTrig()
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Invokes f for each non-empty item of the given player; covering equipped, inventory and belt items.
|
||||
* @param player Player with equipped, inventory and belt items.
|
||||
* @param f Function to invoke on each non-empty item of the player.
|
||||
*/
|
||||
void ForEachInventoryItem(PlayerStruct &player, ItemFunc f)
|
||||
{
|
||||
// Equipped items.
|
||||
for (auto &item : player.InvBody) {
|
||||
if (!item.isEmpty()) {
|
||||
f(item);
|
||||
}
|
||||
}
|
||||
// Inventory items.
|
||||
for (int i = 0; i < player._pNumInv; i++) {
|
||||
auto &item = player.InvList[i];
|
||||
if (!item.isEmpty()) {
|
||||
f(item);
|
||||
}
|
||||
}
|
||||
// Belt items.
|
||||
for (auto &item : player.SpdList) {
|
||||
if (!item.isEmpty()) {
|
||||
f(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace devilution
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue