Reverts the recent config changes (#56606)

* Revert "Fixes included config files not loading (#56602)"

This reverts commit 0749b322f6.

* Revert "Adds configuration consistency tests (#56562)"

This reverts commit 4f44014e25.
This commit is contained in:
LemonInTheDark
2021-02-02 19:14:47 -08:00
committed by GitHub
parent ef73b284e6
commit dd6cea82d9
10 changed files with 71 additions and 176 deletions

View File

@@ -43,11 +43,11 @@
CRASH("/datum/controller/configuration/Load() called more than once!")
InitEntries()
LoadModes()
if(fexists("[directory]/[DEFAULT_CONFIGURATION_FILE]") && LoadEntries(DEFAULT_CONFIGURATION_FILE) <= 1)
if(fexists("[directory]/config.txt") && LoadEntries("config.txt") <= 1)
var/list/legacy_configs = list("game_options.txt", "dbconfig.txt", "comms.txt")
for(var/I in legacy_configs)
if(fexists("[directory]/[I]"))
log_config("No [CONFIGURATION_INCLUDE_TOKEN] directives found in [DEFAULT_CONFIGURATION_FILE]! Loading legacy [legacy_configs.Join("/")] files...")
log_config("No $include directives found in config.txt! Loading legacy [legacy_configs.Join("/")] files...")
for(var/J in legacy_configs)
LoadEntries(J)
break
@@ -101,39 +101,27 @@
entries -= CE.name
entries_by_type -= CE.type
/****
* Breaks up a file into an associated list of lowercase entries and their values. The null entry represents a nested list of entries that are commented out
* filename - The filename in directory to load
*/
/datum/controller/configuration/proc/ParseConfigFile(filename)
/datum/controller/configuration/proc/LoadEntries(filename, list/stack = list())
if(IsAdminAdvancedProcCall())
return
if(world.system_type == MS_WINDOWS)
filename = lowertext(filename)
var/filename_to_test = world.system_type == MS_WINDOWS ? lowertext(filename) : filename
if(filename_to_test in stack)
log_config("Warning: Config recursion detected ([english_list(stack)]), breaking!")
return
stack = stack + filename_to_test
log_config("Loading config file [filename]...")
var/list/lines = world.file2list("[directory]/[filename]")
var/list/results = list()
if(!lines.len) //Good job 4head you loaded a file that doesn't exist or doesn't contain anything in it
log_config("Error: We tried to load [directory]/[filename] but it doesn't have anything in it/it doesn't exist!")
CRASH("Error: We tried to load [directory]/[filename] but it doesn't have anything in it/it doesn't exist!")
var/list/_entries = entries
for(var/L in lines)
L = trim(L)
if(!L)
continue
var/firstchar = L[1]
var/disabled = FALSE
if(firstchar == "#")
if(length(L) > 1 && L[2] == "#")
// comment
continue
// disabled entry
disabled = TRUE
L = trim(copytext(L, 2, length(L) + 1))
firstchar = L[1]
continue
var/lockthis = firstchar == "@"
if(lockthis)
@@ -152,45 +140,15 @@
if(!entry)
continue
if(disabled)
LAZYADD(results[null], entry)
else if(entry == CONFIGURATION_INCLUDE_TOKEN)
LAZYADD(results[entry], value)
else
results[entry] = value
return results
///Takes the file name to load and a list of already loaded files as an argument, returns the amount of files loaded
/datum/controller/configuration/proc/LoadEntries(filename, list/stack = list())
if(IsAdminAdvancedProcCall())
return
var/filename_to_test = world.system_type == MS_WINDOWS ? lowertext(filename) : filename
if(filename_to_test in stack)
log_config("Warning: Config recursion detected ([english_list(stack)]), breaking!")
return
stack += filename_to_test
var/list/parsed_entries = ParseConfigFile(filename_to_test)
// Don't care about disabled entries here
parsed_entries -= null
for(var/entry in parsed_entries)
var/value = parsed_entries[entry]
if(entry == CONFIGURATION_INCLUDE_TOKEN)
for(var/includedfile in value) //Value is a list of included files in this case
if(!includedfile)
log_config("Warning: Invalid $include directive: [includedfile]")
else
. += LoadEntries(includedfile, stack)
if(entry == "$include")
if(!value)
log_config("Warning: Invalid $include directive: [value]")
else
LoadEntries(value, stack)
++.
continue
var/firstchar = entry[1]
var/lockthis = firstchar == "@"
if(lockthis)
entry = copytext(entry, length(firstchar) + 1)
var/datum/config_entry/E = entries[entry]
var/datum/config_entry/E = _entries[entry]
if(!E)
log_config("Unknown setting in configuration: '[entry]'")
continue