Skip to content

Commit

Permalink
Master Controller Fixes (#13644)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fox-McCloud authored Jun 21, 2020
1 parent ebeee92 commit 0d4e085
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
7 changes: 3 additions & 4 deletions code/__DEFINES/MC.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion code/controllers/globals.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
15 changes: 8 additions & 7 deletions code/controllers/master.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion code/controllers/subsystem.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0d4e085

Please sign in to comment.