From efdb35cfbdda4d7ff3f4d2982e15be09fac28e43 Mon Sep 17 00:00:00 2001 From: GuardianDll Date: Wed, 8 May 2024 22:04:16 +0200 Subject: [PATCH] Clamp metabolism enchantment to prevent lag Co-authored-by: RenechCDDA <84619419+RenechCDDA@users.noreply.github.com> --- src/consumption.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/consumption.cpp b/src/consumption.cpp index 2796a2039f47f..70a9341a4c9ad 100644 --- a/src/consumption.cpp +++ b/src/consumption.cpp @@ -715,7 +715,9 @@ float Character::metabolic_rate_base() const { static const std::string hunger_rate_string( "PLAYER_HUNGER_RATE" ); float hunger_rate = get_option< float >( hunger_rate_string ); - return enchantment_cache->modify_value( enchant_vals::mod::METABOLISM, hunger_rate ); + const float final_hunger_rate = enchantment_cache->modify_value( enchant_vals::mod::METABOLISM, + hunger_rate ); + return std::clamp( final_hunger_rate, 0.0f, float_max ); } // TODO: Make this less chaotic to let NPC retroactive catch up work here