From 4d547420799663e5e73b214248839ef87d889dc3 Mon Sep 17 00:00:00 2001 From: mwerezak Date: Fri, 22 May 2015 01:27:01 -0400 Subject: [PATCH 1/2] Fixes portable generators going about their temperature limit --- code/modules/power/port_gen.dm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/code/modules/power/port_gen.dm b/code/modules/power/port_gen.dm index a858a5fd43f..88cc4b57078 100644 --- a/code/modules/power/port_gen.dm +++ b/code/modules/power/port_gen.dm @@ -214,7 +214,10 @@ else if (temperature > upper_limit) bias = max(round((temperature - average)/TEMPERATURE_DIVISOR, 1), -TEMPERATURE_CHANGE_MAX) - temperature += rand(-7 + bias, 7 + bias) + //limit temperature increase so that it cannot raise temperature above upper_limit, + //or if it is already above upper_limit, limit the increase to 0. + var/inc_limit = max(upper_limit - temperature, 0) + temperature += min(rand(-7 + bias, 7 + bias), inc_limit) if (temperature > max_temperature) overheat() From cf591c290b2f967378a0e447a6f49fe0b43eee16 Mon Sep 17 00:00:00 2001 From: mwerezak Date: Fri, 22 May 2015 02:21:12 -0400 Subject: [PATCH 2/2] Adds limit to prevent random walking below the lower limit temperature, too. --- code/modules/power/port_gen.dm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/code/modules/power/port_gen.dm b/code/modules/power/port_gen.dm index 88cc4b57078..61cf05477ae 100644 --- a/code/modules/power/port_gen.dm +++ b/code/modules/power/port_gen.dm @@ -217,7 +217,8 @@ //limit temperature increase so that it cannot raise temperature above upper_limit, //or if it is already above upper_limit, limit the increase to 0. var/inc_limit = max(upper_limit - temperature, 0) - temperature += min(rand(-7 + bias, 7 + bias), inc_limit) + var/dec_limit = min(temperature - lower_limit, 0) + temperature += between(dec_limit, rand(-7 + bias, 7 + bias), inc_limit) if (temperature > max_temperature) overheat()