From cc94a2417c484264a151a795ee0e3e519467cffa Mon Sep 17 00:00:00 2001 From: Lohikar Date: Tue, 16 Jan 2018 07:02:42 -0600 Subject: [PATCH] Fix tick overcommit (#4101) Fixes a bug with the MC where the entire tick would be reserved for the MC instead of 25% of it. Result of bad port. --- code/controllers/master/master.dm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/code/controllers/master/master.dm b/code/controllers/master/master.dm index a2566a1414b..3600d726e68 100644 --- a/code/controllers/master/master.dm +++ b/code/controllers/master/master.dm @@ -300,8 +300,10 @@ var/CURRENT_TICKLIMIT = TICK_LIMIT_RUNNING var/datum/controller/subsystem/SS SS.can_fire = 0 + // Check the failsafe's still alive. if (!Failsafe || (Failsafe.processing_interval > 0 && (Failsafe.lasttick+(Failsafe.processing_interval*5)) < world.time)) new/datum/controller/failsafe() // (re)Start the failsafe. + if (!queue_head || !(iteration % 3)) if (round_started) subsystems_to_check = normalsubsystems @@ -309,6 +311,7 @@ var/CURRENT_TICKLIMIT = TICK_LIMIT_RUNNING subsystems_to_check = lobbysubsystems else subsystems_to_check = tickersubsystems + if (CheckQueue(subsystems_to_check) <= 0) if (!SoftReset(tickersubsystems, normalsubsystems, lobbysubsystems)) log_mc("SoftReset() failed, crashing") @@ -341,7 +344,7 @@ var/CURRENT_TICKLIMIT = TICK_LIMIT_RUNNING src.sleep_delta = MC_AVERAGE_FAST(src.sleep_delta, sleep_delta) CURRENT_TICKLIMIT = TICK_LIMIT_RUNNING if (processing * sleep_delta <= world.tick_lag) - CURRENT_TICKLIMIT -= (TICK_LIMIT_RUNNING) + CURRENT_TICKLIMIT -= (TICK_LIMIT_RUNNING * 0.25) //reserve the tail 1/4 of the next tick for the mc if we plan on running next tick sleep(world.tick_lag * (processing * sleep_delta))