Skip to content

Commit

Permalink
Inherit weight/volume of components not result
Browse files Browse the repository at this point in the history
  • Loading branch information
ifreund committed Apr 8, 2019
1 parent 85dbfc7 commit fbb59eb
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3251,14 +3251,16 @@ units::mass item::weight( bool include_contents ) const
return 0_gram;
}

units::mass ret = 0_gram;

if( is_craft() ) {
ret = units::from_gram( get_var( "weight", to_gram( find_type( making->result() )->weight ) ) );
} else {
ret = units::from_gram( get_var( "weight", to_gram( type->weight ) ) );
units::mass ret = 0_gram;
for( auto it : components ) {
ret += it.weight();
}
return ret;
}

units::mass ret = 0_gram;
ret = units::from_gram( get_var( "weight", to_gram( type->weight ) ) );

if( has_flag( "REDUCED_WEIGHT" ) ) {
ret *= 0.75;
Expand Down Expand Up @@ -3345,8 +3347,13 @@ units::volume item::base_volume() const
if( is_corpse() ) {
return corpse_volume( corpse );
}

if( is_craft() ) {
return find_type( making->result() )->volume;
units::volume ret = 0_ml;
for( auto it : components ) {
ret += it.base_volume();
}
return ret;
}

if( count_by_charges() ) {
Expand All @@ -3371,7 +3378,11 @@ units::volume item::volume( bool integral ) const
}

if( is_craft() ) {
return find_type( making->result() )->volume;
units::volume ret = 0_ml;
for( auto it : components ) {
ret += it.volume();
}
return ret;
}

const int local_volume = get_var( "volume", -1 );
Expand Down

0 comments on commit fbb59eb

Please sign in to comment.