diff --git a/code/controllers/master.dm b/code/controllers/master.dm
index c245c33e51..a220c2530c 100644
--- a/code/controllers/master.dm
+++ b/code/controllers/master.dm
@@ -132,7 +132,7 @@ GLOBAL_VAR_INIT(CURRENT_TICKLIMIT, TICK_LIMIT_RUNNING)
msg = "The [BadBoy.name] subsystem seems to be destabilizing the MC and will be offlined."
BadBoy.flags |= SS_NO_FIRE
if(msg)
- to_chat(GLOB.admins, "[msg]")
+ to_chat(GLOB.admins, "[msg]")
log_world(msg)
if (istype(Master.subsystems))
@@ -189,9 +189,15 @@ GLOBAL_VAR_INIT(CURRENT_TICKLIMIT, TICK_LIMIT_RUNNING)
// Loop.
Master.StartProcessing(0)
-/datum/controller/master/proc/SetRunLevel(runlevel)
- testing("MC: Runlevel changed from [isnull(current_runlevel) ? "NULL" : current_runlevel] to [runlevel]")
- current_runlevel = runlevel
+/datum/controller/master/proc/SetRunLevel(new_runlevel)
+ var/old_runlevel = current_runlevel
+ if(isnull(old_runlevel))
+ old_runlevel = "NULL"
+
+ testing("MC: Runlevel changed from [old_runlevel] to [new_runlevel]")
+ current_runlevel = log(2, new_runlevel) + 1
+ if(current_runlevel < 1)
+ CRASH("Attempted to set invalid runlevel: [new_runlevel]")
// Starts the mc, and sticks around to restart it if the loop ever ends.
/datum/controller/master/proc/StartProcessing(delay)
@@ -233,7 +239,7 @@ GLOBAL_VAR_INIT(CURRENT_TICKLIMIT, TICK_LIMIT_RUNNING)
timer += world.tick_lag * rand(1, 5)
SS.next_fire = timer
continue
-
+
var/ss_runlevels = SS.runlevels
var/added_to_any = FALSE
for(var/I in 1 to GLOB.bitflags.len)
@@ -253,7 +259,7 @@ GLOBAL_VAR_INIT(CURRENT_TICKLIMIT, TICK_LIMIT_RUNNING)
for(var/I in runlevel_sorted_subsystems)
sortTim(runlevel_sorted_subsystems, /proc/cmp_subsystem_priority)
I += tickersubsystems
-
+
var/cached_runlevel = current_runlevel
var/list/current_runlevel_subsystems = runlevel_sorted_subsystems[cached_runlevel]