diff --git a/code/__DEFINES/subsystems.dm b/code/__DEFINES/subsystems.dm index ac6f4e4e7d8..9a0bf8d401e 100644 --- a/code/__DEFINES/subsystems.dm +++ b/code/__DEFINES/subsystems.dm @@ -66,8 +66,7 @@ #define RUNLEVEL_INIT 0 #define RUNLEVEL_LOBBY 1 #define RUNLEVEL_SETUP 2 -#define RUNLEVEL_GAME 3 -#define RUNLEVEL_POSTGAME 4 +#define RUNLEVEL_GAME 4 +#define RUNLEVEL_POSTGAME 8 -#define RUNLEVEL_MIN_DEFAULT RUNLEVEL_SETUP -#define RUNLEVEL_MAX_DEFAULT RUNLEVEL_POSTGAME +#define RUNLEVELS_DEFAULT (RUNLEVEL_SETUP | RUNLEVEL_GAME | RUNLEVEL_POSTGAME) \ No newline at end of file diff --git a/code/controllers/master.dm b/code/controllers/master.dm index 602671f2db8..ed05e62ed29 100644 --- a/code/controllers/master.dm +++ b/code/controllers/master.dm @@ -233,12 +233,17 @@ GLOBAL_VAR_INIT(CURRENT_TICKLIMIT, TICK_LIMIT_RUNNING) timer += world.tick_lag * rand(1, 5) SS.next_fire = timer continue - var/ss_max_runlevel = SS.runlevel_max - while(runlevel_sorted_subsystems.len < ss_max_runlevel) - runlevel_sorted_subsystems += list(list()) - for(var/I in SS.runlevel_min to ss_max_runlevel) - runlevel_sorted_subsystems[I] += SS + var/ss_runlevels = SS.runlevels + var/added_to_any = FALSE + for(var/I in 1 to GLOB.bitflags.len) + if(ss_runlevels & GLOB.bitflags[I]) + while(runlevel_sorted_subsystems.len < I) + runlevel_sorted_subsystems += list(list()) + runlevel_sorted_subsystems[I] += SS + added_to_any = TRUE + if(!added_to_any) + WARNING("[SS.name] subsystem is not SS_NO_FIRE but also does not have any runlevels set!") queue_head = null queue_tail = null diff --git a/code/controllers/subsystem.dm b/code/controllers/subsystem.dm index dcc55a8cb0a..50d5ea2070b 100644 --- a/code/controllers/subsystem.dm +++ b/code/controllers/subsystem.dm @@ -28,8 +28,7 @@ var/datum/controller/subsystem/queue_next var/datum/controller/subsystem/queue_prev - var/runlevel_min = RUNLEVEL_MIN_DEFAULT //the minimum runlevel at which this subsystem will fire - var/runlevel_max = RUNLEVEL_MAX_DEFAULT //the maximum runlevel at which this subsystem will fire + var/runlevels = RUNLEVELS_DEFAULT //points of the game at which the SS can fire var/static/failure_strikes = 0 //How many times we suspect this subsystem has crashed the MC, 3 strikes and you're out! diff --git a/code/controllers/subsystem/acid.dm b/code/controllers/subsystem/acid.dm index 765c8cd49d0..a83afb3923b 100644 --- a/code/controllers/subsystem/acid.dm +++ b/code/controllers/subsystem/acid.dm @@ -2,7 +2,7 @@ SUBSYSTEM_DEF(acid) name = "Acid" priority = 40 flags = SS_NO_INIT|SS_BACKGROUND - runlevel_min = RUNLEVEL_GAME + runlevels = RUNLEVEL_GAME | RUNLEVEL_POSTGAME var/list/currentrun = list() var/list/processing = list() diff --git a/code/controllers/subsystem/air.dm b/code/controllers/subsystem/air.dm index 0b77bbdc06a..e9dc5329754 100644 --- a/code/controllers/subsystem/air.dm +++ b/code/controllers/subsystem/air.dm @@ -12,7 +12,7 @@ SUBSYSTEM_DEF(air) priority = 20 wait = 5 flags = SS_BACKGROUND - runlevel_min = RUNLEVEL_GAME + runlevels = RUNLEVEL_GAME | RUNLEVEL_POSTGAME var/cost_turfs = 0 var/cost_groups = 0 diff --git a/code/controllers/subsystem/augury.dm b/code/controllers/subsystem/augury.dm index 2ac9e05356f..32086f52ed6 100644 --- a/code/controllers/subsystem/augury.dm +++ b/code/controllers/subsystem/augury.dm @@ -1,7 +1,7 @@ SUBSYSTEM_DEF(augury) name = "Augury" flags = SS_NO_INIT - runlevel_min = RUNLEVEL_GAME + runlevels = RUNLEVEL_GAME | RUNLEVEL_POSTGAME var/list/watchers = list() var/list/doombringers = list() diff --git a/code/controllers/subsystem/disease.dm b/code/controllers/subsystem/disease.dm index 845238f497a..5499680a2f1 100644 --- a/code/controllers/subsystem/disease.dm +++ b/code/controllers/subsystem/disease.dm @@ -1,7 +1,7 @@ SUBSYSTEM_DEF(disease) name = "Disease" flags = SS_KEEP_TIMING|SS_NO_INIT - runlevel_min = RUNLEVEL_GAME + runlevels = RUNLEVEL_GAME | RUNLEVEL_POSTGAME var/list/currentrun = list() var/list/processing = list() diff --git a/code/controllers/subsystem/events.dm b/code/controllers/subsystem/events.dm index 22e3485bb7e..5e557b32d58 100644 --- a/code/controllers/subsystem/events.dm +++ b/code/controllers/subsystem/events.dm @@ -1,8 +1,7 @@ SUBSYSTEM_DEF(events) name = "Events" init_order = INIT_ORDER_EVENTS - runlevel_min = RUNLEVEL_GAME - runlevel_max = RUNLEVEL_GAME + runlevels = RUNLEVEL_GAME var/list/control = list() //list of all datum/round_event_control. Used for selecting events based on weight and occurrences. var/list/running = list() //list of all existing /datum/round_event diff --git a/code/controllers/subsystem/fire_burning.dm b/code/controllers/subsystem/fire_burning.dm index 4cba46a0aa4..73358000f16 100644 --- a/code/controllers/subsystem/fire_burning.dm +++ b/code/controllers/subsystem/fire_burning.dm @@ -2,7 +2,7 @@ SUBSYSTEM_DEF(fire_burning) name = "Fire Burning" priority = 40 flags = SS_NO_INIT|SS_BACKGROUND - runlevel_min = RUNLEVEL_GAME + runlevels = RUNLEVEL_GAME | RUNLEVEL_POSTGAME var/list/currentrun = list() var/list/processing = list() diff --git a/code/controllers/subsystem/garbage.dm b/code/controllers/subsystem/garbage.dm index 69a16215826..628c6a14eac 100644 --- a/code/controllers/subsystem/garbage.dm +++ b/code/controllers/subsystem/garbage.dm @@ -3,7 +3,7 @@ SUBSYSTEM_DEF(garbage) priority = 15 wait = 5 flags = SS_POST_FIRE_TIMING|SS_BACKGROUND|SS_NO_INIT - runlevel_min = RUNLEVEL_LOBBY + runlevels = RUNLEVELS_DEFAULT | RUNLEVEL_LOBBY var/collection_timeout = 3000// deciseconds to wait to let running procs finish before we just say fuck it and force del() the object var/delslasttick = 0 // number of del()'s we've done this tick diff --git a/code/controllers/subsystem/inbounds.dm b/code/controllers/subsystem/inbounds.dm index dccb6e45ebe..16e0f53028c 100644 --- a/code/controllers/subsystem/inbounds.dm +++ b/code/controllers/subsystem/inbounds.dm @@ -2,8 +2,7 @@ SUBSYSTEM_DEF(inbounds) name = "Inbounds" priority = 40 flags = SS_NO_INIT - runlevel_min = RUNLEVEL_GAME - runlevel_max = RUNLEVEL_GAME + runlevels = RUNLEVEL_GAME var/list/processing = list() var/list/currentrun = list() diff --git a/code/controllers/subsystem/mobs.dm b/code/controllers/subsystem/mobs.dm index c7a6fb883e0..cbe9d5c2450 100644 --- a/code/controllers/subsystem/mobs.dm +++ b/code/controllers/subsystem/mobs.dm @@ -2,7 +2,7 @@ SUBSYSTEM_DEF(mobs) name = "Mobs" priority = 100 flags = SS_KEEP_TIMING|SS_NO_INIT - runlevel_min = RUNLEVEL_GAME + runlevels = RUNLEVEL_GAME | RUNLEVEL_POSTGAME var/list/currentrun = list() diff --git a/code/controllers/subsystem/npcpool.dm b/code/controllers/subsystem/npcpool.dm index 5a7c263034a..e88da7d9009 100644 --- a/code/controllers/subsystem/npcpool.dm +++ b/code/controllers/subsystem/npcpool.dm @@ -7,7 +7,7 @@ SUBSYSTEM_DEF(npcpool) name = "NPC Pool" flags = SS_POST_FIRE_TIMING|SS_NO_INIT|SS_BACKGROUND priority = 20 - runlevel_min = RUNLEVEL_GAME + runlevels = RUNLEVEL_GAME | RUNLEVEL_POSTGAME var/list/canBeUsed = list() var/list/needsDelegate = list() diff --git a/code/controllers/subsystem/parallax.dm b/code/controllers/subsystem/parallax.dm index 37a398d5d86..39d07ee676b 100644 --- a/code/controllers/subsystem/parallax.dm +++ b/code/controllers/subsystem/parallax.dm @@ -3,7 +3,7 @@ SUBSYSTEM_DEF(parallax) wait = 2 flags = SS_POST_FIRE_TIMING | SS_BACKGROUND | SS_NO_INIT priority = 65 - runlevel_min = RUNLEVEL_LOBBY + runlevels = RUNLEVEL_LOBBY | RUNLEVELS_DEFAULT var/list/currentrun /datum/controller/subsystem/parallax/fire(resumed = 0) diff --git a/code/controllers/subsystem/processing/overlays.dm b/code/controllers/subsystem/processing/overlays.dm index 3484571c5f5..4e1d2d64d51 100644 --- a/code/controllers/subsystem/processing/overlays.dm +++ b/code/controllers/subsystem/processing/overlays.dm @@ -4,7 +4,7 @@ PROCESSING_SUBSYSTEM_DEF(overlays) wait = 1 priority = 500 init_order = INIT_ORDER_OVERLAY - runlevel_min = RUNLEVEL_LOBBY + runlevels = RUNLEVELS_DEFAULT | RUNLEVEL_SETUP stat_tag = "Ov" currentrun = null diff --git a/code/controllers/subsystem/server_maint.dm b/code/controllers/subsystem/server_maint.dm index b69188d1477..a24d952b9dc 100644 --- a/code/controllers/subsystem/server_maint.dm +++ b/code/controllers/subsystem/server_maint.dm @@ -5,7 +5,7 @@ SUBSYSTEM_DEF(server_maint) wait = 6 flags = SS_POST_FIRE_TIMING priority = 10 - runlevel_min = RUNLEVEL_LOBBY + runlevels = RUNLEVEL_LOBBY | RUNLEVELS_DEFAULT var/list/currentrun /datum/controller/subsystem/server_maint/Initialize(timeofday) diff --git a/code/controllers/subsystem/shuttle.dm b/code/controllers/subsystem/shuttle.dm index d23d0a0111a..dc91b0f4d56 100644 --- a/code/controllers/subsystem/shuttle.dm +++ b/code/controllers/subsystem/shuttle.dm @@ -5,7 +5,7 @@ SUBSYSTEM_DEF(shuttle) wait = 10 init_order = INIT_ORDER_SHUTTLE flags = SS_KEEP_TIMING|SS_NO_TICK_CHECK - runlevel_max = RUNLEVEL_GAME + runlevels = RUNLEVEL_SETUP | RUNLEVEL_GAME var/list/mobile = list() var/list/stationary = list() diff --git a/code/controllers/subsystem/spacedrift.dm b/code/controllers/subsystem/spacedrift.dm index b3b530611a6..8fe7cbe048f 100644 --- a/code/controllers/subsystem/spacedrift.dm +++ b/code/controllers/subsystem/spacedrift.dm @@ -3,7 +3,7 @@ SUBSYSTEM_DEF(spacedrift) priority = 30 wait = 5 flags = SS_NO_INIT|SS_KEEP_TIMING - runlevel_min = RUNLEVEL_GAME + runlevels = RUNLEVEL_GAME | RUNLEVEL_POSTGAME var/list/currentrun = list() var/list/processing = list() diff --git a/code/controllers/subsystem/tgui.dm b/code/controllers/subsystem/tgui.dm index 2f2e80f16f3..52fd286eedb 100644 --- a/code/controllers/subsystem/tgui.dm +++ b/code/controllers/subsystem/tgui.dm @@ -3,7 +3,7 @@ SUBSYSTEM_DEF(tgui) wait = 9 flags = SS_NO_INIT priority = 110 - runlevel_min = RUNLEVEL_LOBBY + runlevels = RUNLEVEL_LOBBY | RUNLEVELS_DEFAULT var/list/currentrun = list() var/list/open_uis = list() // A list of open UIs, grouped by src_object and ui_key. diff --git a/code/controllers/subsystem/throwing.dm b/code/controllers/subsystem/throwing.dm index 8d95d3fa294..4ae31e98d65 100644 --- a/code/controllers/subsystem/throwing.dm +++ b/code/controllers/subsystem/throwing.dm @@ -6,6 +6,7 @@ SUBSYSTEM_DEF(throwing) priority = 25 wait = 1 flags = SS_NO_INIT|SS_KEEP_TIMING|SS_TICKER + runlevels = RUNLEVEL_GAME | RUNLEVEL_POSTGAME var/list/currentrun var/list/processing = list() diff --git a/code/controllers/subsystem/ticker.dm b/code/controllers/subsystem/ticker.dm index d3f0176dd8f..854baefaf7a 100644 --- a/code/controllers/subsystem/ticker.dm +++ b/code/controllers/subsystem/ticker.dm @@ -6,8 +6,7 @@ SUBSYSTEM_DEF(ticker) priority = 200 flags = SS_KEEP_TIMING - runlevel_min = RUNLEVEL_LOBBY - runlevel_max = RUNLEVEL_GAME + runlevels = RUNLEVEL_LOBBY | RUNLEVEL_SETUP | RUNLEVEL_GAME var/current_state = GAME_STATE_STARTUP //state of current round (used by process()) Use the defines GAME_STATE_* ! var/force_ending = 0 //Round was ended by admin intervention diff --git a/code/controllers/subsystem/time_track.dm b/code/controllers/subsystem/time_track.dm index 1e82057dbf9..cb190206b7d 100644 --- a/code/controllers/subsystem/time_track.dm +++ b/code/controllers/subsystem/time_track.dm @@ -2,7 +2,7 @@ SUBSYSTEM_DEF(time_track) name = "Time Tracking" wait = 600 flags = SS_NO_INIT|SS_NO_TICK_CHECK - runlevel_min = RUNLEVEL_LOBBY + runlevels = RUNLEVEL_LOBBY | RUNLEVELS_DEFAULT var/time_dilation_current = 0 diff --git a/code/controllers/subsystem/vote.dm b/code/controllers/subsystem/vote.dm index 77d4d07afbc..a914074a418 100644 --- a/code/controllers/subsystem/vote.dm +++ b/code/controllers/subsystem/vote.dm @@ -4,7 +4,7 @@ SUBSYSTEM_DEF(vote) flags = SS_KEEP_TIMING|SS_NO_INIT - runlevel_min = RUNLEVEL_LOBBY + runlevels = RUNLEVEL_LOBBY | RUNLEVELS_DEFAULT var/initiator = null var/started_time = null diff --git a/code/controllers/subsystem/weather.dm b/code/controllers/subsystem/weather.dm index 6245aa927f8..88102e260cb 100644 --- a/code/controllers/subsystem/weather.dm +++ b/code/controllers/subsystem/weather.dm @@ -3,8 +3,7 @@ SUBSYSTEM_DEF(weather) name = "Weather" flags = SS_BACKGROUND wait = 10 - runlevel_min = RUNLEVEL_GAME - runlevel_max = RUNLEVEL_GAME + runlevels = RUNLEVEL_GAME var/list/processing = list() var/list/existing_weather = list() var/list/eligible_zlevels = list(ZLEVEL_LAVALAND)