Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for Carnivores being able to eat low-calorie veggies #75534

Merged
merged 1 commit into from
Aug 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix carnivores being able to eat low-cal veggies
Foods under ~17 calories, including pickles, were skipping the carnivore
check against prohibited foods.  This fix safely closes that edge case.
A comment is also included warning developers of danger from rounding.
  • Loading branch information
p4nc4k3z committed Aug 9, 2024
commit 7ec902eff8ddfd7797ef55654ca61a499afdf278
3 changes: 2 additions & 1 deletion src/consumption.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ std::pair<nutrients, nutrients> Character::compute_nutrient_range(

int Character::nutrition_for( const item &comest ) const
{
// Note: This will round down to zero for super-low-calorie foods
return compute_effective_nutrients( comest ).kcal() / islot_comestible::kcal_per_nutr;
}

Expand Down Expand Up @@ -901,7 +902,7 @@ ret_val<edible_rating> Character::can_eat( const item &food ) const
return ret_val<edible_rating>::make_failure( INEDIBLE_MUTATION, _( "Ugh, you can't drink that!" ) );
}

if( has_trait( trait_CARNIVORE ) && nutrition_for( food ) > 0 &&
if( has_trait( trait_CARNIVORE ) && compute_effective_nutrients( food ).kcal() > 0 &&
food.has_any_vitamin( carnivore_blacklist ) && !food.has_flag( flag_CARNIVORE_OK ) ) {
return ret_val<edible_rating>::make_failure( INEDIBLE_MUTATION,
_( "Eww. Inedible plant stuff!" ) );
Expand Down
Loading