diff --git a/src/item.cpp b/src/item.cpp index 3c3f511810d1d..abedbc759dc20 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -3689,7 +3689,7 @@ void item::final_info( std::vector &info, const iteminfo_query *parts, } } - contents.info( info ); + contents.info( info, parts ); contents_info( info, parts, batch, debug ); if( get_option( "ENABLE_ASCII_ART_ITEM" ) ) { diff --git a/src/item_contents.cpp b/src/item_contents.cpp index dbf705ee5407e..6615603085637 100644 --- a/src/item_contents.cpp +++ b/src/item_contents.cpp @@ -7,6 +7,7 @@ #include "enums.h" #include "game.h" #include "item.h" +#include "iteminfo_query.h" #include "itype.h" #include "item_pocket.h" #include "map.h" @@ -819,7 +820,7 @@ static void insert_separation_line( std::vector &info ) } } -void item_contents::info( std::vector &info ) const +void item_contents::info( std::vector &info, const iteminfo_query *parts ) const { int pocket_number = 1; std::vector contents_info; @@ -843,15 +844,19 @@ void item_contents::info( std::vector &info ) const pocket.contents_info( contents_info, pocket_number++, contents.size() != 1 ); } } - int idx = 0; - for( const item_pocket &pocket : found_pockets ) { - insert_separation_line( info ); - if( pocket_num[idx] > 1 ) { - info.emplace_back( "DESCRIPTION", string_format( _( "Pockets (%d)" ), - pocket_num[idx] ) ); + if( parts->test( iteminfo_parts::DESCRIPTION_POCKETS ) ) { + int idx = 0; + for( const item_pocket &pocket : found_pockets ) { + insert_separation_line( info ); + if( pocket_num[idx] > 1 ) { + info.emplace_back( "DESCRIPTION", string_format( _( "Pockets (%d)" ), + pocket_num[idx] ) ); + } + idx++; + pocket.general_info( info, idx, false ); } - idx++; - pocket.general_info( info, idx, false ); } - info.insert( info.end(), contents_info.begin(), contents_info.end() ); + if( parts->test( iteminfo_parts::DESCRIPTION_CONTENTS ) ) { + info.insert( info.end(), contents_info.begin(), contents_info.end() ); + } } diff --git a/src/item_contents.h b/src/item_contents.h index 5382427a07691..e77989290c991 100644 --- a/src/item_contents.h +++ b/src/item_contents.h @@ -11,6 +11,7 @@ #include "enums.h" #include "item_pocket.h" +#include "iteminfo_query.h" #include "optional.h" #include "ret_val.h" #include "type_id.h" @@ -188,7 +189,7 @@ class item_contents void remove_internal( const std::function &filter, int &count, std::list &res ); - void info( std::vector &info ) const; + void info( std::vector &info, const iteminfo_query *parts ) const; void combine( const item_contents &read_input ); diff --git a/src/iteminfo_query.h b/src/iteminfo_query.h index 8c00866b8ba70..3d097d82335b6 100644 --- a/src/iteminfo_query.h +++ b/src/iteminfo_query.h @@ -192,6 +192,8 @@ enum class iteminfo_parts : size_t { DESCRIPTION_FAULTS, + DESCRIPTION_POCKETS, + DESCRIPTION_HOLSTERS, DESCRIPTION_ACTIVATABLE_TRANSFORMATION, diff --git a/tests/iteminfo_test.cpp b/tests/iteminfo_test.cpp index 5e9c57890f9c4..afb8d0e972fb5 100644 --- a/tests/iteminfo_test.cpp +++ b/tests/iteminfo_test.cpp @@ -103,42 +103,6 @@ TEST_CASE( "item owner, price, and barter value", "[item][iteminfo][price]" ) } } -TEST_CASE( "item rigidity", "[item][iteminfo][rigidity][!mayfail]" ) -{ - iteminfo_query q = q_vec( { iteminfo_parts::BASE_RIGIDITY, iteminfo_parts::ARMOR_ENCUMBRANCE } ); - - SECTION( "non-rigid items indicate their flexible volume/encumbrance" ) { - test_info_equals( - item( "test_waterskin" ), q, - "--\n" - "Encumbrance: 0" - " Encumbrance when full: 6\n" - "--\n" - "* This item is not rigid." - " Its volume and encumbrance increase with contents.\n" ); - - test_info_equals( - item( "test_backpack" ), q, - "--\n" - "Encumbrance: 2" - " Encumbrance when full: 15\n" - "--\n" - "* This item is not rigid." - " Its volume and encumbrance increase with contents.\n" ); - } - - SECTION( "rigid items do not indicate they are rigid, since almost all items are" ) { - test_info_equals( - item( "test_briefcase" ), q, - "--\n" - "Encumbrance: 30\n" ); - - test_info_equals( item( "test_jug_plastic" ), q, "" ); - test_info_equals( item( "test_pipe" ), q, "" ); - test_info_equals( item( "test_pine_nuts" ), q, "" ); - } -} - TEST_CASE( "weapon attack ratings and moves", "[item][iteminfo][weapon]" ) { // new DPS calculations depend on the avatar's stats, so make sure they're consistent