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

Consume fixes #40508

Merged
merged 3 commits into from
May 13, 2020
Merged
Changes from 2 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
17 changes: 12 additions & 5 deletions src/consumption.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include "enums.h"
#include "flat_set.h"
#include "game.h"
#include "item.h"
#include "item_category.h"
#include "item_contents.h"
#include "itype.h"
#include "iuse_actor.h"
Expand Down Expand Up @@ -1321,8 +1323,10 @@ bool Character::consume_effects( item &food )
units::volume food_vol = food.base_volume() - std::max( water_vol, 0_ml );
units::mass food_weight = ( food.weight() / food.count() ) - units::from_gram( units::to_milliliter(
water_vol ) ); //water is 1 gram per milliliter
double ratio = std::max( static_cast<double>( food_nutrients.kcal ) / units::to_gram( food_weight ),
1.0 );
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 );
}

food_summary ingested{
water_vol,
Expand Down Expand Up @@ -1629,7 +1633,8 @@ time_duration Character::get_consume_time( const item &it )
{
const int charges = std::max( it.charges, 1 );
int volume = units::to_milliliter( it.volume() ) / charges;
time_duration time = 0_seconds;
time_duration time = time = time_duration::from_seconds( std::max( ( volume /
Ramza13 marked this conversation as resolved.
Show resolved Hide resolved
5 ), 1 ) ); //Default 5 mL (1 tablespoon) per second
float consume_time_modifier = 1;//only for food and drinks
const bool eat_verb = it.has_flag( flag_USE_EAT_VERB );
if( eat_verb || it.get_comestible()->comesttype == "FOOD" ) {
Expand Down Expand Up @@ -1664,8 +1669,10 @@ time_duration Character::get_consume_time( const item &it )
} else {
time = time_duration::from_seconds( 5 ); //probably pills so quick
}
} else {
debugmsg( "Consumed something that was not food, drink or medicine/drugs" );
} else if( it.get_category().get_id() == "chems" ) {
time = time_duration::from_seconds( std::max( ( volume / 15 ),
1 ) ); //Consume 15 mL (1 tablespoon) per second
consume_time_modifier = mutation_value( "consume_time_modifier" );
}

return time * consume_time_modifier;
Expand Down