diff --git a/code/__DEFINES/_globals.dm b/code/__DEFINES/_globals.dm index e68cc764f8a..3639d559255 100644 --- a/code/__DEFINES/_globals.dm +++ b/code/__DEFINES/_globals.dm @@ -1,4 +1,5 @@ -//See also controllers/globals.dm +// See also controllers/globals.dm +// See initialization order in /code/game/world.dm /// Creates a global initializer with a given InitValue expression, do not use #define GLOBAL_MANAGED(X, InitValue)\ @@ -20,11 +21,12 @@ #define GLOBAL_PROTECT(X) #endif -/// Standard BYOND global, do not use -#define GLOBAL_REAL_VAR(X) var/global/##X +/// Standard BYOND global, seriously do not use without an earthshakingly good reason +#define GLOBAL_REAL_VAR(X) var/global/##X; -/// Standard typed BYOND global, do not use -#define GLOBAL_REAL(X, Typepath) var/global##Typepath/##X + +/// Standard typed BYOND global, seriously do not use without an earthshakingly good reason +#define GLOBAL_REAL(X, Typepath) var/global##Typepath/##X; /// Defines a global var on the controller, do not use #define GLOBAL_RAW(X) /datum/controller/global_vars/var/global##X diff --git a/code/__DEFINES/_profile.dm b/code/__DEFINES/_profile.dm deleted file mode 100644 index 1a6a65cacb3..00000000000 --- a/code/__DEFINES/_profile.dm +++ /dev/null @@ -1,4 +0,0 @@ -#if DM_BUILD >= 1506 -// We don't actually care about storing the output here, this is just an easy way to ensure the profile runs first. -GLOBAL_REAL_VAR(world_init_profiler) = world.Profile(PROFILE_RESTART) -#endif diff --git a/code/__DEFINES/~skyrat_defines/logging.dm b/code/__DEFINES/~skyrat_defines/logging.dm index 04290297abf..5b62b6cd275 100644 --- a/code/__DEFINES/~skyrat_defines/logging.dm +++ b/code/__DEFINES/~skyrat_defines/logging.dm @@ -10,5 +10,4 @@ // Investigate #define INVESTIGATE_CIRCUIT "circuit" -GLOBAL_VAR(event_vote_log) -GLOBAL_PROTECT(event_vote_log) + diff --git a/code/__HELPERS/global_lists.dm b/code/__HELPERS/global_lists.dm index 8e06fce1a0a..707c7769265 100644 --- a/code/__HELPERS/global_lists.dm +++ b/code/__HELPERS/global_lists.dm @@ -2,7 +2,7 @@ /////Initial Building///// ////////////////////////// -/proc/make_datum_references_lists() +/proc/init_sprite_accessories() //hair init_sprite_accessory_subtypes(/datum/sprite_accessory/hair, GLOB.hairstyles_list, GLOB.hairstyles_male_list, GLOB.hairstyles_female_list) //facial hair @@ -51,18 +51,23 @@ sort_list(GLOB.laugh_types, GLOBAL_PROC_REF(cmp_typepaths_asc)) //SKYRAT EDIT END - //Species +/// Inits GLOB.species_list. Not using GLOBAL_LIST_INIT b/c it depends on GLOB.string_lists +/proc/init_species_list() for(var/spath in subtypesof(/datum/species)) var/datum/species/S = new spath() GLOB.species_list[S.id] = spath sort_list(GLOB.species_list, GLOBAL_PROC_REF(cmp_typepaths_asc)) - //Surgeries +/// Inits GLOB.surgeries +/proc/init_surgeries() + var/surgeries = list() for(var/path in subtypesof(/datum/surgery)) - GLOB.surgeries_list += new path() - sort_list(GLOB.surgeries_list, GLOBAL_PROC_REF(cmp_typepaths_asc)) + surgeries += new path() + sort_list(surgeries, GLOBAL_PROC_REF(cmp_typepaths_asc)) + return surgeries - // Hair Gradients - Initialise all /datum/sprite_accessory/hair_gradient into an list indexed by gradient-style name +/// Hair Gradients - Initialise all /datum/sprite_accessory/hair_gradient into an list indexed by gradient-style name +/proc/init_hair_gradients() for(var/path in subtypesof(/datum/sprite_accessory/gradient)) var/datum/sprite_accessory/gradient/gradient = new path() if(gradient.gradient_category & GRADIENT_APPLIES_TO_HAIR) @@ -70,10 +75,15 @@ if(gradient.gradient_category & GRADIENT_APPLIES_TO_FACIAL_HAIR) GLOB.facial_hair_gradients_list[gradient.name] = gradient - // Keybindings +/// Legacy procs that really should be replaced with proper _INIT macros +/proc/make_datum_reference_lists() + // I tried to eliminate this proc but I couldn't untangle their init-order interdependencies -Dominion/Cyberboss + init_sprite_accessories() + init_species_list() + init_hair_gradients() init_keybindings() - GLOB.emote_list = init_emote_list() + GLOB.emote_list = init_emote_list() // WHY DOES THIS NEED TO GO HERE? IT JUST INITS DATUMS make_skyrat_datum_references() //SKYRAT EDIT ADDITION - CUSTOMIZATION init_crafting_recipes() diff --git a/code/__HELPERS/logging/admin.dm b/code/__HELPERS/logging/admin.dm index 5e35d35d09f..6c659e4ea01 100644 --- a/code/__HELPERS/logging/admin.dm +++ b/code/__HELPERS/logging/admin.dm @@ -2,25 +2,25 @@ /// General logging for admin actions /proc/log_admin(text) - GLOB.admin_log.Add(text) + GLOB.admin_activities.Add(text) if (CONFIG_GET(flag/log_admin)) WRITE_LOG(GLOB.world_game_log, "ADMIN: [text]") /// Logging for admin actions on or with circuits /proc/log_admin_circuit(text) - GLOB.admin_log.Add(text) + GLOB.admin_activities.Add(text) if(CONFIG_GET(flag/log_admin)) WRITE_LOG(GLOB.world_game_log, "ADMIN: CIRCUIT: [text]") /// General logging for admin actions /proc/log_admin_private(text) - GLOB.admin_log.Add(text) + GLOB.admin_activities.Add(text) if (CONFIG_GET(flag/log_admin)) WRITE_LOG(GLOB.world_game_log, "ADMINPRIVATE: [text]") /// Logging for AdminSay (ASAY) messages /proc/log_adminsay(text) - GLOB.admin_log.Add(text) + GLOB.admin_activities.Add(text) if (CONFIG_GET(flag/log_adminchat)) WRITE_LOG(GLOB.world_game_log, "ADMINPRIVATE: ASAY: [text]") diff --git a/code/__HELPERS/stack_trace.dm b/code/__HELPERS/stack_trace.dm index a2feaec09f0..5c220d7a74a 100644 --- a/code/__HELPERS/stack_trace.dm +++ b/code/__HELPERS/stack_trace.dm @@ -2,11 +2,3 @@ /// Do not call directly, use the [stack_trace] macro instead. /proc/_stack_trace(message, file, line) CRASH("[message] ([file]:[line])") - -GLOBAL_REAL_VAR(list/stack_trace_storage) -/proc/gib_stack_trace() - stack_trace_storage = list() - stack_trace("") - stack_trace_storage.Cut(1, min(3,stack_trace_storage.len)) - . = stack_trace_storage - stack_trace_storage = null diff --git a/code/__HELPERS/~skyrat_helpers/logging.dm b/code/__HELPERS/~skyrat_helpers/logging.dm index 812a34f0384..e8de300d66a 100644 --- a/code/__HELPERS/~skyrat_helpers/logging.dm +++ b/code/__HELPERS/~skyrat_helpers/logging.dm @@ -3,9 +3,6 @@ if (CONFIG_GET(flag/log_subtler)) WRITE_LOG(GLOB.world_game_log, "SUBTLER EMOTE: [text]") -GLOBAL_VAR(character_creation_log) -GLOBAL_PROTECT(character_creation_log) - /// This logs subtler emotes in game.txt, if the conflig flag in config\skyrat\skyrat_config.txt is true. /proc/log_creator(text) WRITE_LOG(GLOB.character_creation_log, "CREATOR LOG: [text]") diff --git a/code/_debugger.dm b/code/_debugger.dm deleted file mode 100644 index 1518908fa9a..00000000000 --- a/code/_debugger.dm +++ /dev/null @@ -1,13 +0,0 @@ -//Datum used to init Auxtools debugging as early as possible -//Datum gets created in master.dm because for whatever reason global code in there gets runs first -//In case we ever figure out how to manipulate global init order please move the datum creation into this file -/datum/debugger - -/datum/debugger/New() - enable_debugger() - -/datum/debugger/proc/enable_debugger() - var/dll = world.GetConfig("env", "AUXTOOLS_DEBUG_DLL") - if (dll) - LIBCALL(dll, "auxtools_init")() - enable_debugging() diff --git a/code/_globalvars/configuration.dm b/code/_globalvars/configuration.dm index 052252a0323..e43d803fc4f 100644 --- a/code/_globalvars/configuration.dm +++ b/code/_globalvars/configuration.dm @@ -1,6 +1,7 @@ +// See initialization order in /code/game/world.dm GLOBAL_REAL(config, /datum/controller/configuration) -GLOBAL_DATUM(revdata, /datum/getrev) +GLOBAL_DATUM_INIT(revdata, /datum/getrev, new) GLOBAL_VAR(host) GLOBAL_VAR(station_name) diff --git a/code/_globalvars/lists/objects.dm b/code/_globalvars/lists/objects.dm index 6c9496108a3..3718ebce83a 100644 --- a/code/_globalvars/lists/objects.dm +++ b/code/_globalvars/lists/objects.dm @@ -25,7 +25,7 @@ GLOBAL_LIST_INIT(chemical_name_list, init_chemical_name_list()) GLOBAL_LIST(chemical_reactions_results_lookup_list) //List of all reactions with their associated product and result ids. Used for reaction lookups GLOBAL_LIST(fake_reagent_blacklist) //List of all reagents that are parent types used to define a bunch of children - but aren't used themselves as anything. GLOBAL_LIST_EMPTY(tech_list) //list of all /datum/tech datums indexed by id. -GLOBAL_LIST_EMPTY(surgeries_list) //list of all surgeries by name, associated with their path. +GLOBAL_LIST_INIT(surgeries_list, init_surgeries()) //list of all surgeries by name, associated with their path. /// Global list of all non-cooking related crafting recipes. GLOBAL_LIST_EMPTY(crafting_recipes) diff --git a/code/_globalvars/logging.dm b/code/_globalvars/logging.dm index 1aeafa36e80..9db2490409e 100644 --- a/code/_globalvars/logging.dm +++ b/code/_globalvars/logging.dm @@ -1,55 +1,78 @@ GLOBAL_LIST_EMPTY(active_turfs_startlist) -GLOBAL_LIST_EMPTY(admin_log) -GLOBAL_PROTECT(admin_log) +GLOBAL_VAR(round_id) +GLOBAL_PROTECT(round_id) -GLOBAL_LIST_EMPTY(adminlog) -GLOBAL_PROTECT(adminlog) - -GLOBAL_LIST_EMPTY(bombers) -GLOBAL_PROTECT(bombers) - -GLOBAL_LIST_EMPTY(combatlog) -GLOBAL_PROTECT(combatlog) - -GLOBAL_VAR(config_error_log) -GLOBAL_PROTECT(config_error_log) - -GLOBAL_VAR(demo_log) -GLOBAL_PROTECT(demo_log) - -GLOBAL_VAR(dynamic_log) -GLOBAL_PROTECT(dynamic_log) - -GLOBAL_VAR(filter_log) -GLOBAL_PROTECT(filter_log) - -#ifdef REFERENCE_DOING_IT_LIVE -GLOBAL_LIST_EMPTY(harddel_log) -GLOBAL_PROTECT(harddel_log) -#endif - -GLOBAL_LIST_EMPTY(IClog) -GLOBAL_PROTECT(IClog) - -/// Keeps last 100 signals here in format: "[src] used [REF(src)] @ location [src.loc]: [freq]/[code]" -GLOBAL_LIST_EMPTY(lastsignalers) -GLOBAL_PROTECT(lastsignalers) - -/// Stores who uploaded laws to which silicon-based lifeform, and what the law was -GLOBAL_LIST_EMPTY(lawchanges) -GLOBAL_PROTECT(lawchanges) +/// The directory in which ALL log files should be stored GLOBAL_VAR(log_directory) GLOBAL_PROTECT(log_directory) -GLOBAL_VAR(lua_log) -GLOBAL_PROTECT(lua_log) +#define DECLARE_LOG_NAMED(log_var_name, log_file_name, start)\ +GLOBAL_VAR(##log_var_name);\ +GLOBAL_PROTECT(##log_var_name);\ +/world/_initialize_log_files(temp_log_override = null){\ + ..();\ + GLOB.##log_var_name = temp_log_override || "[GLOB.log_directory]/[##log_file_name].log";\ + if(!temp_log_override && ##start){\ + start_log(GLOB.##log_var_name);\ + }\ +} -GLOBAL_LIST_EMPTY(OOClog) -GLOBAL_PROTECT(OOClog) +#define DECLARE_LOG(log_name, start) DECLARE_LOG_NAMED(##log_name, "[copytext(#log_name, 1, length(#log_name) - 4)]", start) +#define START_LOG TRUE +#define DONT_START_LOG FALSE -GLOBAL_VAR(perf_log) -GLOBAL_PROTECT(perf_log) +/// Populated by log declaration macros to set log file names and start messages +/world/proc/_initialize_log_files(temp_log_override = null) + // Needs to be here to avoid compiler warnings + SHOULD_CALL_PARENT(TRUE) + return + +// All individual log files +DECLARE_LOG(config_error_log, DONT_START_LOG) +DECLARE_LOG(dynamic_log, DONT_START_LOG) +DECLARE_LOG(lua_log, DONT_START_LOG) +DECLARE_LOG(perf_log, DONT_START_LOG) // Declared here but name is set in time_track subsystem +DECLARE_LOG(query_debug_log, DONT_START_LOG) +DECLARE_LOG(signals_log, DONT_START_LOG) +DECLARE_LOG(tgui_log, START_LOG) +#ifdef REFERENCE_DOING_IT_LIVE +DECLARE_LOG_NAMED(harddel_log, "harddels", START_LOG) +#endif +#if defined(UNIT_TESTS) || defined(SPACEMAN_DMM) +DECLARE_LOG_NAMED(test_log, "tests", START_LOG) +#endif +DECLARE_LOG_NAMED(filter_log, "filters", DONT_START_LOG) +DECLARE_LOG_NAMED(sql_error_log, "sql", DONT_START_LOG) +DECLARE_LOG_NAMED(world_asset_log, "asset", DONT_START_LOG) +DECLARE_LOG_NAMED(world_attack_log, "attack", START_LOG) +DECLARE_LOG_NAMED(world_econ_log, "econ", START_LOG) +DECLARE_LOG_NAMED(world_game_log, "game", START_LOG) +DECLARE_LOG_NAMED(world_href_log, "hrefs", START_LOG) +DECLARE_LOG_NAMED(world_job_debug_log, "job_debug", START_LOG) +DECLARE_LOG_NAMED(world_manifest_log, "manifest", START_LOG) +DECLARE_LOG_NAMED(world_map_error_log, "map_errors", DONT_START_LOG) +DECLARE_LOG_NAMED(world_mecha_log, "mecha", DONT_START_LOG) +DECLARE_LOG_NAMED(world_mob_tag_log, "mob_tags", START_LOG) +DECLARE_LOG_NAMED(world_paper_log, "paper", DONT_START_LOG) +DECLARE_LOG_NAMED(world_pda_log, "pda", START_LOG) +DECLARE_LOG_NAMED(world_qdel_log, "qdel", START_LOG) +DECLARE_LOG_NAMED(world_runtime_log, "runtime", START_LOG) +DECLARE_LOG_NAMED(world_shuttle_log, "shuttle", START_LOG) +DECLARE_LOG_NAMED(world_silicon_log, "silicon", DONT_START_LOG) +DECLARE_LOG_NAMED(world_speech_indicators_log, "speech_indicators", DONT_START_LOG) +DECLARE_LOG_NAMED(world_telecomms_log, "telecomms", START_LOG) +DECLARE_LOG_NAMED(world_tool_log, "tools", DONT_START_LOG) +DECLARE_LOG_NAMED(world_uplink_log, "uplink", START_LOG) +DECLARE_LOG_NAMED(world_virus_log, "virus", DONT_START_LOG) +/// Log associated with [/proc/log_suspicious_login()] +/// Intended to hold all logins that failed due to suspicious circumstances such as ban detection, CID randomisation etc. +DECLARE_LOG_NAMED(world_suspicious_login_log, "suspicious_logins", DONT_START_LOG) + +// SKYRAT EDIT ADDITION +DECLARE_LOG_NAMED(event_vote_log, "event_vote", START_LOG) +DECLARE_LOG_NAMED(character_creation_log, "character_creation", START_LOG) +// SKYRAT EDIT END /// Picture logging GLOBAL_VAR(picture_log_directory) @@ -61,88 +84,23 @@ GLOBAL_PROTECT(picture_logging_id) GLOBAL_VAR(picture_logging_prefix) GLOBAL_PROTECT(picture_logging_prefix) -GLOBAL_VAR(query_debug_log) -GLOBAL_PROTECT(query_debug_log) +/// All admin related log lines minus their categories +GLOBAL_LIST_EMPTY(admin_activities) +GLOBAL_PROTECT(admin_activities) -GLOBAL_VAR(round_id) -GLOBAL_PROTECT(round_id) +/// All bomb related messages +GLOBAL_LIST_EMPTY(bombers) +GLOBAL_PROTECT(bombers) -GLOBAL_VAR(signals_log) -GLOBAL_PROTECT(signals_log) +/// All signals here in format: "[src] used [REF(src)] @ location [src.loc]: [freq]/[code]" +GLOBAL_LIST_EMPTY(lastsignalers) +GLOBAL_PROTECT(lastsignalers) -GLOBAL_VAR(sql_error_log) -GLOBAL_PROTECT(sql_error_log) +/// Stores who uploaded laws to which silicon-based lifeform, and what the law was +GLOBAL_LIST_EMPTY(lawchanges) +GLOBAL_PROTECT(lawchanges) -GLOBAL_VAR(tgui_log) -GLOBAL_PROTECT(tgui_log) - -GLOBAL_VAR(world_asset_log) -GLOBAL_PROTECT(world_asset_log) - -GLOBAL_VAR(world_attack_log) -GLOBAL_PROTECT(world_attack_log) - -GLOBAL_VAR(world_cloning_log) -GLOBAL_PROTECT(world_cloning_log) - -GLOBAL_VAR(world_econ_log) -GLOBAL_PROTECT(world_econ_log) - -GLOBAL_VAR(world_game_log) -GLOBAL_PROTECT(world_game_log) - -GLOBAL_VAR(world_href_log) -GLOBAL_PROTECT(world_href_log) - -GLOBAL_VAR(world_job_debug_log) -GLOBAL_PROTECT(world_job_debug_log) - -GLOBAL_VAR(world_manifest_log) -GLOBAL_PROTECT(world_manifest_log) - -GLOBAL_VAR(world_map_error_log) -GLOBAL_PROTECT(world_map_error_log) - -GLOBAL_VAR(world_mecha_log) -GLOBAL_PROTECT(world_mecha_log) - -GLOBAL_VAR(world_mob_tag_log) -GLOBAL_PROTECT(world_mob_tag_log) - -GLOBAL_VAR(world_paper_log) -GLOBAL_PROTECT(world_paper_log) - -GLOBAL_VAR(world_pda_log) -GLOBAL_PROTECT(world_pda_log) - -GLOBAL_VAR(world_qdel_log) -GLOBAL_PROTECT(world_qdel_log) - -GLOBAL_VAR(world_runtime_log) -GLOBAL_PROTECT(world_runtime_log) - -GLOBAL_VAR(world_shuttle_log) -GLOBAL_PROTECT(world_shuttle_log) - -GLOBAL_VAR(world_silicon_log) -GLOBAL_PROTECT(world_silicon_log) - -GLOBAL_VAR(world_speech_indicators_log) -GLOBAL_PROTECT(world_speech_indicators_log) - -/// Log associated with [/proc/log_suspicious_login()] -/// Intended to hold all logins that failed due to suspicious circumstances such as ban detection, CID randomisation etc. -GLOBAL_VAR(world_suspicious_login_log) -GLOBAL_PROTECT(world_suspicious_login_log) - -GLOBAL_VAR(world_telecomms_log) -GLOBAL_PROTECT(world_telecomms_log) - -GLOBAL_VAR(world_tool_log) -GLOBAL_PROTECT(world_tool_log) - -GLOBAL_VAR(world_uplink_log) -GLOBAL_PROTECT(world_uplink_log) - -GLOBAL_VAR(world_virus_log) -GLOBAL_PROTECT(world_virus_log) +#undef DECLARE_LOG +#undef DECLARE_LOG_NAMED +#undef START_LOG +#undef DONT_START_LOG diff --git a/code/controllers/configuration/configuration.dm b/code/controllers/configuration/configuration.dm index 5f9e9c51178..0fc5b2e3fb7 100644 --- a/code/controllers/configuration/configuration.dm +++ b/code/controllers/configuration/configuration.dm @@ -96,6 +96,8 @@ LoadChatFilter() if(CONFIG_GET(flag/load_jobs_from_txt)) validate_job_config() + if(CONFIG_GET(flag/usewhitelist)) + load_whitelist() // SKYRAT EDIT ADDITION START populate_interaction_instances() diff --git a/code/controllers/failsafe.dm b/code/controllers/failsafe.dm index bb95adce1bf..f6d03eb828d 100644 --- a/code/controllers/failsafe.dm +++ b/code/controllers/failsafe.dm @@ -4,6 +4,7 @@ * Pretty much pokes the MC to make sure it's still alive. **/ +// See initialization order in /code/game/world.dm GLOBAL_REAL(Failsafe, /datum/controller/failsafe) /datum/controller/failsafe // This thing pretty much just keeps poking the master controller diff --git a/code/controllers/globals.dm b/code/controllers/globals.dm index 7b5cc94d362..dd9b41aacc3 100644 --- a/code/controllers/globals.dm +++ b/code/controllers/globals.dm @@ -1,3 +1,4 @@ +// See initialization order in /code/game/world.dm GLOBAL_REAL(GLOB, /datum/controller/global_vars) /datum/controller/global_vars @@ -16,8 +17,6 @@ GLOBAL_REAL(GLOB, /datum/controller/global_vars) gvars_datum_in_built_vars = exclude_these.vars + list(NAMEOF(src, gvars_datum_protected_varlist), NAMEOF(src, gvars_datum_in_built_vars), NAMEOF(src, gvars_datum_init_order)) QDEL_IN(exclude_these, 0) //signal logging isn't ready - log_world("[vars.len - gvars_datum_in_built_vars.len] global variables") - Initialize() /datum/controller/global_vars/Destroy(force) @@ -46,9 +45,14 @@ GLOBAL_REAL(GLOB, /datum/controller/global_vars) for(var/I in global_procs) expected_global_procs -= replacetext("[I]", "InitGlobal", "") log_world("Missing procs: [expected_global_procs.Join(", ")]") + for(var/I in global_procs) var/start_tick = world.time call(src, I)() var/end_tick = world.time if(end_tick - start_tick) warning("Global [replacetext("[I]", "InitGlobal", "")] slept during initialization!") + + // Someone make it so this call isn't necessary + make_datum_reference_lists() + diff --git a/code/controllers/master.dm b/code/controllers/master.dm index dfc37bac2b9..3857d79c046 100644 --- a/code/controllers/master.dm +++ b/code/controllers/master.dm @@ -7,19 +7,8 @@ * **/ -//Init the debugger datum first so we can debug Master -//You might wonder why not just create the debugger datum global in its own file, since its loaded way earlier than this DM file -//Well for whatever reason then the Master gets created first and then the debugger when doing that -//So thats why this code lives here now, until someone finds out how Byond inits globals -GLOBAL_REAL(Debugger, /datum/debugger) = new -//This is the ABSOLUTE ONLY THING that should init globally like this -//2019 update: the failsafe,config and Global controllers also do it -GLOBAL_REAL(Master, /datum/controller/master) = new - -//THIS IS THE INIT ORDER -//Master -> SSPreInit -> GLOB -> world -> config -> SSInit -> Failsafe -//GOT IT MEMORIZED? - +// See initialization order in /code/game/world.dm +GLOBAL_REAL(Master, /datum/controller/master) /datum/controller/master name = "Master" @@ -88,7 +77,7 @@ GLOBAL_REAL(Master, /datum/controller/master) = new if(!random_seed) #ifdef UNIT_TESTS - random_seed = 29051994 + random_seed = 29051994 // How about 22475? #else random_seed = rand(1, 1e9) #endif diff --git a/code/controllers/subsystem/dbcore.dm b/code/controllers/subsystem/dbcore.dm index e6cdd06111d..d0728dd5b97 100644 --- a/code/controllers/subsystem/dbcore.dm +++ b/code/controllers/subsystem/dbcore.dm @@ -281,7 +281,9 @@ SUBSYSTEM_DEF(dbcore) else log_sql("Database is not enabled in configuration.") -/datum/controller/subsystem/dbcore/proc/SetRoundID() +/datum/controller/subsystem/dbcore/proc/InitializeRound() + CheckSchemaVersion() + if(!Connect()) return var/datum/db_query/query_round_initialize = SSdbcore.NewQuery(/* SKYRAT EDIT CHANGE - MULTISERVER */ diff --git a/code/controllers/subsystem/profiler.dm b/code/controllers/subsystem/profiler.dm index d3ca080bc25..4b3a1a99711 100644 --- a/code/controllers/subsystem/profiler.dm +++ b/code/controllers/subsystem/profiler.dm @@ -1,7 +1,5 @@ #define PROFILER_FILENAME "profiler.json" #define SENDMAPS_FILENAME "sendmaps.json" -GLOBAL_REAL_VAR(world_init_maptick_profiler) = world.Profile(PROFILE_RESTART, type = "sendmaps") - SUBSYSTEM_DEF(profiler) name = "Profiler" diff --git a/code/datums/profiling.dm b/code/datums/profiling.dm index 1eec8787116..56dd844fb1f 100644 --- a/code/datums/profiling.dm +++ b/code/datums/profiling.dm @@ -1,5 +1,5 @@ //these are real globals so you can use profiling to profile early world init stuff. -GLOBAL_REAL_VAR(list/PROFILE_STORE) +GLOBAL_REAL(PROFILE_STORE, /list) GLOBAL_REAL_VAR(PROFILE_LINE) GLOBAL_REAL_VAR(PROFILE_FILE) GLOBAL_REAL_VAR(PROFILE_SLEEPCHECK) diff --git a/code/game/world.dm b/code/game/world.dm index fbef0353b08..46b20890fe5 100644 --- a/code/game/world.dm +++ b/code/game/world.dm @@ -7,6 +7,78 @@ GLOBAL_VAR(restart_counter) +/** + * WORLD INITIALIZATION + * THIS IS THE INIT ORDER: + * + * BYOND => + * - (secret init native) => + * - world.Genesis() => + * - world.init_byond_tracy() + * - (Start native profiling) + * - world.init_debugger() + * - Master => + * - config *unloaded + * - (all subsystems) PreInit() + * - GLOB => + * - make_datum_reference_lists() + * - (/static variable inits, reverse declaration order) + * - (all pre-mapped atoms) /atom/New() + * - world.New() => + * - config.Load() + * - world.InitTgs() => + * - TgsNew() *may sleep + * - GLOB.rev_data.load_tgs_info() + * - world.ConfigLoaded() => + * - SSdbcore.InitializeRound() + * - world.SetupLogs() + * - load_admins() + * - ... + * - Master.Initialize() => + * - (all subsystems) Initialize() + * - Master.StartProcessing() => + * - Master.Loop() => + * - Failsafe + * - world.RunUnattendedFunctions() + * + * Now listen up because I want to make something clear: + * If something is not in this list it should almost definitely be handled by a subsystem Initialize()ing + * If whatever it is that needs doing doesn't fit in a subsystem you probably aren't trying hard enough tbhfam + * + * GOT IT MEMORIZED? + * - Dominion/Cyberboss + */ + +/** + * THIS !!!SINGLE!!! PROC IS WHERE ANY FORM OF INIITIALIZATION THAT CAN'T BE PERFORMED IN MASTER/NEW() IS DONE + * NOWHERE THE FUCK ELSE + * I DON'T CARE HOW MANY LAYERS OF DEBUG/PROFILE/TRACE WE HAVE, YOU JUST HAVE TO DEAL WITH THIS PROC EXISTING + * I'M NOT EVEN GOING TO TELL YOU WHERE IT'S CALLED FROM BECAUSE I'M DECLARING THAT FORBIDDEN KNOWLEDGE + * SO HELP ME GOD IF I FIND ABSTRACTION LAYERS OVER THIS! + */ +/world/proc/Genesis(tracy_initialized = FALSE) + RETURN_TYPE(/datum/controller/master) + +#ifdef USE_BYOND_TRACY +#warn USE_BYOND_TRACY is enabled + if(!tracy_initialized) + init_byond_tracy() + Genesis(tracy_initialized = TRUE) + return +#endif + + Profile(PROFILE_RESTART) + Profile(PROFILE_RESTART, type = "sendmaps") + + // Write everything to this log file until we get to SetupLogs() later + _initialize_log_files("data/logs/config_error.[GUID()].log") + + // Init the debugger first so we can debug Master + init_debugger() + + // THAT'S IT, WE'RE DONE, THE. FUCKING. END. + Master = new + /** * World creation * @@ -34,57 +106,55 @@ GLOBAL_VAR(restart_counter) * All atoms in both compiled and uncompiled maps are initialized() */ /world/New() -#ifdef USE_BYOND_TRACY - #warn USE_BYOND_TRACY is enabled - init_byond_tracy() -#endif - log_world("World loaded at [time_stamp()]!") - make_datum_references_lists() //initialises global lists for referencing frequently used datums (so that we only ever do it once) - - GLOB.config_error_log = GLOB.world_manifest_log = GLOB.world_pda_log = GLOB.world_job_debug_log = GLOB.sql_error_log = GLOB.world_href_log = GLOB.world_runtime_log = GLOB.world_attack_log = GLOB.world_game_log = GLOB.world_econ_log = GLOB.world_shuttle_log = "data/logs/config_error.[GUID()].log" //temporary file used to record errors with loading config, moved to log directory once logging is set bl - #ifdef REFERENCE_DOING_IT_LIVE - GLOB.harddel_log = GLOB.world_game_log - #endif - - GLOB.revdata = new + // From a really fucking old commit (91d7150) + // I wanted to move it but I think this needs to be after /world/New is called but before any sleeps? + // - Dominion/Cyberboss + GLOB.timezoneOffset = text2num(time2text(0,"hh")) * 36000 + // First possible sleep() InitTgs() config.Load(params[OVERRIDE_CONFIG_DIRECTORY_PARAMETER]) - load_admins() - - //SetupLogs depends on the RoundID, so lets check - //DB schema and set RoundID if we can - SSdbcore.CheckSchemaVersion() - SSdbcore.SetRoundID() - SetupLogs() - load_poll_data() - -#ifndef USE_CUSTOM_ERROR_HANDLER - world.log = file("[GLOB.log_directory]/dd.log") -#else - if (TgsAvailable()) - world.log = file("[GLOB.log_directory]/dd.log") //not all runtimes trigger world/Error, so this is the only way to ensure we can see all of them. -#endif - - LoadVerbs(/datum/verbs/menu) - if(CONFIG_GET(flag/usewhitelist)) - load_whitelist() - - GLOB.timezoneOffset = text2num(time2text(0,"hh")) * 36000 - - if(fexists(RESTART_COUNTER_PATH)) - GLOB.restart_counter = text2num(trim(file2text(RESTART_COUNTER_PATH))) - fdel(RESTART_COUNTER_PATH) + ConfigLoaded() if(NO_INIT_PARAMETER in params) return Master.Initialize(10, FALSE, TRUE) + RunUnattendedFunctions() + +/// Initializes TGS and loads the returned revising info into GLOB.revdata +/world/proc/InitTgs() + TgsNew(new /datum/tgs_event_handler/impl, TGS_SECURITY_TRUSTED) + GLOB.revdata.load_tgs_info() + +/// Runs after config is loaded but before Master is initialized +/world/proc/ConfigLoaded() + // Everything in here is prioritized in a very specific way. + // If you need to add to it, ask yourself hard if what your adding is in the right spot + // (i.e. basically nothing should be added before load_admins() in here) + + // Try to set round ID + SSdbcore.InitializeRound() + + SetupLogs() + + load_admins() + + load_poll_data() + + LoadVerbs(/datum/verbs/menu) + + if(fexists(RESTART_COUNTER_PATH)) + GLOB.restart_counter = text2num(trim(file2text(RESTART_COUNTER_PATH))) + fdel(RESTART_COUNTER_PATH) + +/// Runs after the call to Master.Initialize, but before the delay kicks in. Used to turn the world execution into some single function then exit +/world/proc/RunUnattendedFunctions() #ifdef UNIT_TESTS HandleTestRun() #endif @@ -93,10 +163,6 @@ GLOBAL_VAR(restart_counter) setup_autowiki() #endif -/world/proc/InitTgs() - TgsNew(new /datum/tgs_event_handler/impl, TGS_SECURITY_TRUSTED) - GLOB.revdata.load_tgs_info() - /world/proc/HandleTestRun() //trigger things to run the whole process Master.sleep_offline_after_initializations = FALSE @@ -134,75 +200,9 @@ GLOBAL_VAR(restart_counter) GLOB.picture_log_directory = "data/picture_logs/[override_dir]" GLOB.logger.init_logging() - GLOB.demo_log = "[GLOB.log_directory]/demo.log" - GLOB.dynamic_log = "[GLOB.log_directory]/dynamic.log" - GLOB.filter_log = "[GLOB.log_directory]/filters.log" - GLOB.lua_log = "[GLOB.log_directory]/lua.log" - GLOB.query_debug_log = "[GLOB.log_directory]/query_debug.log" - GLOB.signals_log = "[GLOB.log_directory]/signals.log" - GLOB.sql_error_log = "[GLOB.log_directory]/sql.log" - GLOB.tgui_log = "[GLOB.log_directory]/tgui.log" - GLOB.world_asset_log = "[GLOB.log_directory]/asset.log" - GLOB.world_attack_log = "[GLOB.log_directory]/attack.log" - GLOB.world_cloning_log = "[GLOB.log_directory]/cloning.log" - GLOB.world_econ_log = "[GLOB.log_directory]/econ.log" - GLOB.world_game_log = "[GLOB.log_directory]/game.log" - GLOB.world_href_log = "[GLOB.log_directory]/hrefs.log" - GLOB.world_job_debug_log = "[GLOB.log_directory]/job_debug.log" - GLOB.world_manifest_log = "[GLOB.log_directory]/manifest.log" - GLOB.world_map_error_log = "[GLOB.log_directory]/map_errors.log" - GLOB.world_mecha_log = "[GLOB.log_directory]/mecha.log" - GLOB.world_mob_tag_log = "[GLOB.log_directory]/mob_tags.log" - GLOB.world_qdel_log = "[GLOB.log_directory]/qdel.log" - GLOB.world_paper_log = "[GLOB.log_directory]/paper.log" - GLOB.world_pda_log = "[GLOB.log_directory]/pda.log" - GLOB.world_runtime_log = "[GLOB.log_directory]/runtime.log" - GLOB.world_shuttle_log = "[GLOB.log_directory]/shuttle.log" - GLOB.world_silicon_log = "[GLOB.log_directory]/silicon.log" - GLOB.world_speech_indicators_log = "[GLOB.log_directory]/speech_indicators.log" - GLOB.world_suspicious_login_log = "[GLOB.log_directory]/suspicious_logins.log" - GLOB.world_telecomms_log = "[GLOB.log_directory]/telecomms.log" - GLOB.world_tool_log = "[GLOB.log_directory]/tools.log" - GLOB.world_uplink_log = "[GLOB.log_directory]/uplink.log" - GLOB.world_virus_log = "[GLOB.log_directory]/virus.log" - - GLOB.character_creation_log = "[GLOB.log_directory]/creator.log" // SKYRAT EDIT ADDITION - GLOB.event_vote_log = "[GLOB.log_directory]/event_vote.log" // SKYRAT EDIT ADDITION - -#ifdef UNIT_TESTS - GLOB.test_log = "[GLOB.log_directory]/tests.log" - start_log(GLOB.test_log) -#endif - -#ifdef REFERENCE_DOING_IT_LIVE - GLOB.harddel_log = "[GLOB.log_directory]/harddels.log" - start_log(GLOB.harddel_log) -#endif - start_log(GLOB.tgui_log) - start_log(GLOB.world_attack_log) - start_log(GLOB.world_econ_log) - start_log(GLOB.world_game_log) - start_log(GLOB.world_href_log) - start_log(GLOB.world_job_debug_log) - start_log(GLOB.world_manifest_log) - start_log(GLOB.world_mob_tag_log) - start_log(GLOB.world_qdel_log) - start_log(GLOB.world_runtime_log) - start_log(GLOB.world_shuttle_log) - start_log(GLOB.world_telecomms_log) - start_log(GLOB.world_uplink_log) - start_log(GLOB.world_pda_log) - - // SKYRAT EDIT ADDITION - start_log(GLOB.event_vote_log) - start_log(GLOB.character_creation_log) - // SKYRAT EDIT END var/latest_changelog = file("[global.config.directory]/../html/changelogs/archive/" + time2text(world.timeofday, "YYYY-MM") + ".yml") GLOB.changelog_hash = fexists(latest_changelog) ? md5(latest_changelog) : 0 //for telling if the changelog has changed recently - if(fexists(GLOB.config_error_log)) - fcopy(GLOB.config_error_log, "[GLOB.log_directory]/config_error.log") - fdel(GLOB.config_error_log) if(GLOB.round_id) log_game("Round ID: [GLOB.round_id]") @@ -212,6 +212,13 @@ GLOBAL_VAR(restart_counter) // log which is ultimately public. log_runtime(GLOB.revdata.get_log_message()) +#ifndef USE_CUSTOM_ERROR_HANDLER + world.log = file("[GLOB.log_directory]/dd.log") +#else + if (TgsAvailable()) // why + world.log = file("[GLOB.log_directory]/dd.log") //not all runtimes trigger world/Error, so this is the only way to ensure we can see all of them. +#endif + /world/Topic(T, addr, master, key) TGS_TOPIC //redirect to server tools if necessary @@ -324,8 +331,7 @@ GLOBAL_VAR(restart_counter) auxcleanup() . = ..() -/* SKYRAT EDIT CHANGE - MOVED TO MODULAR - +/* SKYRAT EDIT REMOVAL - OVERRIDEN /world/proc/update_status() var/list/features = list() @@ -443,10 +449,15 @@ GLOBAL_VAR(restart_counter) else CRASH("Unsupported platform: [system_type]") - var/init_result = LIBCALL(library, "init")() + var/init_result = LIBCALL(library, "init")("block") if (init_result != "0") CRASH("Error initializing byond-tracy: [init_result]") +/world/proc/init_debugger() + var/dll = GetConfig("env", "AUXTOOLS_DEBUG_DLL") + if (dll) + LIBCALL(dll, "auxtools_init")() + enable_debugging() /world/Profile(command, type, format) if((command & PROFILE_STOP) || !global.config?.loaded || !CONFIG_GET(flag/forbid_all_profiling)) diff --git a/code/modules/admin/verbs/secrets.dm b/code/modules/admin/verbs/secrets.dm index 60eaa79ad5f..5dd4989dd8f 100644 --- a/code/modules/admin/verbs/secrets.dm +++ b/code/modules/admin/verbs/secrets.dm @@ -55,9 +55,9 @@ GLOBAL_DATUM(everyone_a_traitor, /datum/everyone_is_a_traitor_controller) //Generic Buttons anyone can use. if("admin_log") var/dat = "Admin Log
" - for(var/l in GLOB.admin_log) + for(var/l in GLOB.admin_activities) dat += "
  • [l]
  • " - if(!GLOB.admin_log.len) + if(!GLOB.admin_activities.len) dat += "No-one has done anything this round!" holder << browse(dat, "window=admin_log") if("show_admins") diff --git a/code/modules/error_handler/error_handler.dm b/code/modules/error_handler/error_handler.dm index 32a683e7bc7..1b3f6bca16d 100644 --- a/code/modules/error_handler/error_handler.dm +++ b/code/modules/error_handler/error_handler.dm @@ -26,12 +26,6 @@ GLOBAL_VAR_INIT(total_runtimes_skipped, 0) Reboot(reason = 1) return - if (islist(stack_trace_storage)) - for (var/line in splittext(E.desc, "\n")) - if (text2ascii(line) != 32) - stack_trace_storage += line - return - var/static/list/error_last_seen = list() var/static/list/error_cooldown = list() /* Error_cooldown items will either be positive(cooldown time) or negative(silenced error) If negative, starts at -1, and goes down by 1 each time that error gets skipped*/ diff --git a/code/modules/logging/log_holder.dm b/code/modules/logging/log_holder.dm index c2357ad2cfa..0ab25ccb218 100644 --- a/code/modules/logging/log_holder.dm +++ b/code/modules/logging/log_holder.dm @@ -49,6 +49,12 @@ GLOBAL_PROTECT(logger) ) rustg_file_write("[json_encode(log_start_entry)]\n", category_type.get_output_file(null)) + if(fexists(GLOB.config_error_log)) + fcopy(GLOB.config_error_log, "[GLOB.log_directory]/config_error.log") + fdel(GLOB.config_error_log) + + world._initialize_log_files() + /// Tells the log_holder to not allow any more logging to be done, and dumps all categories to their json file /datum/log_holder/proc/shutdown_logging() if(shutdown) diff --git a/code/modules/unit_tests/unit_test.dm b/code/modules/unit_tests/unit_test.dm index efd1290d00d..c5fa8618b4c 100644 --- a/code/modules/unit_tests/unit_test.dm +++ b/code/modules/unit_tests/unit_test.dm @@ -13,7 +13,6 @@ You can use the run_loc_floor_bottom_left and run_loc_floor_top_right to get tur GLOBAL_DATUM(current_test, /datum/unit_test) GLOBAL_VAR_INIT(failed_any_test, FALSE) -GLOBAL_VAR(test_log) /// When unit testing, all logs sent to log_mapping are stored here and retrieved in log_mapping unit test. GLOBAL_LIST_EMPTY(unit_test_mapping_logs) diff --git a/code/world.dm b/code/world.dm index 9534fa987c5..6bacb01b22b 100644 --- a/code/world.dm +++ b/code/world.dm @@ -1,5 +1,5 @@ //This file is just for the necessary /world definition -//Try looking in game/world.dm +//Try looking in /code/game/world.dm, where initialization order is defined /** * # World @@ -7,8 +7,6 @@ * Two possibilities exist: either we are alone in the Universe or we are not. Both are equally terrifying. ~ Arthur C. Clarke * * The byond world object stores some basic byond level config, and has a few hub specific procs for managing hub visiblity - * - * The world /New() is the root of where a round itself begins */ /world mob = /mob/dead/new_player diff --git a/code/ze_genesis_call/genesis_call.dm b/code/ze_genesis_call/genesis_call.dm new file mode 100644 index 00000000000..f1fbed382d4 --- /dev/null +++ b/code/ze_genesis_call/genesis_call.dm @@ -0,0 +1,52 @@ +/* + + You look around. + + There is nothing but naught about you. + + You've come to the end of the world. + + You get a feeling that you really shouldn't be here. + + Ever. + + But with all ends come beginnings. + + As you turn to leave, you spot it out of the corner of your eye. + + Your eye widen in wonder as you look upon the the legendary treasure. + + After all these years of pouring through shitcode + your endevours have brought you to... + +*/ + +/** + * THE GENESIS CALL + * + * THE VERY FIRST LINE OF DM CODE TO EXECUTE + * Ong this must be done after !!!EVERYTHING!!! else + * NO IFS ANDS OR BUTS + * it's a hack, not an example of any sort, and DEFINITELY should NOT be emulated + * IT JUST HAS TO BE LAST!!!!!! + * If you want to do something in the initialization pipeline + * FIRST RTFM IN /code/game/world.dm + * AND THEN NEVER RETURN TO THIS PLACE + * + * + * + * If you're still here, here's an explanation: + * BYOND loves to tell you about its loving spouse /global + * But it's actually having a sexy an affair with /static + * Specifically statics in procs + * Priority is given to these lines of code in REVERSE order of declaration in the .dme + * Which is why this file has a funky name + * So this is what we use to call world.Genesis() + * It's a nameless, no-op function, because it does absolutely nothing + * It exists to hold a static var which is initialized to null + * It's on /world to hide it from reflection + * Painful right? Good, now you share my suffering + * Please lock the door on your way out + */ +/world/proc/_() + var/static/_ = world.Genesis() diff --git a/tgstation.dme b/tgstation.dme index e7ee9c88a2a..4d7aa3df402 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -16,7 +16,6 @@ #include "_maps\_basemap.dm" #include "code\__byond_version_compat.dm" #include "code\_compile_options.dm" -#include "code\_debugger.dm" #include "code\_experiments.dm" #include "code\world.dm" #include "code\__DEFINES\_atoms.dm" @@ -24,7 +23,6 @@ #include "code\__DEFINES\_click.dm" #include "code\__DEFINES\_globals.dm" #include "code\__DEFINES\_helpers.dm" -#include "code\__DEFINES\_profile.dm" #include "code\__DEFINES\_protect.dm" #include "code\__DEFINES\_tick.dm" #include "code\__DEFINES\access.dm" @@ -3788,6 +3786,7 @@ #include "code\modules\lighting\static_lighting_area.dm" #include "code\modules\logging\log_category.dm" #include "code\modules\logging\log_holder.dm" +#include "code\modules\logging\categories\log_category_silo.dm" #include "code\modules\logging\categories\log_category_target_zone_switch.dm" #include "code\modules\mafia\_defines.dm" #include "code\modules\mafia\controller.dm" @@ -5323,6 +5322,7 @@ #include "code\modules\wiremod\shell\shell_items.dm" #include "code\modules\zombie\items.dm" #include "code\modules\zombie\organs.dm" +#include "code\ze_genesis_call\genesis_call.dm" #include "interface\fonts.dm" #include "interface\interface.dm" #include "interface\menu.dm"