@@ -4199,22 +4199,10 @@ void item::final_info( std::vector<iteminfo> &info, const iteminfo_query &parts_
41994199 }
42004200
42014201 if ( parts->test ( iteminfo_parts::BASE_RIGIDITY ) ) {
4202- if ( const islot_armor *armor = find_armor_data () ) {
4203- if ( !type->rigid ) {
4204- info.emplace_back ( " BASE" ,
4205- _ ( " * This item is <info>not rigid</info>. Its"
4206- " volume and encumbrance increase with contents." ) );
4207- } else {
4208- bool any_encumb_increase = std::ranges::any_of ( armor->data ,
4209- []( armor_portion_data data ) {
4210- return data.encumber != data.max_encumber ;
4211- } );
4212- if ( any_encumb_increase ) {
4213- info.emplace_back ( " BASE" ,
4214- _ ( " * This item is <info>not rigid</info>. Its"
4215- " volume and encumbrance increase with contents." ) );
4216- }
4217- }
4202+ if ( is_non_rigid () ) {
4203+ info.emplace_back ( " BASE" ,
4204+ _ ( " * This item is <info>not rigid</info>. Its"
4205+ " volume and encumbrance increase with contents." ) );
42184206 }
42194207 }
42204208
@@ -6138,6 +6126,21 @@ bool item::can_shatter() const
61386126 return only_made_of ( is_glass ) || has_flag ( flag_SHATTERS );
61396127}
61406128
6129+ bool item::is_non_rigid () const
6130+ {
6131+ if ( const islot_armor *armor = find_armor_data () ) {
6132+ if ( !type->rigid ) {
6133+ return true ;
6134+ }
6135+ bool any_encumb_increase = std::ranges::any_of ( armor->data ,
6136+ []( armor_portion_data data ) {
6137+ return data.encumber != data.max_encumber ;
6138+ } );
6139+ return any_encumb_increase;
6140+ }
6141+ return false ;
6142+ }
6143+
61416144void item::unset_flags ()
61426145{
61436146 const bool affects_processing = item_tags.count ( flag_RADIO_ACTIVATION ) ||
@@ -6741,24 +6744,29 @@ int item::get_encumber( const Character &who, const bodypart_id &bodypart ) cons
67416744
67426745 contents_volume += contents.item_size_modifier ();
67436746
6744- if ( who.is_worn ( *this ) ) {
6747+ if ( who.is_worn ( *this ) && this -> is_non_rigid () ) {
67456748 const islot_armor *armor = find_armor_data ();
67466749
67476750 if ( armor != nullptr ) {
67486751 for ( const armor_portion_data &entry : armor->data ) {
6749- if ( entry.covers .test ( bodypart.id () ) ) {
6750- if ( entry.max_encumber != 0 ) {
6751- units::volume char_storage ( 0_ml );
6752-
6753- for ( const item * const &e : who.worn ) {
6754- char_storage += e->get_storage ();
6752+ if ( entry.max_encumber != 0 && entry.covers .test ( bodypart.id () ) ) {
6753+ units::volume rigid_storage ( 0_ml );
6754+ units::volume non_rigid_storage ( 0_ml );
6755+ const units::volume volume_carried = who.volume_carried ();
6756+
6757+ for ( const item * const &e : who.worn ) {
6758+ if ( e->is_non_rigid () ) {
6759+ non_rigid_storage += e->get_storage ();
6760+ } else {
6761+ rigid_storage += e->get_storage ();
67556762 }
6763+ }
67566764
6757- if ( char_storage != 0_ml ) {
6758- // Cast up to 64 to prevent overflow. Dividing before would prevent this but lose data.
6759- contents_volume += units::from_milliliter ( static_cast <int64_t >( armor->storage .value () ) *
6760- who. inv_volume (). value () / char_storage .value () );
6761- }
6765+ if ( volume_carried > rigid_storage && non_rigid_storage > 0_ml ) {
6766+ // Cast up to 64 to prevent overflow. Dividing before would prevent this but lose data.
6767+ contents_volume += units::from_milliliter ( static_cast <int64_t >( armor->storage .value () ) *
6768+ ( static_cast < int64_t >( volume_carried. value () ) - rigid_storage .value () ) /
6769+ non_rigid_storage. value () );
67626770 }
67636771 }
67646772 }
@@ -6783,11 +6791,7 @@ int item::get_encumber_when_containing(
67836791 if ( entry.covers .test ( bodypart.id () ) ) {
67846792 encumber = entry.encumber ;
67856793 // Non-rigid items add additional encumbrance proportional to their volume
6786- bool any_encumb_increase = std::ranges::any_of ( armor->data ,
6787- []( armor_portion_data data ) {
6788- return data.encumber != data.max_encumber ;
6789- } );
6790- if ( !type->rigid || any_encumb_increase ) {
6794+ if ( this ->is_non_rigid () ) {
67916795 const int capacity = get_total_capacity ().value ();
67926796 if ( entry.max_encumber == 0 ) {
67936797 encumber += contents_volume / 500_ml;
0 commit comments