Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moves init time display out of chat (and make it hideable since most people don't care) #656

Merged
merged 3 commits into from
Feb 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions code/__DEFINES/MC.dm
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@
/// It should not be used simply to silence CI.
#define SS_OK_TO_FAIL_INIT (1 << 6)

/// Don't show when this has init'd
#define SS_NO_INIT_MESSAGE (1 << 7)

//! SUBSYSTEM STATES
#define SS_IDLE 0 /// ain't doing shit.
#define SS_QUEUED 1 /// queued to run
Expand Down
3 changes: 0 additions & 3 deletions code/__DEFINES/subsystems.dm
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,6 @@
/// If your system doesn't need to be initialized (by being disabled or something)
#define SS_INIT_NO_NEED 3

/// Succesfully initialized, BUT do not announce it to players (generally to hide game mechanics it would otherwise spoil)
#define SS_INIT_NO_MESSAGE 4

//! ### SS initialization load orders
// Subsystem init_order, from highest priority to lowest priority
// Subsystems shutdown in the reverse of the order they initialize in
Expand Down
2 changes: 1 addition & 1 deletion code/__HELPERS/game.dm
Original file line number Diff line number Diff line change
Expand Up @@ -300,4 +300,4 @@
message = html_encode(message)
else
message = copytext(message, 2)
to_chat(target, span_purple(examine_block("<span class='oocplain'><b>Tip of the round: </b>[message]</span>")))
to_chat(target, span_purple(examine_block("<b>Tip of the round: </b>[message]")))
46 changes: 20 additions & 26 deletions code/controllers/master.dm
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,6 @@ GLOBAL_REAL(Master, /datum/controller/master)
init_stage_completed = 0
var/mc_started = FALSE

to_chat(world, span_boldannounce("Initializing subsystems..."))

var/list/stage_sorted_subsystems = new(INITSTAGE_MAX)
for (var/i in 1 to INITSTAGE_MAX)
stage_sorted_subsystems[i] = list()
Expand Down Expand Up @@ -251,14 +249,9 @@ GLOBAL_REAL(Master, /datum/controller/master)
// Loop.
Master.StartProcessing(0)

var/time = (REALTIMEOFDAY - start_timeofday) / 10



var/msg = "Initializations complete within [time] second[time == 1 ? "" : "s"]!"
to_chat(world, span_boldannounce("[msg]"))
log_world(msg)

var/time = (REALTIMEOFDAY - start_timeofday) / (1 SECONDS)
SStitle.total_init_time = time
log_world("Initializations complete within [time] second\s!")

if(world.system_type == MS_WINDOWS && CONFIG_GET(flag/toast_notification_on_init) && !length(GLOB.clients))
world.shelleo("start /min powershell -ExecutionPolicy Bypass -File tools/initToast/initToast.ps1 -name \"[world.name]\" -icon %CD%\\icons\\ui_icons\\common\\tg_16.png -port [world.port]")
Expand Down Expand Up @@ -290,15 +283,15 @@ GLOBAL_REAL(Master, /datum/controller/master)
SS_INIT_NONE,
SS_INIT_SUCCESS,
SS_INIT_NO_NEED,
SS_INIT_NO_MESSAGE,
)

if (subsystem.flags & SS_NO_INIT || 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)

if(!(subsystem.flags & SS_NO_INIT_MESSAGE))
SStitle.add_init_text(subsystem.type, "- [subsystem.name]", "<font color='yellow'>INITIALIZING...</font>")
var/result = subsystem.Initialize()

// Capture end time
Expand Down Expand Up @@ -326,32 +319,33 @@ GLOBAL_REAL(Master, /datum/controller/master)
subsystem.initialized = FALSE
subsystem.can_fire = FALSE

// The rest of this proc is printing the world log and chat message.
// The rest of this proc is printing the world log and updating the splash screen.
var/message_prefix

// If true, print the chat message with boldwarning text.
var/chat_warning = FALSE

var/screen_display = ""
var/always_show = FALSE
switch(result)
if(SS_INIT_FAILURE)
message_prefix = "Failed to initialize [subsystem.name] subsystem after"
chat_warning = TRUE
if(SS_INIT_SUCCESS, SS_INIT_NO_MESSAGE)
screen_display = "<font color='red'>FAILED</font>"
always_show = TRUE
if(SS_INIT_SUCCESS)
message_prefix = "Initialized [subsystem.name] subsystem within"
screen_display = "<font color='green'>DONE</font>"
if(SS_INIT_NO_NEED)
// This SS is disabled or is otherwise shy.
return
pass()
else
// SS_INIT_NONE or an invalid value.
message_prefix = "Initialized [subsystem.name] subsystem with errors within"
chat_warning = TRUE
screen_display = "<font color='yellow'>ERRORED</font>"
always_show = TRUE

