SS init tags V2 (#15502)

* SS init tags V2

* Sabre tweaks
This commit is contained in:
AffectedArc07
2021-02-15 13:02:50 -05:00
committed by GitHub
parent 577b24b8dc
commit c7d01c9b57
8 changed files with 77 additions and 100 deletions
+8
View File
@@ -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, "<span class='danger'><small>\[[name]]</small> [message]</span>")
log_world("\[[name]] [message]")
+32 -19
View File
@@ -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, "<span class='boldannounce'>[msg]</span>")
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])"))
+1 -3
View File
@@ -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, "<span class='boldannounce'>[msg]</span>")
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.
+2 -2
View File
@@ -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
+3 -3
View File
@@ -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)
+31 -1
View File
@@ -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