From c1c5c55fbafb124e1d098fd2b53acc5c03a5de62 Mon Sep 17 00:00:00 2001 From: Leshana Date: Wed, 8 Apr 2020 18:41:58 -0400 Subject: [PATCH 1/2] MC Statpanel now distinguishes between NO_FIRE subsystems and OFFLINE (can_fire <= 0) subsystems --- code/controllers/subsystem.dm | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/code/controllers/subsystem.dm b/code/controllers/subsystem.dm index 8c0b6fa5de..43429420c0 100644 --- a/code/controllers/subsystem.dm +++ b/code/controllers/subsystem.dm @@ -168,11 +168,12 @@ statclick = new/obj/effect/statclick/debug(null, "Initializing...", src) - - if(can_fire && !(SS_NO_FIRE & flags)) - msg = "[round(cost,1)]ms|[round(tick_usage,1)]%([round(tick_overrun,1)]%)|[round(ticks,0.1)]\t[msg]" - else + if(SS_NO_FIRE & flags) + msg = "NO FIRE\t[msg]" + else if(can_fire <= 0) msg = "OFFLINE\t[msg]" + else + msg = "[round(cost,1)]ms|[round(tick_usage,1)]%([round(tick_overrun,1)]%)|[round(ticks,0.1)]\t[msg]" var/title = name if (can_fire) From 520d5de7bd51ea0120eb7cd3eb570a754147905e Mon Sep 17 00:00:00 2001 From: Leshana Date: Wed, 8 Apr 2020 22:42:00 -0400 Subject: [PATCH 2/2] Suspend SSmachines subsystem while we are initializing map templates. - Adds the capability to "suspend" a subsystem while we're loading something. --- code/controllers/subsystem.dm | 12 ++++++++++++ code/modules/maps/tg/map_template.dm | 3 +++ 2 files changed, 15 insertions(+) diff --git a/code/controllers/subsystem.dm b/code/controllers/subsystem.dm index 43429420c0..7115c77a61 100644 --- a/code/controllers/subsystem.dm +++ b/code/controllers/subsystem.dm @@ -203,3 +203,15 @@ //usually called via datum/controller/subsystem/New() when replacing a subsystem (i.e. due to a recurring crash) //should attempt to salvage what it can from the old instance of subsystem /datum/controller/subsystem/Recover() + +// Suspends this subsystem from being queued for running. If already in the queue, sleeps until idle. Returns FALSE if the subsystem was already suspended. +/datum/controller/subsystem/proc/suspend() + . = (can_fire > 0) // Return true if we were previously runnable, false if previously suspended. + can_fire = FALSE + // Safely sleep in a loop until the subsystem is idle, (or its been un-suspended somehow) + while(can_fire <= 0 && state != SS_IDLE) + stoplag() // Safely sleep in a loop until + +// Wakes a suspended subsystem. +/datum/controller/subsystem/proc/wake() + can_fire = TRUE diff --git a/code/modules/maps/tg/map_template.dm b/code/modules/maps/tg/map_template.dm index 6053353b25..d636cc66d2 100644 --- a/code/modules/maps/tg/map_template.dm +++ b/code/modules/maps/tg/map_template.dm @@ -41,6 +41,7 @@ var/prev_shuttle_queue_state = SSshuttles.block_init_queue SSshuttles.block_init_queue = TRUE + var/machinery_was_awake = SSmachines.suspend() // Suspend machinery (if it was not already suspended) var/list/atom/atoms = list() var/list/area/areas = list() @@ -74,6 +75,8 @@ var/area/A = I A.power_change() + if(machinery_was_awake) + SSmachines.wake() // Wake only if it was awake before we tried to suspended it. SSshuttles.block_init_queue = prev_shuttle_queue_state SSshuttles.process_init_queues() // We will flush the queue unless there were other blockers, in which case they will do it.