var/message = "[message_prefix] [seconds] second[seconds == 1 ? "" : "s"]!"
var/chat_message = chat_warning ? span_boldwarning(message) : span_boldannounce(message)
if(screen_display && (always_show || (seconds > 0.1 && !(subsystem.flags & SS_NO_INIT_MESSAGE))))
SStitle.add_init_text(subsystem.type, "- [subsystem.name]", screen_display, seconds, major_update = TRUE)
else
SStitle.remove_init_text(subsystem.type)

if(result != SS_INIT_NO_MESSAGE)
to_chat(world, chat_message)
log_world(message)
log_world("[message_prefix] [seconds] second\s!")

/datum/controller/master/proc/SetRunLevel(new_runlevel)
var/old_runlevel = current_runlevel
Expand Down
25 changes: 21 additions & 4 deletions code/controllers/subsystem/assets.dm
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,27 @@ SUBSYSTEM_DEF(assets)


/datum/controller/subsystem/assets/Initialize()
for(var/type in typesof(/datum/asset))
var/datum/asset/A = type
if (type != initial(A._abstract))
load_asset_datum(type)
for(var/datum/asset/asset_type as anything in typesof(/datum/asset))
if (asset_type == initial(asset_type._abstract))
continue

if (initial(asset_type.early))
continue

var/pre_init = REALTIMEOFDAY
var/list/typepath_split = splittext("[asset_type]", "/")
var/typepath_readable = capitalize(replacetext(typepath_split[length(typepath_split)], "_", " "))

SStitle.add_init_text(asset_type, "> [typepath_readable]", "<font color='yellow'>CREATING...</font>")
if (load_asset_datum(asset_type))
var/time = (REALTIMEOFDAY - pre_init) / (1 SECONDS)
if(time <= 0.1)
SStitle.remove_init_text(asset_type)
else
SStitle.add_init_text(asset_type, "> [typepath_readable]", "<font color='green'>DONE</font>", time)
else
stack_trace("Could not initialize early asset [asset_type]!")
SStitle.add_init_text(asset_type, "> [typepath_readable]", "<font color='red'>FAILED</font>")

transport.Initialize(cache)

Expand Down
14 changes: 13 additions & 1 deletion code/controllers/subsystem/early_assets.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,20 @@ SUBSYSTEM_DEF(early_assets)
if (!initial(asset_type.early))
continue

if (!load_asset_datum(asset_type))
var/pre_init = REALTIMEOFDAY
var/list/typepath_split = splittext("[asset_type]", "/")
var/typepath_readable = capitalize(replacetext(typepath_split[length(typepath_split)], "_", " "))

SStitle.add_init_text(asset_type, "> [typepath_readable]", "<font color='yellow'>CREATING...</font>")
if (load_asset_datum(asset_type))
var/time = (REALTIMEOFDAY - pre_init) / (1 SECONDS)
if(time <= 0.1)
SStitle.remove_init_text(asset_type)
else
SStitle.add_init_text(asset_type, "> [typepath_readable]", "<font color='green'>DONE</font>", time)
else
stack_trace("Could not initialize early asset [asset_type]!")
SStitle.add_init_text(asset_type, "> [typepath_readable]", "<font color='red'>FAILED</font>")

CHECK_TICK

Expand Down
22 changes: 18 additions & 4 deletions code/controllers/subsystem/mapping.dm
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,11 @@ SUBSYSTEM_DEF(mapping)
process_teleport_locs() //Sets up the wizard teleport locations
preloadTemplates()

var/start_time

#ifndef LOWMEMORYMODE
start_time = REALTIMEOFDAY
SStitle.add_init_text("Empty Space", "> Space", "<font color='yellow'>LOADING...</font>")
// Create space ruin levels
while (space_levels_so_far < config.space_ruin_levels)
add_new_zlevel("Ruin Area [space_levels_so_far+1]", ZTRAITS_SPACE)
Expand All @@ -139,17 +143,27 @@ SUBSYSTEM_DEF(mapping)
while (space_levels_so_far < config.space_empty_levels + config.space_ruin_levels)
empty_space = add_new_zlevel("Empty Area [space_levels_so_far+1]", list(ZTRAIT_LINKAGE = CROSSLINKED))
++space_levels_so_far
SStitle.add_init_text("Empty Space", "> Space", "<font color='green'>DONE</font>", (REALTIMEOFDAY - start_time) / (1 SECONDS))

start_time = REALTIMEOFDAY
// Pick a random away mission.
if(CONFIG_GET(flag/roundstart_away))
SStitle.add_init_text("Away Mission", "> Away Mission", "<font color='yellow'>LOADING...</font>")
createRandomZlevel(prob(CONFIG_GET(number/config_gateway_chance)))

