From 0a0324514b4d902b7944c643ec5d8950a117d14a Mon Sep 17 00:00:00 2001 From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com> Date: Tue, 29 Dec 2020 15:43:28 +0000 Subject: [PATCH] Changes some world init order stuff around (#15186) * Changes some world init order stuff around * More stuff --- code/game/world.dm | 10 ++++++++-- code/modules/admin/admin_ranks.dm | 4 ++-- code/modules/admin/banjob.dm | 4 ++-- code/modules/admin/verbs/diagnostics.dm | 2 +- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/code/game/world.dm b/code/game/world.dm index d92ebe364f9..ca336eb5dc3 100644 --- a/code/game/world.dm +++ b/code/game/world.dm @@ -1,6 +1,10 @@ GLOBAL_LIST_INIT(map_transition_config, MAP_TRANSITION_CONFIG) /world/New() + // IMPORTANT + // If you do any SQL operations inside this proc, they must ***NOT*** be ran async. Otherwise players can join mid query + // This is BAD. + //temporary file used to record errors with loading config and the database, moved to log directory once logging is set up GLOB.config_error_log = GLOB.world_game_log = GLOB.world_runtime_log = GLOB.sql_log = "data/logs/config_error.log" load_configuration() @@ -13,11 +17,14 @@ GLOBAL_LIST_INIT(map_transition_config, MAP_TRANSITION_CONFIG) // Setup all log paths and stamp them with startups, including round IDs SetupLogs() + // This needs to happen early, otherwise people can get a null species, nuking their character + makeDatumRefLists() + TgsNew(new /datum/tgs_event_handler/impl, TGS_SECURITY_TRUSTED) // creates a new TGS object log_world("World loaded at [time_stamp()]") log_world("[GLOB.vars.len - GLOB.gvars_datum_in_built_vars.len] global variables") GLOB.revision_info.log_info() - load_admins() // Same here + load_admins(run_async=FALSE) // This better happen early on. #ifdef UNIT_TESTS log_world("Unit Tests Are Enabled!") @@ -58,7 +65,6 @@ GLOBAL_LIST_INIT(map_transition_config, MAP_TRANSITION_CONFIG) load_motd() // Loads up the MOTD (Welcome message players see when joining the server) load_mode() // Loads up the gamemode investigate_reset() // This is part of the admin investigate system. PLEASE DONT SS THIS EITHER - makeDatumRefLists() // Setups up lists of datums and their subtypes /// List of all world topic spam prevention handlers. See code/modules/world_topic/_spam_prevention_handler.dm GLOBAL_LIST_EMPTY(world_topic_spam_prevention_handlers) diff --git a/code/modules/admin/admin_ranks.dm b/code/modules/admin/admin_ranks.dm index 6e91e70c3c9..f913d9d98ef 100644 --- a/code/modules/admin/admin_ranks.dm +++ b/code/modules/admin/admin_ranks.dm @@ -56,7 +56,7 @@ GLOBAL_PROTECT(admin_ranks) // this shit is being protected for obvious reasons testing(msg) #endif -/proc/load_admins() +/proc/load_admins(run_async = FALSE) if(IsAdminAdvancedProcCall()) to_chat(usr, "Admin reload blocked: Advanced ProcCall detected.") message_admins("[key_name(usr)] attempted to reload admins via advanced proc-call") @@ -118,7 +118,7 @@ GLOBAL_PROTECT(admin_ranks) // this shit is being protected for obvious reasons return var/datum/db_query/query = SSdbcore.NewQuery("SELECT ckey, rank, level, flags FROM [format_table_name("admin")]") - if(!query.warn_execute()) + if(!query.warn_execute(async=run_async)) qdel(query) return diff --git a/code/modules/admin/banjob.dm b/code/modules/admin/banjob.dm index c7a9332f569..22d2a825ac6 100644 --- a/code/modules/admin/banjob.dm +++ b/code/modules/admin/banjob.dm @@ -68,7 +68,7 @@ GLOBAL_DATUM_INIT(jobban_regex, /regex, regex("(\[\\S]+) - (\[^#]+\[^# ])(?: ## //Job permabans var/datum/db_query/permabans = SSdbcore.NewQuery("SELECT ckey, job FROM [format_table_name("ban")] WHERE bantype = 'JOB_PERMABAN' AND isnull(unbanned)") - if(!permabans.warn_execute()) + if(!permabans.warn_execute(async=FALSE)) qdel(permabans) return FALSE @@ -83,7 +83,7 @@ GLOBAL_DATUM_INIT(jobban_regex, /regex, regex("(\[\\S]+) - (\[^#]+\[^# ])(?: ## // Job tempbans var/datum/db_query/tempbans = SSdbcore.NewQuery("SELECT ckey, job FROM [format_table_name("ban")] WHERE bantype = 'JOB_TEMPBAN' AND isnull(unbanned) AND expiration_time > Now()") - if(!tempbans.warn_execute()) + if(!tempbans.warn_execute(async=FALSE)) qdel(tempbans) return FALSE diff --git a/code/modules/admin/verbs/diagnostics.dm b/code/modules/admin/verbs/diagnostics.dm index b847c2fcc5a..f57d2871b02 100644 --- a/code/modules/admin/verbs/diagnostics.dm +++ b/code/modules/admin/verbs/diagnostics.dm @@ -116,7 +116,7 @@ message_admins("[key_name_admin(usr)] has manually reloaded admins") log_admin("[key_name(usr)] has manually reloaded admins") - load_admins() + load_admins(run_async=TRUE) SSblackbox.record_feedback("tally", "admin_verb", 1, "Reload Admins") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!