Skip to content

Commit

Permalink
Call is_compatible later and on a fresh copy
Browse files Browse the repository at this point in the history
This will save some repeated calls and allow showing items that were only excluded because they were full of stuff at the time.
  • Loading branch information
CalKerethi committed Feb 15, 2022
1 parent 2632090 commit 32b32ac
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/item_contents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,7 @@ bool pocket_favorite_callback::key( const input_context &, const input_event &ev
cata::flat_set<itype_id> nearby_itypes;
selector_menu.title = _( "Select an item from nearby" );
for( const std::list<item> *it_list : get_player_character().crafting_inventory().const_slice() ) {
item it = it_list->front();
if( !it.is_null() && selected_pocket->is_compatible( it ).success() ) {
nearby_itypes.insert( it.typeId() );
}
nearby_itypes.insert( it_list->front().typeId() );
}

std::vector<std::pair<itype_id, std::string>> listed_names;
Expand All @@ -168,7 +165,7 @@ bool pocket_favorite_callback::key( const input_context &, const input_event &ev
listed_names.emplace_back( id, id->nname( 1 ) );
}
for( const itype_id &id : nearby_itypes ) {
if( !listed_itypes.count( id ) ) {
if( !listed_itypes.count( id ) && selected_pocket->is_compatible( item( id ) ).success() ) {
nearby_names.emplace_back( id, id->nname( 1 ) );
}
}
Expand Down

0 comments on commit 32b32ac

Please sign in to comment.