diff --git a/code/__HELPERS/_logging.dm b/code/__HELPERS/_logging.dm
index 80afcc6819a..38176cd0981 100644
--- a/code/__HELPERS/_logging.dm
+++ b/code/__HELPERS/_logging.dm
@@ -147,13 +147,6 @@ GLOBAL_PROTECT(log_end)
rustg_log_write(GLOB.sql_log, "[text][GLOB.log_end]")
SEND_TEXT(world.log, text) // Redirect it to DD too
-/**
- * Standardized method for tracking startup times.
- */
-/proc/log_startup_progress(var/message)
- to_chat(world, "[message]")
- log_world(message)
-
// A logging proc that only outputs after setup is done, to
// help devs test initialization stuff that happens a lot
/proc/log_after_setup(var/message)
diff --git a/code/controllers/controller.dm b/code/controllers/controller.dm
index c9d5f1e5650..54f984005c8 100644
--- a/code/controllers/controller.dm
+++ b/code/controllers/controller.dm
@@ -17,3 +17,11 @@
/datum/controller/proc/Recover()
/datum/controller/proc/stat_entry()
+
+/**
+ * Standardized method for tracking startup times.
+ */
+/datum/controller/proc/log_startup_progress(message)
+ Master.current_init_stage = "([name]): [message]"
+ to_chat(world, "\[[name]] [message]")
+ log_world("\[[name]] [message]")
diff --git a/code/controllers/master.dm b/code/controllers/master.dm
index 9a119bfa6a3..82e2517823a 100644
--- a/code/controllers/master.dm
+++ b/code/controllers/master.dm
@@ -17,48 +17,61 @@ GLOBAL_REAL(Master, /datum/controller/master) = new
/datum/controller/master
name = "Master"
- // Are we processing (higher values increase the processing delay by n ticks)
- var/processing = TRUE
- // How many times have we ran
+ /// Are we processing (higher values increase the processing delay by n ticks)
+ var/processing = 1
+ /// How many times have we ran
var/iteration = 0
- // world.time of last fire, for tracking lag outside of the mc
+ /// world.time of last fire, for tracking lag outside of the mc
var/last_run
- // List of subsystems to process().
+ /// List of subsystems to fire().
var/list/subsystems
+ /// Current init stage
+ var/current_init_stage
+
// Vars for keeping track of tick drift.
var/init_timeofday
var/init_time
var/tickdrift = 0
+ /// How long is the MC sleeping between runs, read only (set by Loop() based off of anti-tick-contention heuristics)
var/sleep_delta = 1
+ /// Set this to 1 to debug the MC with a detailed stack trace. Do not set on a production server.
var/make_runtime = 0
- var/initializations_finished_with_no_players_logged_in //I wonder what this could be?
+ /// Did inits finish with no one logged in
+ var/initializations_finished_with_no_players_logged_in
- // The type of the last subsystem to be process()'d.
+ // The type of the last subsystem to be fire()'d.
var/last_type_processed
- var/datum/controller/subsystem/queue_head //Start of queue linked list
- var/datum/controller/subsystem/queue_tail //End of queue linked list (used for appending to the list)
- var/queue_priority_count = 0 //Running total so that we don't have to loop thru the queue each run to split up the tick
- var/queue_priority_count_bg = 0 //Same, but for background subsystems
- var/map_loading = FALSE //Are we loading in a new map?
+ /// Start of queue linked list
+ var/datum/controller/subsystem/queue_head
+ /// End of queue linked list (used for appending to the list)
+ var/datum/controller/subsystem/queue_tail
+ /// Running total so that we don't have to loop thru the queue each run to split up the tick
+ var/queue_priority_count = 0
+ /// Same, but for background subsystems
+ var/queue_priority_count_bg = 0
+ /// Are we loading in a new map?
+ var/map_loading = FALSE
- var/current_runlevel //for scheduling different subsystems for different stages of the round
+ /// For scheduling different subsystems for different stages of the round
+ var/current_runlevel
+ /// Do we want to sleep until players log in?
var/sleep_offline_after_initializations = TRUE
var/static/restart_clear = 0
var/static/restart_timeout = 0
var/static/restart_count = 0
+ /// Random seed generated for randomness if entropy is required
var/static/random_seed
- //current tick limit, assigned before running a subsystem.
- //used by CHECK_TICK as well so that the procs subsystems call can obey that SS's tick limits
+ /// Current tick limit, assigned before running a subsystem. Used by CHECK_TICK as well so that the procs subsystems call can obey that SS's tick limits
var/static/current_ticklimit = TICK_LIMIT_RUNNING
/datum/controller/master/New()
@@ -185,14 +198,13 @@ GLOBAL_REAL(Master, /datum/controller/master) = new
for(var/datum/controller/subsystem/SS in subsystems)
if(SS.flags & SS_NO_INIT)
continue
+ SS.log_startup_progress("Initializing...")
SS.Initialize(REALTIMEOFDAY)
CHECK_TICK
current_ticklimit = TICK_LIMIT_RUNNING
var/time = (REALTIMEOFDAY - start_timeofday) / 10
- var/msg = "Initializations complete within [time] second[time == 1 ? "" : "s"]!"
- to_chat(world, "[msg]")
- log_world(msg)
+ log_startup_progress("Initializations complete within [time] second[time == 1 ? "" : "s"]!")
if(config.developer_express_start & SSticker.current_state == GAME_STATE_PREGAME)
SSticker.current_state = GAME_STATE_SETTING_UP
@@ -588,7 +600,8 @@ GLOBAL_REAL(Master, /datum/controller/master) = new
/datum/controller/master/stat_entry()
if(!statclick)
statclick = new/obj/effect/statclick/debug(null, "Initializing...", src)
-
+ if(current_init_stage)
+ stat("Init Stage", current_init_stage)
stat("Byond:", "(FPS:[world.fps]) (TickCount:[world.time / world.tick_lag]) (TickDrift:[round(Master.tickdrift, 1)]([round((Master.tickdrift / (world.time / world.tick_lag)) * 100, 0.1)]%))")
stat("Master Controller:", statclick.update("(TickRate:[Master.processing]) (Iteration:[Master.iteration])"))
diff --git a/code/controllers/subsystem.dm b/code/controllers/subsystem.dm
index c9934b128cf..f187fb7a9b9 100644
--- a/code/controllers/subsystem.dm
+++ b/code/controllers/subsystem.dm
@@ -162,9 +162,7 @@
/datum/controller/subsystem/Initialize(start_timeofday)
initialized = TRUE
var/time = (REALTIMEOFDAY - start_timeofday) / 10
- var/msg = "Initialized [name] subsystem within [time] second[time == 1 ? "" : "s"]!"
- to_chat(world, "[msg]")
- log_world(msg)
+ log_startup_progress("Initialized within [time] second[time == 1 ? "" : "s"]!")
return time
//hook for printing stats to the "MC" statuspanel for admins to see performance and related stats etc.
diff --git a/code/controllers/subsystem/air.dm b/code/controllers/subsystem/air.dm
index 6c755ce6b7a..6b08efe7b38 100644
--- a/code/controllers/subsystem/air.dm
+++ b/code/controllers/subsystem/air.dm
@@ -325,7 +325,7 @@ SUBSYSTEM_DEF(air)
var/watch = start_watch()
log_startup_progress("Initializing atmospherics machinery...")
var/count = _setup_atmos_machinery(machines_to_init)
- log_startup_progress(" Initialized [count] atmospherics machines in [stop_watch(watch)]s.")
+ log_startup_progress("Initialized [count] atmospherics machines in [stop_watch(watch)]s.")
// this underscored variant is so that we can have a means of late initing
// atmos machinery without a loud announcement to the world
@@ -349,7 +349,7 @@ SUBSYSTEM_DEF(air)
var/watch = start_watch()
log_startup_progress("Initializing pipe networks...")
var/count = _setup_pipenets(pipes)
- log_startup_progress(" Initialized [count] pipenets in [stop_watch(watch)]s.")
+ log_startup_progress("Initialized [count] pipenets in [stop_watch(watch)]s.")
// An underscored wrapper that exists for the same reason
// the machine init wrapper does
diff --git a/code/controllers/subsystem/atoms.dm b/code/controllers/subsystem/atoms.dm
index cbe8806fc15..cf29fb0619f 100644
--- a/code/controllers/subsystem/atoms.dm
+++ b/code/controllers/subsystem/atoms.dm
@@ -54,7 +54,7 @@ SUBSYSTEM_DEF(atoms)
CHECK_TICK
if(noisy)
- log_startup_progress(" Initialized [count] atoms in [stop_watch(watch)]s")
+ log_startup_progress("Initialized [count] atoms in [stop_watch(watch)]s")
else
log_debug(" Initialized [count] atoms in [stop_watch(watch)]s")
pass(count)
@@ -71,9 +71,9 @@ SUBSYSTEM_DEF(atoms)
var/atom/A = I
A.LateInitialize()
if(noisy)
- log_startup_progress(" Late initialized [late_loaders.len] atoms in [stop_watch(watch)]s")
+ log_startup_progress("Late initialized [length(late_loaders)] atoms in [stop_watch(watch)]s")
else
- log_debug(" Late initialized [late_loaders.len] atoms in [stop_watch(watch)]s")
+ log_debug(" Late initialized [length(late_loaders)] atoms in [stop_watch(watch)]s")
late_loaders.Cut()
/datum/controller/subsystem/atoms/proc/InitAtom(atom/A, list/arguments)
diff --git a/code/controllers/subsystem/mapping.dm b/code/controllers/subsystem/mapping.dm
index 533e3c6c024..ac8165aca7a 100644
--- a/code/controllers/subsystem/mapping.dm
+++ b/code/controllers/subsystem/mapping.dm
@@ -8,7 +8,7 @@ SUBSYSTEM_DEF(mapping)
preloadTemplates()
// Pick a random away mission.
if(!config.disable_away_missions)
- createRandomZlevel()
+ load_away_mission()
// Seed space ruins
if(!config.disable_space_ruins)
// load in extra levels of space ruins
@@ -162,5 +162,35 @@ SUBSYSTEM_DEF(mapping)
log_world("Ruin loader finished with [budget] left to spend.")
+/datum/controller/subsystem/mapping/proc/load_away_mission()
+ if(length(GLOB.awaydestinations))
+ return
+
+ if(GLOB.potentialRandomZlevels && length(GLOB.potentialRandomZlevels))
+ var/watch = start_watch()
+ log_startup_progress("Loading away mission...")
+
+ var/map = pick(GLOB.potentialRandomZlevels)
+ var/file = file(map)
+ if(isfile(file))
+ var/zlev = GLOB.space_manager.add_new_zlevel(AWAY_MISSION, linkage = UNAFFECTED, traits = list(AWAY_LEVEL,BLOCK_TELEPORT))
+ GLOB.space_manager.add_dirt(zlev)
+ GLOB.maploader.load_map(file, z_offset = zlev)
+ late_setup_level(block(locate(1, 1, zlev), locate(world.maxx, world.maxy, zlev)))
+ GLOB.space_manager.remove_dirt(zlev)
+ log_world("Away mission loaded: [map]")
+
+ for(var/thing in GLOB.landmarks_list)
+ var/obj/effect/landmark/L = thing
+ if(L.name != "awaystart")
+ continue
+ GLOB.awaydestinations.Add(L)
+
+ log_startup_progress("Away mission loaded in [stop_watch(watch)]s.")
+
+ else
+ log_startup_progress("No away missions found.")
+ return
+
/datum/controller/subsystem/mapping/Recover()
flags |= SS_NO_INIT
diff --git a/code/modules/awaymissions/zlevel.dm b/code/modules/awaymissions/zlevel.dm
index c582508ace1..641b7e0815e 100644
--- a/code/modules/awaymissions/zlevel.dm
+++ b/code/modules/awaymissions/zlevel.dm
@@ -38,71 +38,6 @@ GLOBAL_LIST_INIT(potentialRandomZlevels, generateMapList(filename = "config/away
qdel(otherthing)
T.ChangeTurf(T.baseturf)
-/proc/createRandomZlevel()
- if(GLOB.awaydestinations.len) //crude, but it saves another var!
- return
-
- if(GLOB.potentialRandomZlevels && GLOB.potentialRandomZlevels.len)
- var/watch = start_watch()
- log_startup_progress("Loading away mission...")
-
- var/map = pick(GLOB.potentialRandomZlevels)
- var/file = file(map)
- if(isfile(file))
- var/zlev = GLOB.space_manager.add_new_zlevel(AWAY_MISSION, linkage = UNAFFECTED, traits = list(AWAY_LEVEL,BLOCK_TELEPORT))
- GLOB.space_manager.add_dirt(zlev)
- GLOB.maploader.load_map(file, z_offset = zlev)
- late_setup_level(block(locate(1, 1, zlev), locate(world.maxx, world.maxy, zlev)))
- GLOB.space_manager.remove_dirt(zlev)
- log_world(" Away mission loaded: [map]")
-
- for(var/thing in GLOB.landmarks_list)
- var/obj/effect/landmark/L = thing
- if(L.name != "awaystart")
- continue
- GLOB.awaydestinations.Add(L)
-
- log_startup_progress(" Away mission loaded in [stop_watch(watch)]s.")
-
- else
- log_startup_progress(" No away missions found.")
- return
-
-
-/proc/createALLZlevels()
- if(GLOB.awaydestinations.len) //crude, but it saves another var!
- return
-
- if(GLOB.potentialRandomZlevels && GLOB.potentialRandomZlevels.len)
- var/watch = start_watch()
- log_startup_progress("Loading away missions...")
-
- for(var/map in GLOB.potentialRandomZlevels)
- var/file = file(map)
- if(isfile(file))
- log_startup_progress("Loading away mission: [map]")
- var/zlev = GLOB.space_manager.add_new_zlevel()
- GLOB.space_manager.add_dirt(zlev)
- GLOB.maploader.load_map(file, z_offset = zlev)
- late_setup_level(block(locate(1, 1, zlev), locate(world.maxx, world.maxy, zlev)))
- GLOB.space_manager.remove_dirt(zlev)
- log_world(" Away mission loaded: [map]")
-
- //map_transition_config.Add(AWAY_MISSION_LIST)
-
- for(var/thing in GLOB.landmarks_list)
- var/obj/effect/landmark/L = thing
- if(L.name != "awaystart")
- continue
- GLOB.awaydestinations.Add(L)
-
- log_startup_progress(" Away mission loaded in [stop_watch(watch)]s.")
- watch = start_watch()
-
- else
- log_startup_progress(" No away missions found.")
- return
-
/proc/generateMapList(filename)
var/list/potentialMaps = list()
var/list/Lines = file2list(filename)