Skip to content

Commit

Permalink
Remove water weight from stomach volume calculator (#41541)
Browse files Browse the repository at this point in the history
When removing the weight from water from the calculated weight of the
item, it lead to the calculated effective volume of certain foods,
such as sandwiches, being too high, and thus taking up too much space in
the stomach.

Also, add a debug message for this, enabling easier debugging in the
future.
  • Loading branch information
anothersimulacrum authored Jun 23, 2020
1 parent 7bd8648 commit 28fa7cb
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/consumption.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1337,8 +1337,7 @@ bool Character::consume_effects( item &food )
units::volume water_vol = ( food.type->comestible->quench > 0 ) ? food.type->comestible->quench *
5_ml : 0_ml;
units::volume food_vol = food.base_volume() - water_vol;
units::mass food_weight = ( food.weight() / food.count() ) - units::from_gram( units::to_milliliter(
water_vol ) ); //water is 1 gram per milliliter
units::mass food_weight = ( food.weight() / food.count() );
double ratio = 1.0f;
if( units::to_gram( food_weight ) != 0 ) {
ratio = std::max( static_cast<double>( food_nutrients.kcal ) / units::to_gram( food_weight ), 1.0 );
Expand All @@ -1349,6 +1348,9 @@ bool Character::consume_effects( item &food )
food_vol * ratio,
food_nutrients
};
add_msg( m_debug, "Effective volume: %d (solid) %d (liquid)\n multiplier: %g calculated: %d / %d",
units::to_milliliter( ingested.solids ), units::to_milliliter( ingested.water ), ratio,
food_nutrients.kcal, units::to_gram( food_weight ) );
// Maybe move tapeworm to digestion
if( has_effect( effect_tapeworm ) ) {
ingested.nutr /= 2;
Expand Down

0 comments on commit 28fa7cb

Please sign in to comment.