From dd6cea82d998904b43e9c9fd5a3f764bee2972aa Mon Sep 17 00:00:00 2001 From: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com> Date: Tue, 2 Feb 2021 19:14:47 -0800 Subject: [PATCH] Reverts the recent config changes (#56606) * Revert "Fixes included config files not loading (#56602)" This reverts commit 0749b322f65e71aa3c976a3696a5f6d93bc9f719. * Revert "Adds configuration consistency tests (#56562)" This reverts commit 4f44014e255b1340eefe72628e27c90662b5190e. --- code/__DEFINES/configuration.dm | 6 -- .../configuration/configuration.dm | 76 +++++-------------- code/modules/unit_tests/_unit_tests.dm | 1 - .../unit_tests/configuration_documentation.dm | 63 --------------- config/antag_rep.txt | 6 +- config/config.txt | 38 ++++++---- config/game_options.txt | 3 +- config/interviews.txt | 6 +- config/resources.txt | 44 +++++------ tools/ci/run_server.sh | 4 +- 10 files changed, 71 insertions(+), 176 deletions(-) delete mode 100644 code/modules/unit_tests/configuration_documentation.dm diff --git a/code/__DEFINES/configuration.dm b/code/__DEFINES/configuration.dm index 5d204694d2b..3fbc6d098f3 100644 --- a/code/__DEFINES/configuration.dm +++ b/code/__DEFINES/configuration.dm @@ -9,9 +9,3 @@ #define CONFIG_ENTRY_LOCKED 1 /// can't see value #define CONFIG_ENTRY_HIDDEN 2 - -/// The main configuration .txt file loaded -#define DEFAULT_CONFIGURATION_FILE "config.txt" - -/// The token used to include other config files -#define CONFIGURATION_INCLUDE_TOKEN "$include" diff --git a/code/controllers/configuration/configuration.dm b/code/controllers/configuration/configuration.dm index 4fd5573c770..55930cfa600 100644 --- a/code/controllers/configuration/configuration.dm +++ b/code/controllers/configuration/configuration.dm @@ -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 diff --git a/code/modules/unit_tests/_unit_tests.dm b/code/modules/unit_tests/_unit_tests.dm index c08a377f278..fc7ebbb707c 100644 --- a/code/modules/unit_tests/_unit_tests.dm +++ b/code/modules/unit_tests/_unit_tests.dm @@ -44,7 +44,6 @@ #include "chain_pull_through_space.dm" #include "combat.dm" #include "component_tests.dm" -#include "configuration_documentation.dm" #include "confusion.dm" #include "designs.dm" #include "emoting.dm" diff --git a/code/modules/unit_tests/configuration_documentation.dm b/code/modules/unit_tests/configuration_documentation.dm deleted file mode 100644 index efe9614a540..00000000000 --- a/code/modules/unit_tests/configuration_documentation.dm +++ /dev/null @@ -1,63 +0,0 @@ -/datum/unit_test/configuration_documentation - /// List of undocumented config entries - var/list/undocumented_entries - /// List of set config entries with no code equivalent - var/list/extraneous_entries - /// List of entries seen already - var/list/seen_entries - -/datum/unit_test/configuration_documentation/Run() - undocumented_entries = list() - for(var/entry_key in global.config.entries) - var/datum/config_entry/config_entry = global.config.entries[entry_key] - if(!config_entry.deprecated_by) - undocumented_entries += entry_key - - extraneous_entries = list() - seen_entries = list() - var/test_config_file = world.params["original_config"] ? world.params["original_config"] : DEFAULT_CONFIGURATION_FILE - TestGraph(test_config_file) - if(undocumented_entries.len) - Fail("The following configuration entries are missing default values in the .txt (commented out or otherwise): [english_list(undocumented_entries)]") - if(extraneous_entries.len) - Fail("The following configuration entries do not have a match in code: [english_list(extraneous_entries)]") - -/**** - * Test a graph of config files inclusions - * filename - The file to test - * stack - Used for recursive calls to prevent repeat parsing - */ -/datum/unit_test/configuration_documentation/proc/TestGraph(filename, list/stack = list()) - var/filename_to_test = world.system_type == MS_WINDOWS ? lowertext(filename) : filename - if(filename_to_test in stack) - Fail("Config recursion detected ([english_list(stack)])!") - return - - stack = stack + filename_to_test - - var/list/parsed_entries = global.config.ParseConfigFile(filename_to_test) - for(var/entry in parsed_entries) - if(!entry) - // Commented out entries - for(var/disabled_entry in parsed_entries[entry]) - TryRemoveEntry(disabled_entry, filename_to_test) - else if(entry == CONFIGURATION_INCLUDE_TOKEN) - for(var/sub_config in parsed_entries[entry]) - TestGraph(sub_config, stack) - else - TryRemoveEntry(entry, filename_to_test) - -/**** - * Attempt to update undocumented_entries and extraneous_entries - * entry - The detected entry - * filename - The containing filename - */ -/datum/unit_test/configuration_documentation/proc/TryRemoveEntry(entry, filename) - entry = lowertext(entry) - var/start_len = undocumented_entries.len - undocumented_entries -= entry - - if(!seen_entries[entry]) - seen_entries[entry] = TRUE - if(undocumented_entries.len == start_len) - extraneous_entries[entry] = filename diff --git a/config/antag_rep.txt b/config/antag_rep.txt index 047afc51cde..e8a7250686a 100644 --- a/config/antag_rep.txt +++ b/config/antag_rep.txt @@ -1,5 +1,5 @@ ## Custom antag reputation values ## List of job titles followed by antag rep value, all prefixed with ANTAG_REP. See code/modules/jobs/job_types for titles -## e.g. -# ANTAG_REP Captain 10 -# ANTAG_REP Assistant 0 +## e.g. +## ANTAG_REP Captain 10 +## ANTAG_REP Assistant 0 diff --git a/config/config.txt b/config/config.txt index 074f31568b7..7927899f5aa 100644 --- a/config/config.txt +++ b/config/config.txt @@ -1,4 +1,4 @@ -## You can use the "$include" directive to split your configs however you want +# You can use the "$include" directive to split your configs however you want $include game_options.txt $include dbconfig.txt @@ -7,13 +7,13 @@ $include antag_rep.txt $include resources.txt $include interviews.txt -## You can use the @ character at the beginning of a config option to lock it from being edited in-game -## Example usage: -## @SERVERNAME tgstation -## Which sets the SERVERNAME, and disallows admins from being able to change it using View Variables. -## @LOG_TWITTER 0 -## Which explicitly disables LOG_TWITTER, as well as locking it. -## There are various options which are hard-locked for security reasons. +# You can use the @ character at the beginning of a config option to lock it from being edited in-game +# Example usage: +# @SERVERNAME tgstation +# Which sets the SERVERNAME, and disallows admins from being able to change it using View Variables. +# @LOG_TWITTER 0 +# Which explicitly disables LOG_TWITTER, as well as locking it. +# There are various options which are hard-locked for security reasons. ## Server name: This appears at the top of the screen in-game and in the BYOND hub. Uncomment and replace 'tgstation' with the name of your choice. # SERVERNAME tgstation @@ -27,9 +27,6 @@ STATIONNAME Space Station 13 ## Put on byond hub: Uncomment this to put your server on the byond hub. #HUB -## Once the server population reaches this number, it will be taken off the byond hub. 0 disables. -#MAX_HUB_POP 100 - ## Lobby time: This is the amount of time between rounds that players have to setup their characters and be ready. LOBBY_COUNTDOWN 120 @@ -402,9 +399,6 @@ AUTOADMIN_RANK Game Master ## Uncomment to automatically deadmin players when the game starts. #AUTO_DEADMIN_PLAYERS -## Number of game ticks before player-admins will be automatically deadminned. -#AUTO_DEADMIN_TIMEGATE 600 - ## Uncomment to automatically deadmin antagonists when they gain the role. #AUTO_DEADMIN_ANTAGONISTS @@ -522,3 +516,19 @@ DEFAULT_VIEW_SQUARE 15x15 ## Uncomment to enable source whitelisting, a comma-separated list (no spaces) of CentCom sources (sourceName). ## If enabled, only bans from these servers will be shown to admins using CentCom. The default sources list is an example. #CENTCOM_SOURCE_WHITELIST Beestation MRP,TGMC,FTL13 + +#### DISCORD STUFFS #### +## MAKE SURE ALL SECTIONS OF THIS ARE FILLED OUT BEFORE ENABLING +## Discord IDs can be obtained by following this guide: https://support.discord.com/hc/en-us/articles/206346498-Where-can-I-find-my-User-Server-Message-ID- + +## Uncomment to enable discord auto-roling when users link their BYOND and Discord accounts +#ENABLE_DISCORD_AUTOROLE + +## Add your discord bot token here. Make sure it has the ability to manage roles +#DISCORD_TOKEN someDiscordToken + +## Add the ID of your guild (server) here +#DISCORD_GUILDID 000000000000000000 + +## Add the ID of the role you want assigning here +#DISCORD_ROLEID 000000000000000000 diff --git a/config/game_options.txt b/config/game_options.txt index caa1b0f9196..415f0bf497a 100644 --- a/config/game_options.txt +++ b/config/game_options.txt @@ -21,7 +21,7 @@ EMOJIS ## HEART COMMENDATIONS ### ## Uncomment this if you'd like to enable commendation pollings for this percentage of players near the end of the round (5% default) -#COMMENDATIONS 0.05 +## COMMENDATIONS 0.05 ## MOB MOVEMENT ### @@ -199,7 +199,6 @@ SHUTTLE_REFUEL_DELAY 12000 TRAITOR_SCALING_COEFF 6 BROTHER_SCALING_COEFF 6 CHANGELING_SCALING_COEFF 6 -ECULT_SCALING_COEFF 6 ## Variables calculate how number of open security officer positions will scale to population. ## Used as (Officers = Population / Coeff) diff --git a/config/interviews.txt b/config/interviews.txt index a7e3f21ef2d..5bd80b81546 100644 --- a/config/interviews.txt +++ b/config/interviews.txt @@ -1,8 +1,8 @@ -## Interview welcome message displayed at the top of all interview questionnaires -## Should help to describe why the questionnaire is being given to the interviewee +# Interview welcome message displayed at the top of all interview questionnaires +# Should help to describe why the questionnaire is being given to the interviewee INTERVIEW_WELCOME_MSG Welcome to our server. As you have not played here before, or played very little, we'll need you to answer a few questions below. After you submit your answers they will be reviewed and you may be asked further questions before being allowed to play. Please be patient as there may be others ahead of you. -## Interview questions are listed here, in the order that they will be displayed in-game. +# Interview questions are listed here, in the order that they will be displayed in-game. INTERVIEW_QUESTIONS Why have you joined the server today? INTERVIEW_QUESTIONS Have you played space-station 13 before? If so, on what servers? INTERVIEW_QUESTIONS Do you know anybody on the server today? If so, who? diff --git a/config/resources.txt b/config/resources.txt index a3fbf9153d6..95a1f20434a 100644 --- a/config/resources.txt +++ b/config/resources.txt @@ -1,41 +1,41 @@ -## External resources -## Set this to the location of a .zip with the server's .rsc inside of it. -## If you set this mutiple times, the server will rotate between the links. -## To use this, the compile option PRELOAD_RSC must be set to 0 to keep byond from preloading resources -## Resource urls can not be encrypted (https://), as they are downloaded by byond, not IE, and byond can't into encryption +# External resources +# Set this to the location of a .zip with the server's .rsc inside of it. +# If you set this mutiple times, the server will rotate between the links. +# To use this, the compile option PRELOAD_RSC must be set to 0 to keep byond from preloading resources +# Resource urls can not be encrypted (https://), as they are downloaded by byond, not IE, and byond can't into encryption EXTERNAL_RSC_URLS http://tgstation13.download/byond/tgstationv2.zip ######################## -## Browser Asset Config # +# Browser Asset Config # ######################## -## Browser assets are any file included in interfaces. css, images, javascript, etc. -## This handles configuring how we get these to the player so interfaces can access them. +# Browser assets are any file included in interfaces. css, images, javascript, etc. +# This handles configuring how we get these to the player so interfaces can access them. -## Asset Transport -## The normal way of getting assets to clients is to use the internal byond system. This can be slow and delay the opening of interface windows. It also doesn't allow the internal IE windows byond uses to cache anything. -## You can instead have the server save them to a website via a folder within the game server that the web server can read. This could be a simple webserver or something backed by a CDN. -## Valid values: simple, webroot. Simple is the default. +# Asset Transport +# The normal way of getting assets to clients is to use the internal byond system. This can be slow and delay the opening of interface windows. It also doesn't allow the internal IE windows byond uses to cache anything. +# You can instead have the server save them to a website via a folder within the game server that the web server can read. This could be a simple webserver or something backed by a CDN. +# Valid values: simple, webroot. Simple is the default. #ASSET_TRANSPORT webroot -## Simple asset transport configurable values. +# Simple asset transport configurable values. -## Uncomment this to have the server passively send all browser assets to each client in the background. (instead of waiting for them to be needed) -## This should be uncommented in production and commented in development +# Uncomment this to have the server passively send all browser assets to each client in the background. (instead of waiting for them to be needed) +# This should be uncommented in production and commented in development #ASSET_SIMPLE_PRELOAD -## Webroot asset transport configurable values. +# Webroot asset transport configurable values. -## Local folder to save assets to. -## Assets will be saved in the format of asset.MD5HASH.EXT or in namespaces/hash/ as ASSET_FILE_NAME or asset.MD5HASH.EXT +# Local folder to save assets to. +# Assets will be saved in the format of asset.MD5HASH.EXT or in namespaces/hash/ as ASSET_FILE_NAME or asset.MD5HASH.EXT #ASSET_CDN_WEBROOT data/asset-store/ -## URL the folder from above can be accessed from. -## for best results the webserver powering this should return a long cache validity time, as all assets sent via this transport use hash based urls -## Encryption (https) is supported here, but linux clients will have issues if you require higher then tls 1.0. Windows clients down to windows 7 can handle tls 1.2 no issue. -## if you want to test this locally, you simpily run the `localhost-asset-webroot-server.py` python3 script to host assets stored in `data/asset-store/` via http://localhost:58715/ +# URL the folder from above can be accessed from. +# for best results the webserver powering this should return a long cache validity time, as all assets sent via this transport use hash based urls +# Encryption (https) is supported here, but linux clients will have issues if you require higher then tls 1.0. Windows clients down to windows 7 can handle tls 1.2 no issue. +# if you want to test this locally, you simpily run the `localhost-asset-webroot-server.py` python3 script to host assets stored in `data/asset-store/` via http://localhost:58715/ #ASSET_CDN_URL http://localhost:58715/ diff --git a/tools/ci/run_server.sh b/tools/ci/run_server.sh index 6718e672fd6..4d943846f04 100644 --- a/tools/ci/run_server.sh +++ b/tools/ci/run_server.sh @@ -5,11 +5,9 @@ tools/deploy.sh ci_test mkdir ci_test/config #test config -cp -r config/* ci_test/config/ -mv ci_test/config/config.txt ci_test/config/original_config.txt cp tools/ci/ci_config.txt ci_test/config/config.txt cd ci_test -DreamDaemon tgstation.dmb -close -trusted -verbose -params "log-directory=ci&original_config=original_config.txt" +DreamDaemon tgstation.dmb -close -trusted -verbose -params "log-directory=ci" cd .. cat ci_test/data/logs/ci/clean_run.lk