SStitle.add_init_text("Away Mission", "> Away Mission", "<font color='green'>DONE</font>", (REALTIMEOFDAY - start_time) / (1 SECONDS))
else if (SSmapping.config.load_all_away_missions) // we're likely in a local testing environment, so punch it.
SStitle.add_init_text("Away Mission", "> All Away Missions", "<font color='yellow'>LOADING...</font>")
load_all_away_missions()
SStitle.add_init_text("Away Mission", "> All Away Missions", "<font color='green'>DONE</font>", (REALTIMEOFDAY - start_time) / (1 SECONDS))
else
SStitle.add_init_text("Away Mission", "> Away Mission", "<font color='yellow'>SKIPPED</font>")

start_time = REALTIMEOFDAY
SStitle.add_init_text("Ruins", "> Ruins", "<font color='yellow'>LOADING...</font>")
loading_ruins = TRUE
setup_ruins()
loading_ruins = FALSE
SStitle.add_init_text("Ruins", "> Ruins", "<font color='green'>DONE</font>", (REALTIMEOFDAY - start_time) / (1 SECONDS))

#endif
// Run map generation after ruin generation to prevent issues
Expand Down Expand Up @@ -373,7 +387,8 @@ Used by the AI doomsday and the self-destruct nuke.
/datum/controller/subsystem/mapping/proc/LoadGroup(list/errorList, name, path, files, list/traits, list/default_traits, silent = FALSE)
. = list()
var/start_time = REALTIMEOFDAY

if(!silent)
SStitle.add_init_text(path, "> [name]", "<font color='yellow'>LOADING...</font>")
if (!islist(files)) // handle single-level maps
files = list(files)

Expand Down Expand Up @@ -416,7 +431,7 @@ Used by the AI doomsday and the self-destruct nuke.
if (!pm.load(x_offset, y_offset, start_z + parsed_maps[P], no_changeturf = TRUE, new_z = TRUE))
errorList |= pm.original_path
if(!silent)
INIT_ANNOUNCE("Loaded [name] in [(REALTIMEOFDAY - start_time)/10]s!")
SStitle.add_init_text(path, "> [name]", "<font color='green'>DONE</font>", (REALTIMEOFDAY - start_time) / (1 SECONDS))
return parsed_maps

/datum/controller/subsystem/mapping/proc/loadWorld()
Expand All @@ -428,7 +443,6 @@ Used by the AI doomsday and the self-destruct nuke.

// load the station
station_start = world.maxz + 1
INIT_ANNOUNCE("Loading [config.map_name]...")
LoadGroup(FailedZs, "Station", config.map_path, config.map_file, config.traits, ZTRAITS_STATION)

if(SSdbcore.Connect())
Expand Down
4 changes: 2 additions & 2 deletions code/controllers/subsystem/radioactive_nebula.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/// Controls making objects irradiated when Radioactive Nebula is in effect.
SUBSYSTEM_DEF(radioactive_nebula)
name = "Radioactive Nebula"
flags = SS_BACKGROUND
flags = SS_BACKGROUND|SS_NO_INIT_MESSAGE
wait = 30 SECONDS

VAR_PRIVATE
Expand All @@ -21,7 +21,7 @@ SUBSYSTEM_DEF(radioactive_nebula)
irradiate_everything()

// Don't leak that the station trait has been picked
return SS_INIT_NO_MESSAGE
return SS_INIT_SUCCESS

/// Makes something appear irradiated for the purposes of the Radioactive Nebula
/datum/controller/subsystem/radioactive_nebula/proc/fake_irradiate(atom/movable/target)
Expand Down
3 changes: 2 additions & 1 deletion code/controllers/subsystem/ticker.dm
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ SUBSYSTEM_DEF(ticker)
send2chat(new /datum/tgs_message_content("New round starting on [SSmapping.config.map_name]!"), CONFIG_GET(string/channel_announce_new_game))
current_state = GAME_STATE_PREGAME
SEND_SIGNAL(src, COMSIG_TICKER_ENTER_PREGAME)

SStitle.update_init_text()
fire()
if(GAME_STATE_PREGAME)
//lobby stats for statpanels
Expand All @@ -188,6 +188,7 @@ SUBSYSTEM_DEF(ticker)
if(timeLeft <= 300 && !tipped)
send_tip_of_the_round(world, selected_tip)
tipped = TRUE
SStitle.fade_init_text()

if(timeLeft <= 0)
SEND_SIGNAL(src, COMSIG_TICKER_ENTER_SETTING_UP)
Expand Down
Loading
Loading