mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-15 12:11:45 +00:00
add a stack_trace to config validation checking (#73160)
## About The Pull Request config validation didn't actually throw on invalid configs, thus CI never caught breaking changes ## Why It's Good For The Game config should work
This commit is contained in:
@@ -60,6 +60,9 @@
|
|||||||
/// An assoc list of words that are soft blocked both IC and OOC to their reasons
|
/// An assoc list of words that are soft blocked both IC and OOC to their reasons
|
||||||
var/static/list/soft_shared_filter_reasons
|
var/static/list/soft_shared_filter_reasons
|
||||||
|
|
||||||
|
/// A list of configuration errors that occurred during load
|
||||||
|
var/static/list/configuration_errors
|
||||||
|
|
||||||
/datum/controller/configuration/proc/admin_reload()
|
/datum/controller/configuration/proc/admin_reload()
|
||||||
if(IsAdminAdvancedProcCall())
|
if(IsAdminAdvancedProcCall())
|
||||||
return
|
return
|
||||||
@@ -75,6 +78,7 @@
|
|||||||
directory = _directory
|
directory = _directory
|
||||||
if(entries)
|
if(entries)
|
||||||
CRASH("/datum/controller/configuration/Load() called more than once!")
|
CRASH("/datum/controller/configuration/Load() called more than once!")
|
||||||
|
configuration_errors ||= list()
|
||||||
InitEntries()
|
InitEntries()
|
||||||
if(fexists("[directory]/config.txt") && LoadEntries("config.txt") <= 1)
|
if(fexists("[directory]/config.txt") && LoadEntries("config.txt") <= 1)
|
||||||
var/list/legacy_configs = list("game_options.txt", "dbconfig.txt", "comms.txt")
|
var/list/legacy_configs = list("game_options.txt", "dbconfig.txt", "comms.txt")
|
||||||
@@ -97,6 +101,7 @@
|
|||||||
|
|
||||||
if (Master)
|
if (Master)
|
||||||
Master.OnConfigLoad()
|
Master.OnConfigLoad()
|
||||||
|
process_config_errors()
|
||||||
|
|
||||||
/datum/controller/configuration/proc/full_wipe()
|
/datum/controller/configuration/proc/full_wipe()
|
||||||
if(IsAdminAdvancedProcCall())
|
if(IsAdminAdvancedProcCall())
|
||||||
@@ -107,6 +112,7 @@
|
|||||||
QDEL_LIST_ASSOC_VAL(maplist)
|
QDEL_LIST_ASSOC_VAL(maplist)
|
||||||
maplist = null
|
maplist = null
|
||||||
QDEL_NULL(defaultmap)
|
QDEL_NULL(defaultmap)
|
||||||
|
configuration_errors?.Cut()
|
||||||
|
|
||||||
/datum/controller/configuration/Destroy()
|
/datum/controller/configuration/Destroy()
|
||||||
full_wipe()
|
full_wipe()
|
||||||
@@ -114,6 +120,16 @@
|
|||||||
|
|
||||||
return ..()
|
return ..()
|
||||||
|
|
||||||
|
/datum/controller/configuration/proc/log_config_error(error_message)
|
||||||
|
configuration_errors += error_message
|
||||||
|
log_config(error_message)
|
||||||
|
|
||||||
|
/datum/controller/configuration/proc/process_config_errors()
|
||||||
|
if(!CONFIG_GET(flag/config_errors_runtime))
|
||||||
|
return
|
||||||
|
for(var/error_message in configuration_errors)
|
||||||
|
stack_trace(error_message)
|
||||||
|
|
||||||
/datum/controller/configuration/proc/InitEntries()
|
/datum/controller/configuration/proc/InitEntries()
|
||||||
var/list/_entries = list()
|
var/list/_entries = list()
|
||||||
entries = _entries
|
entries = _entries
|
||||||
@@ -128,7 +144,7 @@
|
|||||||
var/esname = E.name
|
var/esname = E.name
|
||||||
var/datum/config_entry/test = _entries[esname]
|
var/datum/config_entry/test = _entries[esname]
|
||||||
if(test)
|
if(test)
|
||||||
log_config("Error: [test.type] has the same name as [E.type]: [esname]! Not initializing [E.type]!")
|
log_config_error("Error: [test.type] has the same name as [E.type]: [esname]! Not initializing [E.type]!")
|
||||||
qdel(E)
|
qdel(E)
|
||||||
continue
|
continue
|
||||||
_entries[esname] = E
|
_entries[esname] = E
|
||||||
@@ -144,7 +160,7 @@
|
|||||||
|
|
||||||
var/filename_to_test = world.system_type == MS_WINDOWS ? lowertext(filename) : filename
|
var/filename_to_test = world.system_type == MS_WINDOWS ? lowertext(filename) : filename
|
||||||
if(filename_to_test in stack)
|
if(filename_to_test in stack)
|
||||||
log_config("Warning: Config recursion detected ([english_list(stack)]), breaking!")
|
log_config_error("Warning: Config recursion detected ([english_list(stack)]), breaking!")
|
||||||
return
|
return
|
||||||
stack = stack + filename_to_test
|
stack = stack + filename_to_test
|
||||||
|
|
||||||
@@ -179,7 +195,7 @@
|
|||||||
|
|
||||||
if(entry == "$include")
|
if(entry == "$include")
|
||||||
if(!value)
|
if(!value)
|
||||||
log_config("Warning: Invalid $include directive: [value]")
|
log_config_error("Warning: Invalid $include directive: [value]")
|
||||||
else
|
else
|
||||||
LoadEntries(value, stack)
|
LoadEntries(value, stack)
|
||||||
++.
|
++.
|
||||||
@@ -189,7 +205,7 @@
|
|||||||
if (entry == "$reset")
|
if (entry == "$reset")
|
||||||
var/datum/config_entry/resetee = _entries[lowertext(value)]
|
var/datum/config_entry/resetee = _entries[lowertext(value)]
|
||||||
if (!value || !resetee)
|
if (!value || !resetee)
|
||||||
log_config("Warning: invalid $reset directive: [value]")
|
log_config_error("Warning: invalid $reset directive: [value]")
|
||||||
continue
|
continue
|
||||||
resetee.set_default()
|
resetee.set_default()
|
||||||
log_config("Reset configured value for [value] to original defaults")
|
log_config("Reset configured value for [value] to original defaults")
|
||||||
@@ -219,10 +235,12 @@
|
|||||||
|
|
||||||
var/validated = E.ValidateAndSet(value)
|
var/validated = E.ValidateAndSet(value)
|
||||||
if(!validated)
|
if(!validated)
|
||||||
log_config("Failed to validate setting \"[value]\" for [entry]")
|
var/log_message = "Failed to validate setting \"[value]\" for [entry]"
|
||||||
|
log_config(log_message)
|
||||||
|
stack_trace(log_message)
|
||||||
else
|
else
|
||||||
if(E.modified && !E.dupes_allowed)
|
if(E.modified && !E.dupes_allowed)
|
||||||
log_config("Duplicate setting for [entry] ([value], [E.resident_file]) detected! Using latest.")
|
log_config_error("Duplicate setting for [entry] ([value], [E.resident_file]) detected! Using latest.")
|
||||||
|
|
||||||
E.resident_file = filename
|
E.resident_file = filename
|
||||||
|
|
||||||
|
|||||||
@@ -525,7 +525,7 @@
|
|||||||
/datum/config_entry/string/chat_announce_new_game
|
/datum/config_entry/string/chat_announce_new_game
|
||||||
deprecated_by = /datum/config_entry/string/channel_announce_new_game
|
deprecated_by = /datum/config_entry/string/channel_announce_new_game
|
||||||
|
|
||||||
/datum/config_entry/flag/chat_announce_new_game/DeprecationUpdate(value)
|
/datum/config_entry/string/chat_announce_new_game/DeprecationUpdate(value)
|
||||||
return "" //default broadcast
|
return "" //default broadcast
|
||||||
|
|
||||||
/datum/config_entry/string/channel_announce_new_game
|
/datum/config_entry/string/channel_announce_new_game
|
||||||
@@ -659,3 +659,6 @@
|
|||||||
/datum/config_entry/string/morgue_cadaver_override_species
|
/datum/config_entry/string/morgue_cadaver_override_species
|
||||||
|
|
||||||
/datum/config_entry/flag/toast_notification_on_init
|
/datum/config_entry/flag/toast_notification_on_init
|
||||||
|
|
||||||
|
/datum/config_entry/flag/config_errors_runtime
|
||||||
|
default = FALSE
|
||||||
|
|||||||
@@ -642,3 +642,6 @@ PR_ANNOUNCEMENTS_PER_ROUND 5
|
|||||||
## Comment to disable sending a toast notification on the host server when initializations complete.
|
## Comment to disable sending a toast notification on the host server when initializations complete.
|
||||||
## Even if this is enabled, a notification will only be sent if there are no clients connected.
|
## Even if this is enabled, a notification will only be sent if there are no clients connected.
|
||||||
TOAST_NOTIFICATION_ON_INIT
|
TOAST_NOTIFICATION_ON_INIT
|
||||||
|
|
||||||
|
## Causes configuration errors to spit out runtimes
|
||||||
|
CONFIG_ERRORS_RUNTIME
|
||||||
|
|||||||
Reference in New Issue
Block a user