diff --git a/src/character.cpp b/src/character.cpp index fbab19264d809..1e8805d63ded2 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -2349,6 +2349,20 @@ std::vector Character::all_items_loc() return ret; } +std::vector Character::top_items_loc() +{ + std::vector ret; + if( has_weapon() ) { + item_location weap_loc( *this, &weapon ); + ret.push_back( weap_loc ); + } + for( item &worn_it : worn ) { + item_location worn_loc( *this, &worn_it ); + ret.push_back( worn_loc ); + } + return ret; +} + item *Character::invlet_to_item( const int linvlet ) { // Invlets may come from curses, which may also return any kind of key codes, those being diff --git a/src/character.h b/src/character.h index a3addead9a5e7..dcd133328d6cd 100644 --- a/src/character.h +++ b/src/character.h @@ -1229,6 +1229,8 @@ class Character : public Creature, public visitable // returns a list of all item_location the character has, including items contained in other items. // only for CONTAINER pocket type; does not look for magazines std::vector all_items_loc(); + // Returns list of all the top level item_lodation the character has. Includes worn and held items. + std::vector top_items_loc(); /** Return the item pointer of the item with given invlet, return nullptr if * the player does not have such an item with that invlet. Don't use this on npcs. * Only use the invlet in the user interface, otherwise always use the item position. */ diff --git a/src/player.cpp b/src/player.cpp index 7acd1df8bfe80..5b95a4df8d723 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -1763,7 +1763,7 @@ void player::process_items() } std::vector removed_items; - for( item_location it : all_items_loc() ) { + for( item_location it : top_items_loc() ) { if( !it ) { continue; } @@ -1777,11 +1777,6 @@ void player::process_items() removed.remove_item(); } - // worn items - remove_worn_items_with( [this]( item & itm ) { - return itm.needs_processing() && itm.process( this, pos(), false ); - } ); - // Active item processing done, now we're recharging. item *cloak = nullptr; item *power_armor = nullptr;