From 3ac02c5edaffd1544d3aef5baad06a7621ff797b Mon Sep 17 00:00:00 2001 From: Eric <52087122+Ramza13@users.noreply.github.com> Date: Wed, 13 May 2020 04:06:32 -0400 Subject: [PATCH 1/4] Consume fixes (#40508) * prevent divide by zero * Better handle consume time misc cases --- src/consumption.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/consumption.cpp b/src/consumption.cpp index 1d3cc3b831b66..ee7cf695312a3 100644 --- a/src/consumption.cpp +++ b/src/consumption.cpp @@ -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" @@ -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( 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( food_nutrients.kcal ) / units::to_gram( food_weight ), 1.0 ); + } food_summary ingested{ water_vol, @@ -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_duration::from_seconds( std::max( ( volume / + 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" ) { @@ -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; From a9a9b647a0b6b112c3d036413f02d0bd7eded331 Mon Sep 17 00:00:00 2001 From: Alexey Mostovoy <1931904+AMurkin@users.noreply.github.com> Date: Wed, 13 May 2020 20:59:23 +0400 Subject: [PATCH 2/4] Minor doc fix (#40531) * Set c++ syntax for JSON code snippet with comments * Enclose a code snippet in the Field types section --- doc/JSON_INFO.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/JSON_INFO.md b/doc/JSON_INFO.md index 70ce92d83676e..5ba7140a70e7b 100644 --- a/doc/JSON_INFO.md +++ b/doc/JSON_INFO.md @@ -2949,7 +2949,7 @@ A flat multiplier on the harvest count of the plant. For numbers greater than on ### clothing_mod -```JSON +```C++ "type": "clothing_mod", "id": "leather_padded", // Unique ID. "flag": "leather_padded", // flag to add to clothing. @@ -3316,7 +3316,7 @@ The internal ID of the compatible tilesets. MOD tileset is only applied when bas Setting of sprite sheets. Same as `tiles-new` field in `tile_config`. Sprite files are loaded from the same folder json file exists. # Field types - +```C++ { "type": "field_type", // this is a field type "id": "fd_gum_web", // id of the field @@ -3339,3 +3339,4 @@ Setting of sprite sheets. Same as `tiles-new` field in `tile_config`. Sprite fil ] } } +``` From 9bb14f62ce9892a4ae9f7c7140170e0e9b5bb7e7 Mon Sep 17 00:00:00 2001 From: LaVeyanFiend <51099123+LaVeyanFiend@users.noreply.github.com> Date: Wed, 13 May 2020 15:19:02 -0400 Subject: [PATCH 3/4] Capital P (#40534) --- data/json/scenarios.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/json/scenarios.json b/data/json/scenarios.json index 050343c7259aa..d38fbc73a18de 100644 --- a/data/json/scenarios.json +++ b/data/json/scenarios.json @@ -497,7 +497,7 @@ { "type": "scenario", "ident": "presort", - "name": "Crazy party", + "name": "Crazy Party", "points": 0, "description": "You thought things couldn't get any worse when the cops came over to bust your wild party, even though you booked it at a private resort. When the guests started fighting with the police you tried to get them to calm down, only to find out they hungered for more.", "start_name": "Private resort", From 626c31cdf76e5355b1ba8e7ef39c0f017a824739 Mon Sep 17 00:00:00 2001 From: Xenomorph-III Date: Thu, 14 May 2020 10:14:10 +1200 Subject: [PATCH 4/4] Removed extra "E" from baselard flag. This stopped it from being stored in a sheath. --- data/json/items/melee/swords_and_blades.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/json/items/melee/swords_and_blades.json b/data/json/items/melee/swords_and_blades.json index a098d9a3a1fc4..6262263b96488 100644 --- a/data/json/items/melee/swords_and_blades.json +++ b/data/json/items/melee/swords_and_blades.json @@ -280,7 +280,7 @@ "symbol": ";", "color": "dark_gray", "qualities": [ [ "CUT", 1 ], [ "BUTCHER", 15 ] ], - "flags": [ "STAB", "SHEATHE_KNIFE" ] + "flags": [ "STAB", "SHEATH_KNIFE" ] }, { "id": "makeshift_machete",