mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 10:12:45 +00:00
Subsystem return update (#7881)
This commit is contained in:
@@ -59,9 +59,11 @@ GLOBAL_REAL(Master, /datum/controller/master) = new
|
||||
|
||||
var/current_runlevel //!for scheduling different subsystems for different stages of the round
|
||||
|
||||
// CHOMPEdit Start
|
||||
/// During initialization, will be the instanced subsytem that is currently initializing.
|
||||
/// Outside of initialization, returns null.
|
||||
var/current_initializing_subsystem = null
|
||||
// CHOMPEdit End
|
||||
|
||||
var/static/restart_clear = 0
|
||||
var/static/restart_timeout = 0
|
||||
@@ -207,8 +209,10 @@ GLOBAL_REAL(Master, /datum/controller/master) = new
|
||||
for (var/datum/controller/subsystem/SS in subsystems)
|
||||
if (SS.flags & SS_NO_INIT)
|
||||
continue
|
||||
SS.Initialize(REALTIMEOFDAY)
|
||||
//SS.Initialize(REALTIMEOFDAY) // CHOMPEdit
|
||||
init_subsystem(SS) // CHOMPEdit
|
||||
CHECK_TICK
|
||||
current_initializing_subsystem = null // CHOMPEdit
|
||||
current_ticklimit = TICK_LIMIT_RUNNING
|
||||
var/time = (REALTIMEOFDAY - start_timeofday) / 10
|
||||
|
||||
@@ -239,6 +243,82 @@ GLOBAL_REAL(Master, /datum/controller/master) = new
|
||||
// Loop.
|
||||
Master.StartProcessing(0)
|
||||
|
||||
// CHOMPEdit Start
|
||||
/**
|
||||
* Initialize a given subsystem and handle the results.
|
||||
*
|
||||
* Arguments:
|
||||
* * subsystem - the subsystem to initialize.
|
||||
*/
|
||||
/datum/controller/master/proc/init_subsystem(datum/controller/subsystem/subsystem)
|
||||
var/static/list/valid_results = list(
|
||||
SS_INIT_FAILURE,
|
||||
SS_INIT_NONE,
|
||||
SS_INIT_SUCCESS,
|
||||
SS_INIT_NO_NEED,
|
||||
)
|
||||
|
||||
if (subsystem.flags & SS_NO_INIT || subsystem.subsystem_initialized) //Don't init SSs with the corresponding flag or if they already are initialized
|
||||
return
|
||||
|
||||
current_initializing_subsystem = subsystem
|
||||
rustg_time_reset(SS_INIT_TIMER_KEY)
|
||||
|
||||
var/result = subsystem.Initialize()
|
||||
|
||||
// Capture end time
|
||||
var/time = rustg_time_milliseconds(SS_INIT_TIMER_KEY)
|
||||
var/seconds = round(time / 1000, 0.01)
|
||||
|
||||
// Always update the blackbox tally regardless.
|
||||
// SSblackbox.record_feedback("tally", "subsystem_initialize", time, subsystem.name)
|
||||
feedback_set_details("subsystem_initialize", "[time] [subsystem.name]")
|
||||
|
||||
// Gave invalid return value.
|
||||
if(result && !(result in valid_results))
|
||||
warning("[subsystem.name] subsystem initialized, returning invalid result [result]. This is a bug.")
|
||||
|
||||
// just returned ..() or didn't implement Initialize() at all
|
||||
if(result == SS_INIT_NONE)
|
||||
warning("[subsystem.name] subsystem does not implement Initialize() or it returns ..(). If the former is true, the SS_NO_INIT flag should be set for this subsystem.")
|
||||
|
||||
if(result != SS_INIT_FAILURE)
|
||||
// Some form of success, implicit failure, or the SS in unused.
|
||||
subsystem.subsystem_initialized = TRUE
|
||||
|
||||
SEND_SIGNAL(subsystem, COMSIG_SUBSYSTEM_POST_INITIALIZE)
|
||||
else
|
||||
// The subsystem officially reports that it failed to init and wishes to be treated as such.
|
||||
subsystem.subsystem_initialized = FALSE
|
||||
subsystem.can_fire = FALSE
|
||||
|
||||
// The rest of this proc is printing the world log and chat message.
|
||||
var/message_prefix
|
||||
|
||||
// If true, print the chat message with boldwarning text.
|
||||
var/chat_warning = FALSE
|
||||
|
||||
switch(result)
|
||||
if(SS_INIT_FAILURE)
|
||||
message_prefix = "Failed to initialize [subsystem.name] subsystem after"
|
||||
chat_warning = TRUE
|
||||
if(SS_INIT_SUCCESS)
|
||||
message_prefix = "Initialized [subsystem.name] subsystem within"
|
||||
if(SS_INIT_NO_NEED)
|
||||
// This SS is disabled or is otherwise shy.
|
||||
return
|
||||
else
|
||||
// SS_INIT_NONE or an invalid value.
|
||||
message_prefix = "Initialized [subsystem.name] subsystem with errors within"
|
||||
chat_warning = TRUE
|
||||
|
||||
var/message = "[message_prefix] [seconds] second[seconds == 1 ? "" : "s"]!"
|
||||
var/chat_message = chat_warning ? span_boldwarning(message) : span_boldannounce(message)
|
||||
|
||||
to_chat(world, chat_message)
|
||||
log_world(message)
|
||||
// CHOMPEdit End
|
||||
|
||||
/datum/controller/master/proc/SetRunLevel(new_runlevel)
|
||||
var/old_runlevel = isnull(current_runlevel) ? "NULL" : runlevel_flags[current_runlevel]
|
||||
testing("MC: Runlevel changed from [old_runlevel] to [new_runlevel]")
|
||||
|
||||
Reference in New Issue
Block a user