From 0d4e0855f35e92b8e61261c842fa7d9fd222ab21 Mon Sep 17 00:00:00 2001 From: Fox McCloud Date: Sun, 21 Jun 2020 15:00:41 -0400 Subject: [PATCH] Master Controller Fixes (#13644) --- code/__DEFINES/MC.dm | 7 +++---- code/controllers/globals.dm | 2 +- code/controllers/master.dm | 15 ++++++++------- code/controllers/subsystem.dm | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/code/__DEFINES/MC.dm b/code/__DEFINES/MC.dm index cbcf2c1dd90..e2068cecb89 100644 --- a/code/__DEFINES/MC.dm +++ b/code/__DEFINES/MC.dm @@ -32,17 +32,16 @@ // (Requires a MC restart to change) #define SS_NO_FIRE 2 -//subsystem only runs on spare cpu (after all non-background subsystems have ran that tick) -// SS_BACKGROUND has its own priority bracket +/** Subsystem only runs on spare cpu (after all non-background subsystems have ran that tick) */ +/// SS_BACKGROUND has its own priority bracket, this overrides SS_TICKER's priority bump #define SS_BACKGROUND 4 //subsystem does not tick check, and should not run unless there is enough time (or its running behind (unless background)) #define SS_NO_TICK_CHECK 8 //Treat wait as a tick count, not DS, run every wait ticks. -// (also forces it to run first in the tick, above even SS_NO_TICK_CHECK subsystems) +/// (also forces it to run first in the tick (unless SS_BACKGROUND)) // (implies all runlevels because of how it works) -// (overrides SS_BACKGROUND) // This is designed for basically anything that works as a mini-mc (like SStimer) #define SS_TICKER 16 diff --git a/code/controllers/globals.dm b/code/controllers/globals.dm index 5a520b547e1..691f19201f6 100644 --- a/code/controllers/globals.dm +++ b/code/controllers/globals.dm @@ -14,7 +14,7 @@ GLOBAL_REAL(GLOB, /datum/controller/global_vars) var/datum/controller/exclude_these = new gvars_datum_in_built_vars = exclude_these.vars + list("gvars_datum_protected_varlist", "gvars_datum_in_built_vars", "gvars_datum_init_order") - qdel(exclude_these) + QDEL_IN(exclude_these, 0) //signal logging isn't ready Initialize() diff --git a/code/controllers/master.dm b/code/controllers/master.dm index fea79c2f7a5..b8c3cdbf1e2 100644 --- a/code/controllers/master.dm +++ b/code/controllers/master.dm @@ -451,14 +451,15 @@ GLOBAL_REAL(Master, /datum/controller/master) = new // in those cases, so we just let them run) if(queue_node_flags & SS_NO_TICK_CHECK) if(queue_node.tick_usage > TICK_LIMIT_RUNNING - TICK_USAGE && ran_non_ticker) - queue_node.queued_priority += queue_priority_count * 0.1 - queue_priority_count -= queue_node_priority - queue_priority_count += queue_node.queued_priority - current_tick_budget -= queue_node_priority - queue_node = queue_node.queue_next + if(!(queue_node_flags & SS_BACKGROUND)) + queue_node.queued_priority += queue_priority_count * 0.1 + queue_priority_count -= queue_node_priority + queue_priority_count += queue_node.queued_priority + current_tick_budget -= queue_node_priority + queue_node = queue_node.queue_next continue - if((queue_node_flags & SS_BACKGROUND) && !bg_calc) + if(!bg_calc && (queue_node_flags & SS_BACKGROUND)) current_tick_budget = queue_priority_count_bg bg_calc = TRUE @@ -511,7 +512,7 @@ GLOBAL_REAL(Master, /datum/controller/master) = new queue_node.paused_ticks = 0 queue_node.paused_tick_usage = 0 - if(queue_node_flags & SS_BACKGROUND) //update our running total + if(bg_calc) //update our running total queue_priority_count_bg -= queue_node_priority else queue_priority_count -= queue_node_priority diff --git a/code/controllers/subsystem.dm b/code/controllers/subsystem.dm index 68ee4bfeace..03e54df61c5 100644 --- a/code/controllers/subsystem.dm +++ b/code/controllers/subsystem.dm @@ -89,7 +89,7 @@ queue_node_flags = queue_node.flags if(queue_node_flags & SS_TICKER) - if(!(SS_flags & SS_TICKER)) + if((SS_flags & (SS_TICKER|SS_BACKGROUND)) != SS_TICKER) continue if(queue_node_priority < SS_priority) break