From a834a92ed67725fc83ce804e5f187df5d0485827 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sun, 30 Mar 2025 16:44:23 -0400 Subject: [PATCH] Add an event to config reloading that can be used to trigger a config sync (#90329) --- code/controllers/configuration/configuration.dm | 16 +++++++++++++++- code/game/world.dm | 2 +- code/modules/admin/admin_ranks.dm | 6 +++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/code/controllers/configuration/configuration.dm b/code/controllers/configuration/configuration.dm index 7afefeaa628..84938b7b083 100644 --- a/code/controllers/configuration/configuration.dm +++ b/code/controllers/configuration/configuration.dm @@ -24,6 +24,9 @@ /// If the configuration is loaded var/loaded = FALSE + /// If a reload is in progress + var/reload_in_progress = FALSE + /// A regex that matches words blocked IC var/static/regex/ic_filter_regex @@ -64,13 +67,24 @@ var/static/list/configuration_errors /datum/controller/configuration/proc/admin_reload() - if(IsAdminAdvancedProcCall()) + if(IsAdminAdvancedProcCall() || !PreConfigReload()) return + log_admin("[key_name_admin(usr)] has forcefully reloaded the configuration from disk.") message_admins("[key_name_admin(usr)] has forcefully reloaded the configuration from disk.") full_wipe() Load(world.params[OVERRIDE_CONFIG_DIRECTORY_PARAMETER]) +/datum/controller/configuration/proc/PreConfigReload() + if(reload_in_progress) + to_chat(usr, span_warning("Another user is already reloading the config!")) + return FALSE + + reload_in_progress = TRUE + world.TgsTriggerEvent("tg-PreConfigReload", wait_for_completion = TRUE) + reload_in_progress = FALSE + return TRUE + /datum/controller/configuration/proc/Load(_directory) if(IsAdminAdvancedProcCall()) //If admin proccall is detected down the line it will horribly break everything. return diff --git a/code/game/world.dm b/code/game/world.dm index 0633e197acc..9a5d25ab2a2 100644 --- a/code/game/world.dm +++ b/code/game/world.dm @@ -177,7 +177,7 @@ GLOBAL_PROTECT(tracy_init_reason) SetupLogs() - load_admins() + load_admins(initial = TRUE) load_poll_data() diff --git a/code/modules/admin/admin_ranks.dm b/code/modules/admin/admin_ranks.dm index 3b959d449cd..19810f5ab8f 100644 --- a/code/modules/admin/admin_ranks.dm +++ b/code/modules/admin/admin_ranks.dm @@ -211,7 +211,11 @@ GLOBAL_PROTECT(protected_ranks) /// (Re)Loads the admin list. /// returns TRUE if database admins had to be loaded from the backup json -/proc/load_admins(no_update) +/proc/load_admins(no_update, initial = FALSE) + if(!initial) + if(!global.config.PreConfigReload()) + return + var/dbfail if(!CONFIG_GET(flag/admin_legacy_system) && !SSdbcore.Connect()) message_admins("Failed to connect to database while loading admins. Loading from backup.")