From 242fa3a66b3cd9e5a477c7f6543dcaee71bf4326 Mon Sep 17 00:00:00 2001
From: Selis <12716288+ItsSelis@users.noreply.github.com>
Date: Tue, 22 Oct 2024 19:26:44 +0200
Subject: [PATCH] Ports over configuration controller (#16484)
* Ports over configuration controller
* Fixes
* Manual path fix
* patch (#16490)
* patch
* .
* SQL Fix
* Post-rebase fix
* Added missing examples
---------
Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com>
---
code/__defines/configuration.dm | 30 +
code/__defines/rust_g.dm | 117 ++-
code/_global_vars/configuration.dm | 5 +
code/_global_vars/sensitive.dm | 11 -
code/_helpers/_lists.dm | 6 +
code/_helpers/logging.dm | 46 +-
code/_helpers/logging/debug.dm | 11 +
code/_helpers/logging_vr.dm | 6 +-
code/_helpers/mobs.dm | 2 +-
code/_helpers/nameof.dm | 11 +
code/_helpers/names.dm | 8 +-
code/_helpers/text.dm | 7 +
code/_helpers/type2type.dm | 30 +
code/_helpers/unsorted.dm | 3 -
code/_helpers/unsorted_vr.dm | 12 +-
code/_onclick/click.dm | 2 +-
code/controllers/autotransfer.dm | 12 +-
.../controllers/configuration/config_entry.dm | 300 ++++++++
.../configuration/configuration.dm | 536 ++++++++++++++
.../configuration/entries/dbconfig.dm | 58 ++
.../configuration/entries/game_options.dm | 102 +++
.../configuration/entries/general.dm | 696 ++++++++++++++++++
.../configuration/entries/resources.dm | 11 +
.../configuration/entries/vorestation.dm | 63 ++
code/controllers/configuration/legacy.dm | 53 ++
code/controllers/master.dm | 11 +-
code/controllers/subsystem.dm | 2 +
code/controllers/subsystems/assets.dm | 4 +-
code/controllers/subsystems/inactivity.dm | 6 +-
code/controllers/subsystems/lighting.dm | 2 +-
code/controllers/subsystems/mapping.dm | 6 +-
code/controllers/subsystems/media_tracks.dm | 2 +-
code/controllers/subsystems/nightshift.dm | 2 +-
code/controllers/subsystems/persist_vr.dm | 6 +-
code/controllers/subsystems/persistence.dm | 2 +-
code/controllers/subsystems/radiation.dm | 14 +-
code/controllers/subsystems/sqlite.dm | 10 +-
code/controllers/subsystems/ticker.dm | 16 +-
code/datums/ai_law_sets.dm | 2 +-
code/datums/helper_datums/getrev.dm | 8 +-
code/datums/managed_browsers/feedback_form.dm | 15 +-
.../managed_browsers/feedback_viewer.dm | 4 +-
code/defines/procs/dbcore.dm | 6 +-
code/defines/procs/statistics.dm | 12 +-
code/game/antagonist/alien/borer.dm | 2 +-
code/game/antagonist/alien/xenomorph.dm | 2 +-
code/game/antagonist/antagonist.dm | 4 +-
code/game/antagonist/antagonist_create.dm | 4 +-
code/game/antagonist/antagonist_helpers.dm | 4 +-
code/game/antagonist/antagonist_objectives.dm | 6 +-
code/game/antagonist/outsider/ninja.dm | 2 +-
code/game/antagonist/outsider/raider.dm | 2 +-
code/game/dna/dna_modifier.dm | 2 +-
code/game/gamemodes/cult/runes.dm | 2 +-
code/game/gamemodes/cult/soulstone.dm | 2 +-
code/game/gamemodes/events/holidays/Other.dm | 4 +-
code/game/gamemodes/game_mode.dm | 8 +-
code/game/gamemodes/nuclear/nuclear.dm | 2 +-
.../technomancer/spells/mend_organs.dm | 2 +-
code/game/jobs/job/assistant.dm | 2 +-
code/game/jobs/job/assistant_vr.dm | 10 +-
code/game/jobs/job/job.dm | 4 +-
code/game/jobs/job/job_vr.dm | 8 +-
code/game/jobs/job/special_vr.dm | 4 +-
code/game/jobs/job_controller.dm | 2 +-
code/game/jobs/whitelist.dm | 6 +-
code/game/machinery/Sleeper.dm | 2 +-
code/game/machinery/computer/Operating.dm | 2 +-
code/game/machinery/computer/cloning.dm | 2 +-
code/game/machinery/computer/timeclock_vr.dm | 2 +-
code/game/machinery/cryo.dm | 2 +-
code/game/objects/effects/decals/cleanable.dm | 2 +-
code/game/objects/explosion.dm | 4 +-
code/game/objects/items/contraband_vr.dm | 2 +-
code/game/objects/items/crayons.dm | 2 +-
.../items/devices/communicator/phone.dm | 2 +-
code/game/objects/items/devices/defib.dm | 8 +-
code/game/objects/items/trash.dm | 4 +-
code/game/objects/items/weapons/manuals.dm | 161 ----
code/game/objects/items/weapons/manuals_vr.dm | 10 +-
.../objects/items/weapons/wiki_manuals.dm | 145 ++++
code/game/objects/structures/gravemarker.dm | 4 +-
.../structures/stool_bed_chair_nest/chairs.dm | 4 +-
code/game/objects/structures/trash_pile_vr.dm | 4 +-
code/game/turfs/space/space.dm | 4 +-
code/game/world.dm | 153 ++--
code/global.dm | 2 -
code/global_init.dm | 4 +-
code/modules/admin/IsBanned.dm | 8 +-
code/modules/admin/NewBan.dm | 4 +-
code/modules/admin/ToRban.dm | 6 +-
code/modules/admin/admin.dm | 90 +--
code/modules/admin/admin_investigate.dm | 2 +-
code/modules/admin/admin_ranks.dm | 6 +-
code/modules/admin/admin_verb_lists_vr.dm | 2 +-
code/modules/admin/admin_verbs.dm | 16 +-
code/modules/admin/admin_verbs_vr.dm | 10 +-
code/modules/admin/banjob.dm | 8 +-
.../admin/permissionverbs/permissionedit.dm | 4 +-
code/modules/admin/topic.dm | 46 +-
code/modules/admin/verbs/adminhelp.dm | 4 +-
code/modules/admin/verbs/adminhelp_vr.dm | 6 +-
code/modules/admin/verbs/adminjump.dm | 18 +-
code/modules/admin/verbs/adminpm.dm | 2 +-
code/modules/admin/verbs/debug.dm | 12 +-
code/modules/admin/verbs/fps.dm | 6 +-
code/modules/admin/verbs/panicbunker.dm | 20 +-
code/modules/admin/verbs/playsound.dm | 4 +-
code/modules/admin/verbs/possess.dm | 2 +-
code/modules/admin/verbs/randomverbs.dm | 22 +-
code/modules/asset_cache/asset_list.dm | 12 +-
.../asset_cache/transports/asset_transport.dm | 4 +-
.../transports/webroot_transport.dm | 8 +-
code/modules/awaymissions/gateway.dm | 2 +-
code/modules/client/client procs.dm | 30 +-
code/modules/client/client procs_vr.dm | 12 +-
.../preference_setup/general/01_basic.dm | 4 +-
.../preference_setup/general/02_language.dm | 6 +-
.../client/preference_setup/global/01_ui.dm | 2 +-
.../preference_setup/global/02_settings.dm | 2 +-
.../preference_setup/loadout/loadout.dm | 10 +-
.../preference_setup/occupation/occupation.dm | 4 +-
code/modules/client/preferences.dm | 8 +-
.../client/preferences/migrations/14_nifs.dm | 2 +-
.../preferences/migrations/15_nif_path.dm | 2 +-
code/modules/client/preferences_savefile.dm | 4 +-
code/modules/client/preferences_tgui.dm | 2 +-
code/modules/client/verbs/ooc.dm | 22 +-
code/modules/client/verbs/who.dm | 8 +-
code/modules/events/event_container.dm | 22 +-
code/modules/events/event_dynamic.dm | 2 +-
code/modules/events/event_manager.dm | 6 +-
code/modules/ext_scripts/irc.dm | 10 +-
code/modules/library/lib_items.dm | 19 +-
code/modules/library/lib_machines.dm | 12 +-
code/modules/lighting/lighting_overlay.dm | 2 +-
code/modules/maps/tg/map_template.dm | 2 +-
code/modules/mob/_modifiers/unholy.dm | 2 +-
code/modules/mob/dead/observer/observer.dm | 16 +-
code/modules/mob/emote.dm | 2 +-
code/modules/mob/language/language.dm | 4 +-
code/modules/mob/living/carbon/brain/life.dm | 2 +-
code/modules/mob/living/carbon/breathe.dm | 4 +-
code/modules/mob/living/carbon/carbon.dm | 2 +-
.../mob/living/carbon/human/appearance.dm | 6 +-
code/modules/mob/living/carbon/human/human.dm | 4 +-
.../living/carbon/human/human_attackhand.dm | 4 +-
.../mob/living/carbon/human/human_damage.dm | 2 +-
.../mob/living/carbon/human/human_defense.dm | 2 +-
.../mob/living/carbon/human/human_movement.dm | 6 +-
code/modules/mob/living/carbon/human/life.dm | 14 +-
.../carbon/human/species/species_getters.dm | 2 +-
.../carbon/human/species/station/alraune.dm | 2 +-
.../human/species/xenomorphs/alien_powers.dm | 2 +-
code/modules/mob/living/living.dm | 4 +-
.../living/silicon/ai/ai_remote_control.dm | 4 +-
code/modules/mob/living/silicon/ai/malf.dm | 2 +-
code/modules/mob/living/silicon/decoy/life.dm | 2 +-
.../mob/living/silicon/robot/drone/drone.dm | 4 +-
.../silicon/robot/drone/drone_manufacturer.dm | 10 +-
code/modules/mob/living/silicon/robot/life.dm | 4 +-
.../modules/mob/living/silicon/robot/robot.dm | 4 +-
.../living/silicon/robot/robot_movement.dm | 2 +-
.../silicon/robot/robot_remote_control.dm | 4 +-
.../mob/living/simple_mob/simple_mob.dm | 4 +-
.../simple_mob/subtypes/animal/pets/cat_vr.dm | 3 +-
code/modules/mob/login.dm | 4 +-
code/modules/mob/mob.dm | 8 +-
code/modules/mob/mob_movement.dm | 4 +-
code/modules/mob/new_player/login.dm | 10 +-
code/modules/mob/new_player/new_player.dm | 4 +-
code/modules/mob/new_player/new_player_vr.dm | 4 +-
code/modules/mob/say.dm | 2 +-
code/modules/organs/internal/brain.dm | 6 +-
code/modules/organs/organ.dm | 2 +-
code/modules/organs/organ_external.dm | 18 +-
code/modules/organs/subtypes/standard.dm | 2 +-
code/modules/paperwork/faxmachine.dm | 20 +-
code/modules/persistence/graffiti.dm | 2 +-
code/modules/power/solar.dm | 2 +-
code/modules/radiation/radiation.dm | 8 +-
code/modules/resleeving/computers.dm | 2 +-
code/modules/resleeving/machines.dm | 2 +-
.../security levels/keycard authentication.dm | 4 +-
.../security levels/security levels.dm | 26 +-
code/modules/tgs/v5/api_vgs.dm | 10 +-
code/modules/tgui/modules/late_choices.dm | 2 +-
code/modules/vehicles/cargo_train.dm | 2 +-
code/modules/vehicles/rover_vr.dm | 2 +-
code/modules/vore/eating/belly_obj_vr.dm | 2 +-
code/modules/vore/eating/living_vr.dm | 2 +-
code/modules/vore/smoleworld/smoleworld_vr.dm | 20 +-
code/modules/webhooks/_webhook.dm | 2 +-
config/.gitignore | 6 +-
config/example/config.txt | 246 ++-----
config/example/dbconfig.txt | 48 +-
config/example/forumdbconfig.txt | 19 -
config/example/game_options.txt | 34 +-
config/example/jobwhitelist.txt | 10 +
config/example/logging.txt | 57 ++
config/example/mentors.txt | 1 +
config/example/moderators.txt | 1 +
config/example/resources.txt | 37 +
config/example/sqlite.txt | 35 +
config/example/svndir.txt | 5 -
interface/interface.dm | 32 +-
maps/RandomZLevels/Academy.dmm | 4 +-
maps/RandomZLevels/example.dmm | 2 +-
maps/RandomZLevels/stationCollision.dmm | 2 +-
maps/cynosure/cynosure-6.dmm | 2 +-
maps/gateway_archive_vr/Academy.dmm | 6 +-
maps/gateway_archive_vr/example.dmm | 4 +-
maps/gateway_archive_vr/stationCollision.dmm | 2 +-
maps/gateway_archive_vr/zresearchlabs.dmm | 6 +-
maps/gateway_vr/variable/arynthilake_a.dmm | 20 +-
maps/gateway_vr/variable/arynthilake_b.dmm | 20 +-
maps/groundbase/gb-centcomm.dmm | 14 +-
maps/groundbase/gb-z1.dmm | 16 +-
maps/groundbase/gb-z2.dmm | 18 +-
maps/northern_star/polaris-1.dmm | 6 +-
maps/northern_star/polaris-2.dmm | 3 +-
maps/redgate/cybercity.dmm | 2 +-
maps/redgate/facility.dmm | 2 +-
maps/southern_cross/southern_cross-1.dmm | 6 +-
maps/southern_cross/southern_cross-6.dmm | 3 +-
maps/stellar_delight/ship_centcom.dmm | 14 +-
maps/stellar_delight/stellar_delight1.dmm | 20 +-
maps/stellar_delight/stellar_delight2.dmm | 6 +-
maps/stellar_delight/stellar_delight3.dmm | 10 +-
maps/submaps/admin_use_vr/dhael_centcom.dmm | 14 +-
maps/submaps/admin_use_vr/wizard.dmm | 4 +-
maps/submaps/pois_vr/aerostat/DJOutpost1.dmm | 2 +-
.../surface_submaps/wilderness/DJOutpost1.dmm | 2 +-
.../surface_submaps/wilderness/DJOutpost3.dmm | 2 +-
.../surface_submaps/wilderness/DJOutpost4.dmm | 2 +-
maps/tether/submaps/tether_centcom.dmm | 14 +-
maps/tether/tether-01-surface1.dmm | 4 +-
maps/tether/tether-02-surface2.dmm | 18 +-
maps/tether/tether-03-surface3.dmm | 40 +-
maps/tether/tether-05-station1.dmm | 4 +-
tools/ci/validate_files.sh | 2 +-
vorestation.dme | 16 +-
242 files changed, 3275 insertions(+), 1257 deletions(-)
create mode 100644 code/__defines/configuration.dm
create mode 100644 code/_global_vars/configuration.dm
delete mode 100644 code/_global_vars/sensitive.dm
create mode 100644 code/_helpers/logging/debug.dm
create mode 100644 code/_helpers/nameof.dm
create mode 100644 code/controllers/configuration/config_entry.dm
create mode 100644 code/controllers/configuration/configuration.dm
create mode 100644 code/controllers/configuration/entries/dbconfig.dm
create mode 100644 code/controllers/configuration/entries/game_options.dm
create mode 100644 code/controllers/configuration/entries/general.dm
create mode 100644 code/controllers/configuration/entries/resources.dm
create mode 100644 code/controllers/configuration/entries/vorestation.dm
create mode 100644 code/controllers/configuration/legacy.dm
create mode 100644 code/game/objects/items/weapons/wiki_manuals.dm
delete mode 100644 config/example/forumdbconfig.txt
create mode 100644 config/example/jobwhitelist.txt
create mode 100644 config/example/logging.txt
create mode 100644 config/example/resources.txt
create mode 100644 config/example/sqlite.txt
delete mode 100644 config/example/svndir.txt
diff --git a/code/__defines/configuration.dm b/code/__defines/configuration.dm
new file mode 100644
index 0000000000..477bed243c
--- /dev/null
+++ b/code/__defines/configuration.dm
@@ -0,0 +1,30 @@
+//config files
+#define CONFIG_GET(X) global.config.Get(/datum/config_entry/##X)
+#define CONFIG_SET(X, Y) global.config.Set(/datum/config_entry/##X, ##Y)
+
+#define CONFIG_MAPS_FILE "maps.txt"
+
+//flags
+/// can't edit
+#define CONFIG_ENTRY_LOCKED (1<<0)
+/// can't see value
+#define CONFIG_ENTRY_HIDDEN (1<<1)
+
+/// Force the config directory to be something other than "config"
+#define OVERRIDE_CONFIG_DIRECTORY_PARAMETER "config-directory"
+
+// Config entry types
+#define VALUE_MODE_NUM 0
+#define VALUE_MODE_TEXT 1
+#define VALUE_MODE_FLAG 2
+
+#define KEY_MODE_TEXT 0
+#define KEY_MODE_TYPE 1
+
+// Flags for respawn config
+/// Respawn not allowed
+#define RESPAWN_FLAG_DISABLED 0
+/// Respawn as much as you'd like
+#define RESPAWN_FLAG_FREE 1
+/// Can respawn, but not as the same character
+#define RESPAWN_FLAG_NEW_CHARACTER 2
diff --git a/code/__defines/rust_g.dm b/code/__defines/rust_g.dm
index 1c93497ec8..bd0e0879b4 100644
--- a/code/__defines/rust_g.dm
+++ b/code/__defines/rust_g.dm
@@ -38,27 +38,46 @@
#define RUST_G (__rust_g || __detect_rust_g())
#endif
-#define RUSTG_JOB_NO_RESULTS_YET "NO RESULTS YET"
-#define RUSTG_JOB_NO_SUCH_JOB "NO SUCH JOB"
-#define RUSTG_JOB_ERROR "JOB PANICKED"
+// Handle 515 call() -> call_ext() changes
+#if DM_VERSION >= 515
+#define RUSTG_CALL call_ext
+#else
+#define RUSTG_CALL call
+#endif
-#define rustg_dmi_strip_metadata(fname) LIBCALL(RUST_G, "dmi_strip_metadata")(fname)
-#define rustg_dmi_create_png(path, width, height, data) LIBCALL(RUST_G, "dmi_create_png")(path, width, height, data)
+/// Gets the version of rust_g
+/proc/rustg_get_version() return RUSTG_CALL(RUST_G, "get_version")()
-#define rustg_noise_get_at_coordinates(seed, x, y) LIBCALL(RUST_G, "noise_get_at_coordinates")(seed, x, y)
+#define rustg_dmi_strip_metadata(fname) RUSTG_CALL(RUST_G, "dmi_strip_metadata")(fname)
+#define rustg_dmi_create_png(path, width, height, data) RUSTG_CALL(RUST_G, "dmi_create_png")(path, width, height, data)
+#define rustg_dmi_resize_png(path, width, height, resizetype) RUSTG_CALL(RUST_G, "dmi_resize_png")(path, width, height, resizetype)
+/**
+ * input: must be a path, not an /icon; you have to do your own handling if it is one, as icon objects can't be directly passed to rustg.
+ *
+ * output: json_encode'd list. json_decode to get a flat list with icon states in the order they're in inside the .dmi
+ */
+#define rustg_dmi_icon_states(fname) RUSTG_CALL(RUST_G, "dmi_icon_states")(fname)
-#define rustg_file_read(fname) LIBCALL(RUST_G, "file_read")(fname)
-#define rustg_file_exists(fname) LIBCALL(RUST_G, "file_exists")(fname)
-#define rustg_file_write(text, fname) LIBCALL(RUST_G, "file_write")(text, fname)
-#define rustg_file_append(text, fname) LIBCALL(RUST_G, "file_append")(text, fname)
+#define rustg_file_read(fname) RUSTG_CALL(RUST_G, "file_read")(fname)
+#define rustg_file_exists(fname) (RUSTG_CALL(RUST_G, "file_exists")(fname) == "true")
+#define rustg_file_write(text, fname) RUSTG_CALL(RUST_G, "file_write")(text, fname)
+#define rustg_file_append(text, fname) RUSTG_CALL(RUST_G, "file_append")(text, fname)
+#define rustg_file_get_line_count(fname) text2num(RUSTG_CALL(RUST_G, "file_get_line_count")(fname))
+#define rustg_file_seek_line(fname, line) RUSTG_CALL(RUST_G, "file_seek_line")(fname, "[line]")
#ifdef RUSTG_OVERRIDE_BUILTINS
#define file2text(fname) rustg_file_read("[fname]")
#define text2file(text, fname) rustg_file_append(text, "[fname]")
#endif
-#define rustg_git_revparse(rev) LIBCALL(RUST_G, "rg_git_revparse")(rev)
-#define rustg_git_commit_date(rev) LIBCALL(RUST_G, "rg_git_commit_date")(rev)
+/// Returns the git hash of the given revision, ex. "HEAD".
+#define rustg_git_revparse(rev) RUSTG_CALL(RUST_G, "rg_git_revparse")(rev)
+
+/**
+ * Returns the date of the given revision in the format YYYY-MM-DD.
+ * Returns null if the revision is invalid.
+ */
+#define rustg_git_commit_date(rev) RUSTG_CALL(RUST_G, "rg_git_commit_date")(rev)
#define rustg_hash_string(algorithm, text) LIBCALL(RUST_G, "hash_string")(algorithm, text)
#define rustg_hash_file(algorithm, fname) LIBCALL(RUST_G, "hash_file")(algorithm, fname)
@@ -72,28 +91,36 @@
#define md5(thing) (isfile(thing) ? rustg_hash_file(RUSTG_HASH_MD5, "[thing]") : rustg_hash_string(RUSTG_HASH_MD5, thing))
#endif
-#define rustg_json_is_valid(text) (LIBCALL(RUST_G, "json_is_valid")(text) == "true")
-
-#define rustg_log_write(fname, text, format) LIBCALL(RUST_G, "log_write")(fname, text, format)
-/proc/rustg_log_close_all() return LIBCALL(RUST_G, "log_close_all")()
-
-#define rustg_url_encode(text) LIBCALL(RUST_G, "url_encode")(text)
-#define rustg_url_decode(text) LIBCALL(RUST_G, "url_decode")(text)
-
-#ifdef RUSTG_OVERRIDE_BUILTINS
-#define url_encode(text) rustg_url_encode(text)
-#define url_decode(text) rustg_url_decode(text)
-#endif
-
#define RUSTG_HTTP_METHOD_GET "get"
#define RUSTG_HTTP_METHOD_PUT "put"
#define RUSTG_HTTP_METHOD_DELETE "delete"
#define RUSTG_HTTP_METHOD_PATCH "patch"
#define RUSTG_HTTP_METHOD_HEAD "head"
#define RUSTG_HTTP_METHOD_POST "post"
-#define rustg_http_request_blocking(method, url, body, headers) LIBCALL(RUST_G, "http_request_blocking")(method, url, body, headers)
-#define rustg_http_request_async(method, url, body, headers) LIBCALL(RUST_G, "http_request_async")(method, url, body, headers)
-#define rustg_http_check_request(req_id) LIBCALL(RUST_G, "http_check_request")(req_id)
+#define rustg_http_request_blocking(method, url, body, headers, options) RUSTG_CALL(RUST_G, "http_request_blocking")(method, url, body, headers, options)
+#define rustg_http_request_async(method, url, body, headers, options) RUSTG_CALL(RUST_G, "http_request_async")(method, url, body, headers, options)
+#define rustg_http_check_request(req_id) RUSTG_CALL(RUST_G, "http_check_request")(req_id)
+
+#define RUSTG_JOB_NO_RESULTS_YET "NO RESULTS YET"
+#define RUSTG_JOB_NO_SUCH_JOB "NO SUCH JOB"
+#define RUSTG_JOB_ERROR "JOB PANICKED"
+
+#define rustg_json_is_valid(text) (RUSTG_CALL(RUST_G, "json_is_valid")(text) == "true")
+
+#define rustg_log_write(fname, text, format) LIBCALL(RUST_G, "log_write")(fname, text, format)
+/proc/rustg_log_close_all() return LIBCALL(RUST_G, "log_close_all")()
+
+#define rustg_noise_get_at_coordinates(seed, x, y) RUSTG_CALL(RUST_G, "noise_get_at_coordinates")(seed, x, y)
+
+/*
+ * Takes in a string and json_encode()"d lists to produce a sanitized string.
+ * This function operates on whitelists, there is currently no way to blacklist.
+ * Args:
+ * * text: the string to sanitize.
+ * * attribute_whitelist_json: a json_encode()'d list of HTML attributes to allow in the final string.
+ * * tag_whitelist_json: a json_encode()'d list of HTML tags to allow in the final string.
+ */
+#define rustg_sanitize_html(text, attribute_whitelist_json, tag_whitelist_json) RUSTG_CALL(RUST_G, "sanitize_html")(text, attribute_whitelist_json, tag_whitelist_json)
#define rustg_sql_connect_pool(options) LIBCALL(RUST_G, "sql_connect_pool")(options)
#define rustg_sql_query_async(handle, query, params) LIBCALL(RUST_G, "sql_query_async")(handle, query, params)
@@ -101,3 +128,37 @@
#define rustg_sql_connected(handle) LIBCALL(RUST_G, "sql_connected")(handle)
#define rustg_sql_disconnect_pool(handle) LIBCALL(RUST_G, "sql_disconnect_pool")(handle)
#define rustg_sql_check_query(job_id) LIBCALL(RUST_G, "sql_check_query")("[job_id]")
+
+#define rustg_time_microseconds(id) text2num(RUSTG_CALL(RUST_G, "time_microseconds")(id))
+#define rustg_time_milliseconds(id) text2num(RUSTG_CALL(RUST_G, "time_milliseconds")(id))
+#define rustg_time_reset(id) RUSTG_CALL(RUST_G, "time_reset")(id)
+
+/// Returns the timestamp as a string
+/proc/rustg_unix_timestamp()
+ return RUSTG_CALL(RUST_G, "unix_timestamp")()
+
+#define rustg_raw_read_toml_file(path) json_decode(RUSTG_CALL(RUST_G, "toml_file_to_json")(path) || "null")
+
+/proc/rustg_read_toml_file(path)
+ var/list/output = rustg_raw_read_toml_file(path)
+ if (output["success"])
+ return json_decode(output["content"])
+ else
+ CRASH(output["content"])
+
+#define rustg_raw_toml_encode(value) json_decode(RUSTG_CALL(RUST_G, "toml_encode")(json_encode(value)))
+
+/proc/rustg_toml_encode(value)
+ var/list/output = rustg_raw_toml_encode(value)
+ if (output["success"])
+ return output["content"]
+ else
+ CRASH(output["content"])
+
+#define rustg_url_encode(text) RUSTG_CALL(RUST_G, "url_encode")("[text]")
+#define rustg_url_decode(text) RUSTG_CALL(RUST_G, "url_decode")(text)
+
+#ifdef RUSTG_OVERRIDE_BUILTINS
+ #define url_encode(text) rustg_url_encode(text)
+ #define url_decode(text) rustg_url_decode(text)
+#endif
diff --git a/code/_global_vars/configuration.dm b/code/_global_vars/configuration.dm
new file mode 100644
index 0000000000..7aa2272fe9
--- /dev/null
+++ b/code/_global_vars/configuration.dm
@@ -0,0 +1,5 @@
+// See initialization order in /code/game/world.dm
+// GLOBAL_REAL(config, /datum/controller/configuration)
+GLOBAL_REAL(config, /datum/controller/configuration) = new
+
+GLOBAL_DATUM_INIT(revdata, /datum/getrev, new)
diff --git a/code/_global_vars/sensitive.dm b/code/_global_vars/sensitive.dm
deleted file mode 100644
index 8de09f4f3a..0000000000
--- a/code/_global_vars/sensitive.dm
+++ /dev/null
@@ -1,11 +0,0 @@
-// MySQL configuration
-GLOBAL_REAL_VAR(sqladdress) = "localhost"
-GLOBAL_REAL_VAR(sqlport) = "3306"
-GLOBAL_REAL_VAR(sqldb) = "tgstation"
-GLOBAL_REAL_VAR(sqllogin) = "root"
-GLOBAL_REAL_VAR(sqlpass) = ""
-// Feedback gathering sql connection
-GLOBAL_REAL_VAR(sqlfdbkdb) = "test"
-GLOBAL_REAL_VAR(sqlfdbklogin) = "root"
-GLOBAL_REAL_VAR(sqlfdbkpass) = ""
-GLOBAL_REAL_VAR(sqllogging) = 0 // Should we log deaths, population stats, etc.?
diff --git a/code/_helpers/_lists.dm b/code/_helpers/_lists.dm
index 00f1e9ba9c..e245198f81 100644
--- a/code/_helpers/_lists.dm
+++ b/code/_helpers/_lists.dm
@@ -15,6 +15,12 @@
* Misc
*/
+/// Returns the top (last) element from the list, does not remove it from the list. Stack functionality.
+/proc/peek(list/target_list)
+ var/list_length = length(target_list)
+ if(list_length != 0)
+ return target_list[list_length]
+
//Returns a list in plain english as a string
/proc/english_list(var/list/input, nothing_text = "nothing", and_text = " and ", comma_text = ", ", final_comma_text = ",")
// this proc cannot be merged with counting_english_list to maintain compatibility
diff --git a/code/_helpers/logging.dm b/code/_helpers/logging.dm
index 57795108c7..d016b7111d 100644
--- a/code/_helpers/logging.dm
+++ b/code/_helpers/logging.dm
@@ -27,21 +27,21 @@
/proc/log_admin(text)
admin_log.Add(text)
- if (config.log_admin)
+ if (CONFIG_GET(flag/log_admin))
WRITE_LOG(diary, "ADMIN: [text]")
/proc/log_adminpm(text, client/source, client/dest)
admin_log.Add(text)
- if (config.log_admin)
+ if (CONFIG_GET(flag/log_admin))
WRITE_LOG(diary, "ADMINPM: [key_name(source)]->[key_name(dest)]: [html_decode(text)]")
/proc/log_pray(text, client/source)
admin_log.Add(text)
- if (config.log_admin)
+ if (CONFIG_GET(flag/log_admin))
WRITE_LOG(diary, "PRAY: [key_name(source)]: [text]")
/proc/log_debug(text)
- if (config.log_debug)
+ if (CONFIG_GET(flag/log_debug))
WRITE_LOG(debug_log, "DEBUG: [sanitize(text)]")
for(var/client/C in GLOB.admins)
@@ -51,25 +51,25 @@
html = span_filter_debuglogs("DEBUG: [text]"))
/proc/log_game(text)
- if (config.log_game)
+ if (CONFIG_GET(flag/log_game))
WRITE_LOG(diary, "GAME: [text]")
/proc/log_vote(text)
- if (config.log_vote)
+ if (CONFIG_GET(flag/log_vote))
WRITE_LOG(diary, "VOTE: [text]")
/proc/log_access_in(client/new_client)
- if (config.log_access)
+ if (CONFIG_GET(flag/log_access))
var/message = "[key_name(new_client)] - IP:[new_client.address] - CID:[new_client.computer_id] - BYOND v[new_client.byond_version]"
WRITE_LOG(diary, "ACCESS IN: [message]") //VOREStation Edit
/proc/log_access_out(mob/last_mob)
- if (config.log_access)
+ if (CONFIG_GET(flag/log_access))
var/message = "[key_name(last_mob)] - IP:[last_mob.lastKnownIP] - CID:Logged Out - BYOND Logged Out"
WRITE_LOG(diary, "ACCESS OUT: [message]")
/proc/log_say(text, mob/speaker)
- if (config.log_say)
+ if (CONFIG_GET(flag/log_say))
WRITE_LOG(diary, "SAY: [speaker.simple_info_line()]: [html_decode(text)]")
//Log the message to in-game dialogue logs, as well.
@@ -78,25 +78,25 @@
GLOB.round_text_log += span_bold("([time_stamp()])") + " (" + span_bold("[speaker]/[speaker.client]") + ") " + span_underline("SAY:") + " - " + span_green("[text]")
/proc/log_ooc(text, client/user)
- if (config.log_ooc)
+ if (CONFIG_GET(flag/log_ooc))
WRITE_LOG(diary, "OOC: [user.simple_info_line()]: [html_decode(text)]")
GLOB.round_text_log += span_bold("([time_stamp()])") + " (" + span_bold("[user]") + ") " + span_underline("OOC:") + " - " + span_blue(span_bold("[text]"))
/proc/log_aooc(text, client/user)
- if (config.log_ooc)
+ if (CONFIG_GET(flag/log_ooc))
WRITE_LOG(diary, "AOOC: [user.simple_info_line()]: [html_decode(text)]")
GLOB.round_text_log += span_bold("([time_stamp()])") + " (" + span_bold("[user]") + ") " + span_underline("AOOC:") + " - " + span_red(span_bold("[text]"))
/proc/log_looc(text, client/user)
- if (config.log_ooc)
+ if (CONFIG_GET(flag/log_ooc))
WRITE_LOG(diary, "LOOC: [user.simple_info_line()]: [html_decode(text)]")
GLOB.round_text_log += span_bold("([time_stamp()])") + " (" + span_bold("[user]") + ") " + span_underline("LOOC:") + " - " + span_orange(span_bold("[text]"))
/proc/log_whisper(text, mob/speaker)
- if (config.log_whisper)
+ if (CONFIG_GET(flag/log_whisper))
WRITE_LOG(diary, "WHISPER: [speaker.simple_info_line()]: [html_decode(text)]")
if(speaker.client)
@@ -104,7 +104,7 @@
GLOB.round_text_log += span_bold("([time_stamp()])") + " (" + span_bold("[speaker]/[speaker.client]") + ") " + span_underline("SAY:") + " - " + span_gray(span_italics("[text]"))
/proc/log_emote(text, mob/speaker)
- if (config.log_emote)
+ if (CONFIG_GET(flag/log_emote))
WRITE_LOG(diary, "EMOTE: [speaker.simple_info_line()]: [html_decode(text)]")
if(speaker.client)
@@ -112,38 +112,38 @@
GLOB.round_text_log += span_bold("([time_stamp()])") + " (" + span_bold("[speaker]/[speaker.client]") + ") " + span_underline("EMOTE:") + " - " + span_pink("[text]")
/proc/log_attack(attacker, defender, message)
- if (config.log_attack)
+ if (CONFIG_GET(flag/log_attack))
WRITE_LOG(diary, "ATTACK: [attacker] against [defender]: [message]")
/proc/log_adminsay(text, mob/speaker)
- if (config.log_adminchat)
+ if (CONFIG_GET(flag/log_adminchat))
WRITE_LOG(diary, "ADMINSAY: [speaker.simple_info_line()]: [html_decode(text)]")
/proc/log_modsay(text, mob/speaker)
- if (config.log_adminchat)
+ if (CONFIG_GET(flag/log_adminchat))
WRITE_LOG(diary, "MODSAY: [speaker.simple_info_line()]: [html_decode(text)]")
/proc/log_eventsay(text, mob/speaker)
- if (config.log_adminchat)
+ if (CONFIG_GET(flag/log_adminchat))
WRITE_LOG(diary, "EVENTSAY: [speaker.simple_info_line()]: [html_decode(text)]")
/proc/log_ghostsay(text, mob/speaker)
- if (config.log_say)
+ if (CONFIG_GET(flag/log_say))
WRITE_LOG(diary, "DEADCHAT: [speaker.simple_info_line()]: [html_decode(text)]")
speaker.dialogue_log += span_bold("([time_stamp()])") + " (" + span_bold("[speaker]/[speaker.client]") + ") " + span_underline("DEADSAY:") + " - " + span_green("[text]")
GLOB.round_text_log += span_small(span_purple(span_bold("([time_stamp()])") + " (" + span_bold("[speaker]/[speaker.client]") + ") " + span_underline("DEADSAY:") + " - [text]"))
/proc/log_ghostemote(text, mob/speaker)
- if (config.log_emote)
+ if (CONFIG_GET(flag/log_emote))
WRITE_LOG(diary, "DEADEMOTE: [speaker.simple_info_line()]: [html_decode(text)]")
/proc/log_adminwarn(text)
- if (config.log_adminwarn)
+ if (CONFIG_GET(flag/log_adminwarn))
WRITE_LOG(diary, "ADMINWARN: [html_decode(text)]")
/proc/log_pda(text, mob/speaker)
- if (config.log_pda)
+ if (CONFIG_GET(flag/log_pda))
WRITE_LOG(diary, "PDA: [speaker.simple_info_line()]: [html_decode(text)]")
speaker.dialogue_log += span_bold("([time_stamp()])") + " (" + span_bold("[speaker]/[speaker.client]") + ") " + span_underline("MSG:") + " - " + span_darkgreen("[text]")
@@ -151,7 +151,7 @@
/proc/log_to_dd(text)
to_world_log(text) //this comes before the config check because it can't possibly runtime
- if(config.log_world_output)
+ if(CONFIG_GET(flag/log_world_output))
WRITE_LOG(diary, "DD_OUTPUT: [text]")
/proc/log_error(text)
diff --git a/code/_helpers/logging/debug.dm b/code/_helpers/logging/debug.dm
new file mode 100644
index 0000000000..9a847ee61b
--- /dev/null
+++ b/code/_helpers/logging/debug.dm
@@ -0,0 +1,11 @@
+/// Logging for config errors
+/// Rarely gets called; just here in case the config breaks.
+/proc/log_config(text, list/data)
+ var/entry = "CONFIG: "
+
+ entry += text
+ entry += " | DATA: "
+ entry += data
+
+ WRITE_LOG(diary, entry)
+ SEND_TEXT(world.log, text)
diff --git a/code/_helpers/logging_vr.dm b/code/_helpers/logging_vr.dm
index aa117125dc..b0bf8d07e7 100644
--- a/code/_helpers/logging_vr.dm
+++ b/code/_helpers/logging_vr.dm
@@ -1,11 +1,11 @@
/proc/log_nsay(text, inside, mob/speaker)
- if (config.log_say)
+ if (CONFIG_GET(flag/log_say))
WRITE_LOG(diary, "NSAY (NIF:[inside]): [speaker.simple_info_line()]: [html_decode(text)]")
/proc/log_nme(text, inside, mob/speaker)
- if (config.log_emote)
+ if (CONFIG_GET(flag/log_emote))
WRITE_LOG(diary, "NME (NIF:[inside]): [speaker.simple_info_line()]: [html_decode(text)]")
/proc/log_subtle(text, mob/speaker)
- if (config.log_emote)
+ if (CONFIG_GET(flag/log_emote))
WRITE_LOG(diary, "SUBTLE: [speaker.simple_info_line()]: [html_decode(text)]")
diff --git a/code/_helpers/mobs.dm b/code/_helpers/mobs.dm
index d4a29095b8..e78123fe64 100644
--- a/code/_helpers/mobs.dm
+++ b/code/_helpers/mobs.dm
@@ -317,7 +317,7 @@ Proc for attack log creation, because really why not
cached_character_icons[cachekey] = .
/proc/not_has_ooc_text(mob/user)
- if (config.allow_Metadata && (!user.client?.prefs?.metadata || length(user.client.prefs.metadata) < 15))
+ if (CONFIG_GET(flag/allow_metadata) && (!user.client?.prefs?.metadata || length(user.client.prefs.metadata) < 15))
to_chat(user, span_warning("Please set informative OOC notes related to RP/ERP preferences. Set them using the 'OOC Notes' button on the 'General' tab in character setup."))
return TRUE
return FALSE
diff --git a/code/_helpers/nameof.dm b/code/_helpers/nameof.dm
new file mode 100644
index 0000000000..5a2fd60e71
--- /dev/null
+++ b/code/_helpers/nameof.dm
@@ -0,0 +1,11 @@
+/**
+ * NAMEOF: Compile time checked variable name to string conversion
+ * evaluates to a string equal to "X", but compile errors if X isn't a var on datum.
+ * datum may be null, but it does need to be a typed var.
+ **/
+#define NAMEOF(datum, X) (#X || ##datum.##X)
+
+/**
+ * NAMEOF that actually works in static definitions because src::type requires src to be defined
+ */
+#define NAMEOF_STATIC(datum, X) (nameof(type::##X))
diff --git a/code/_helpers/names.dm b/code/_helpers/names.dm
index 12e6c46289..12d2c08e86 100644
--- a/code/_helpers/names.dm
+++ b/code/_helpers/names.dm
@@ -92,8 +92,8 @@ var/religion_name = null
new_station_name += pick("13","XIII","Thirteen")
- if (config && config.server_name)
- world.name = "[config.server_name]: [name]"
+ if (config && CONFIG_GET(string/servername))
+ world.name = "[CONFIG_GET(string/servername)]: [name]"
else
world.name = new_station_name
@@ -104,8 +104,8 @@ var/religion_name = null
using_map.station_name = name
- if (config && config.server_name)
- world.name = "[config.server_name]: [name]"
+ if (config && CONFIG_GET(string/servername))
+ world.name = "[CONFIG_GET(string/servername)]: [name]"
else
world.name = name
diff --git a/code/_helpers/text.dm b/code/_helpers/text.dm
index 4d8968ad4e..520b98d39a 100644
--- a/code/_helpers/text.dm
+++ b/code/_helpers/text.dm
@@ -613,3 +613,10 @@
paper_text = replacetext(paper_text, "
", "\n")
paper_text = strip_html_properly(paper_text) // Get rid of everything else entirely.
return paper_text
+
+//json decode that will return null on parse error instead of runtiming.
+/proc/safe_json_decode(data)
+ try
+ return json_decode(data)
+ catch
+ return null
diff --git a/code/_helpers/type2type.dm b/code/_helpers/type2type.dm
index c9dffc7c2b..0e0dd58295 100644
--- a/code/_helpers/type2type.dm
+++ b/code/_helpers/type2type.dm
@@ -1,11 +1,41 @@
/*
* Holds procs designed to change one type of value, into another.
* Contains:
+ * file2list
+ * type2top
* hex2num & num2hex
* file2list
* angle2dir
*/
+//Splits the text of a file at seperator and returns them in a list.
+//returns an empty list if the file doesn't exist
+/world/proc/file2list(filename, seperator="\n", trim = TRUE)
+ if (trim)
+ return splittext(trim(file2text(filename)),seperator)
+ return splittext(file2text(filename),seperator)
+
+//returns a string the last bit of a type, without the preceeding '/'
+/proc/type2top(the_type)
+ //handle the builtins manually
+ if(!ispath(the_type))
+ return
+ switch(the_type)
+ if(/datum)
+ return "datum"
+ if(/atom)
+ return "atom"
+ if(/obj)
+ return "obj"
+ if(/mob)
+ return "mob"
+ if(/area)
+ return "area"
+ if(/turf)
+ return "turf"
+ else //regex everything else (works for /proc too)
+ return lowertext(replacetext("[the_type]", "[type2parent(the_type)]/", ""))
+
// Returns an integer given a hexadecimal number string as input.
/proc/hex2num(hex)
if (!istext(hex))
diff --git a/code/_helpers/unsorted.dm b/code/_helpers/unsorted.dm
index c18a512db2..057f988dcb 100644
--- a/code/_helpers/unsorted.dm
+++ b/code/_helpers/unsorted.dm
@@ -1359,9 +1359,6 @@ var/mob/dview/dview_mob = new
#undef NOT_FLAG
#undef HAS_FLAG
-//datum may be null, but it does need to be a typed var
-#define NAMEOF(datum, X) (#X || ##datum.##X)
-
#define VARSET_LIST_CALLBACK(target, var_name, var_value) CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(___callbackvarset), ##target, ##var_name, ##var_value)
//dupe code because dm can't handle 3 level deep macros
#define VARSET_CALLBACK(datum, var, var_value) CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(___callbackvarset), ##datum, NAMEOF(##datum, ##var), ##var_value)
diff --git a/code/_helpers/unsorted_vr.dm b/code/_helpers/unsorted_vr.dm
index 0890c1f9c6..88c6dba1b2 100644
--- a/code/_helpers/unsorted_vr.dm
+++ b/code/_helpers/unsorted_vr.dm
@@ -43,26 +43,26 @@
//Sender is optional
/proc/admin_chat_message(var/message = "Debug Message", var/color = "#FFFFFF", var/sender)
- if (!config.chat_webhook_url || !message)
+ if (!CONFIG_GET(string/chat_webhook_url) || !message)
return
spawn(0)
var/query_string = "type=adminalert"
- query_string += "&key=[url_encode(config.chat_webhook_key)]"
+ query_string += "&key=[url_encode(CONFIG_GET(string/chat_webhook_key))]"
query_string += "&msg=[url_encode(message)]"
query_string += "&color=[url_encode(color)]"
if(sender)
query_string += "&from=[url_encode(sender)]"
- world.Export("[config.chat_webhook_url]?[query_string]")
+ world.Export("[CONFIG_GET(string/chat_webhook_url)]?[query_string]")
/proc/admin_action_message(var/admin = "INVALID", var/user = "INVALID", var/action = "INVALID", var/reason = "INVALID", var/time = "INVALID")
- if (!config.chat_webhook_url || !action)
+ if (!CONFIG_GET(string/chat_webhook_url) || !action)
return
spawn(0)
var/query_string = "type=adminaction"
- query_string += "&key=[url_encode(config.chat_webhook_key)]"
+ query_string += "&key=[url_encode(CONFIG_GET(string/chat_webhook_key))]"
query_string += "&admin=[url_encode(admin)]"
query_string += "&user=[url_encode(user)]"
query_string += "&action=[url_encode(action)]"
query_string += "&reason=[url_encode(reason)]"
query_string += "&time=[url_encode(time)]"
- world.Export("[config.chat_webhook_url]?[query_string]")
+ world.Export("[CONFIG_GET(string/chat_webhook_url)]?[query_string]")
diff --git a/code/_onclick/click.dm b/code/_onclick/click.dm
index 3562ed09a7..f321d231f3 100644
--- a/code/_onclick/click.dm
+++ b/code/_onclick/click.dm
@@ -158,7 +158,7 @@
next_click = max(world.time + timeout, next_click)
/mob/proc/checkClickCooldown()
- if(next_click > world.time && !config.no_click_cooldown)
+ if(next_click > world.time && !CONFIG_GET(flag/no_click_cooldown))
return FALSE
return TRUE
diff --git a/code/controllers/autotransfer.dm b/code/controllers/autotransfer.dm
index d303142886..6bc2bd6daf 100644
--- a/code/controllers/autotransfer.dm
+++ b/code/controllers/autotransfer.dm
@@ -6,9 +6,9 @@ var/datum/controller/transfer_controller/transfer_controller
var/shift_hard_end = 0 //VOREStation Edit
var/shift_last_vote = 0 //VOREStation Edit
/datum/controller/transfer_controller/New()
- timerbuffer = config.vote_autotransfer_initial
- shift_hard_end = config.vote_autotransfer_initial + (config.vote_autotransfer_interval * 0) //VOREStation Edit //Change this "1" to how many extend votes you want there to be.
- shift_last_vote = shift_hard_end - config.vote_autotransfer_interval //VOREStation Edit
+ timerbuffer = CONFIG_GET(number/vote_autotransfer_initial)
+ shift_hard_end = CONFIG_GET(number/vote_autotransfer_initial) + (CONFIG_GET(number/vote_autotransfer_interval) * 0) //VOREStation Edit //Change this "1" to how many extend votes you want there to be.
+ shift_last_vote = shift_hard_end - CONFIG_GET(number/vote_autotransfer_interval) //VOREStation Edit
START_PROCESSING(SSprocessing, src)
/datum/controller/transfer_controller/Destroy()
@@ -22,9 +22,9 @@ var/datum/controller/transfer_controller/transfer_controller
to_world(span_world(span_notice("Warning: You have one hour left in the shift. Wrap up your scenes in the next 60 minutes before the transfer is called."))) //VOREStation Edit
if (round_duration_in_ds >= shift_hard_end - 1 MINUTE)
init_shift_change(null, 1)
- shift_hard_end = timerbuffer + config.vote_autotransfer_interval //If shuttle somehow gets recalled, let's force it to call again next time a vote would occur.
- timerbuffer = timerbuffer + config.vote_autotransfer_interval //Just to make sure a vote doesn't occur immediately afterwords.
+ shift_hard_end = timerbuffer + CONFIG_GET(number/vote_autotransfer_interval) //If shuttle somehow gets recalled, let's force it to call again next time a vote would occur.
+ timerbuffer = timerbuffer + CONFIG_GET(number/vote_autotransfer_interval) //Just to make sure a vote doesn't occur immediately afterwords.
else if (round_duration_in_ds >= timerbuffer - 1 MINUTE)
SSvote.start_vote(new /datum/vote/crew_transfer)
//VOREStation Edit END
- timerbuffer = timerbuffer + config.vote_autotransfer_interval
+ timerbuffer = timerbuffer + CONFIG_GET(number/vote_autotransfer_interval)
diff --git a/code/controllers/configuration/config_entry.dm b/code/controllers/configuration/config_entry.dm
new file mode 100644
index 0000000000..b279bc52c9
--- /dev/null
+++ b/code/controllers/configuration/config_entry.dm
@@ -0,0 +1,300 @@
+/datum/config_entry
+ /// Read-only, this is determined by the last portion of the derived entry type
+ var/name
+ /// The configured value for this entry. This shouldn't be initialized in code, instead set default
+ var/config_entry_value
+ /// Read-only default value for this config entry, used for resetting value to defaults when necessary. This is what config_entry_value is initially set to
+ var/default
+ /// The file which this was loaded from, if any
+ var/resident_file
+ /// Set to TRUE if the default has been overridden by a config entry
+ var/modified = FALSE
+ /// The config name of a configuration type that depricates this, if it exists
+ var/deprecated_by
+ /// The /datum/config_entry type that supercedes this one
+ var/protection = NONE
+ /// Do not instantiate if type matches this
+ var/config_abstract_type = /datum/config_entry
+ /// Force validate and set on VV. VAS proccall guard will run regardless.
+ var/vv_VAS = TRUE
+ /// Controls if error is thrown when duplicate configuration values for this entry type are encountered
+ var/dupes_allowed = FALSE
+ /// Stores the original protection configuration, used for set_default()
+ var/default_protection
+
+/datum/config_entry/New()
+ if(type == config_abstract_type)
+ CRASH("Abstract config entry [type] instatiated!")
+ name = lowertext(type2top(type))
+ default_protection = protection
+ set_default()
+
+/datum/config_entry/Destroy()
+ config.RemoveEntry(src)
+ return ..()
+
+/**
+ * Returns the value of the configuration datum to its default, used for resetting a config value. Note this also sets the protection back to default.
+ */
+/datum/config_entry/proc/set_default()
+ if ((protection & CONFIG_ENTRY_LOCKED) && IsAdminAdvancedProcCall())
+ //log_admin_private("[key_name(usr)] attempted to reset locked config entry [type] to its default")
+ log_admin("[key_name(usr)] attempted to reset locked config entry [type] to its default")
+ return
+ if (islist(default))
+ var/list/L = default
+ config_entry_value = L.Copy()
+ else
+ config_entry_value = default
+ protection = default_protection
+ resident_file = null
+ modified = FALSE
+
+/datum/config_entry/can_vv_get(var_name)
+ . = ..()
+ if(var_name == NAMEOF(src, config_entry_value) || var_name == NAMEOF(src, default))
+ . &= !(protection & CONFIG_ENTRY_HIDDEN)
+
+/datum/config_entry/vv_edit_var(var_name, var_value)
+ var/static/list/banned_edits = list(NAMEOF_STATIC(src, name), NAMEOF_STATIC(src, vv_VAS), NAMEOF_STATIC(src, default), NAMEOF_STATIC(src, resident_file), NAMEOF_STATIC(src, protection), NAMEOF_STATIC(src, config_abstract_type), NAMEOF_STATIC(src, modified), NAMEOF_STATIC(src, dupes_allowed))
+ if(var_name == NAMEOF(src, config_entry_value))
+ if(protection & CONFIG_ENTRY_LOCKED)
+ return FALSE
+ if(vv_VAS)
+ . = ValidateAndSet("[var_value]")
+ if(.)
+ datum_flags |= DF_VAR_EDITED
+ return
+ else
+ return ..()
+ if(var_name in banned_edits)
+ return FALSE
+ return ..()
+
+/datum/config_entry/proc/VASProcCallGuard(str_val)
+ . = !((protection & CONFIG_ENTRY_LOCKED) && IsAdminAdvancedProcCall())
+ if(!.)
+ //log_admin_private("[key_name(usr)] attempted to set locked config entry [type] to '[str_val]'")
+ log_admin("[key_name(usr)] attempted to set locked config entry [type] to '[str_val]'")
+
+/datum/config_entry/proc/ValidateAndSet(str_val)
+ VASProcCallGuard(str_val)
+ CRASH("Invalid config entry type!")
+
+/datum/config_entry/proc/ValidateListEntry(key_name, key_value)
+ return TRUE
+
+/datum/config_entry/proc/DeprecationUpdate(value)
+ return
+
+/datum/config_entry/string
+ default = ""
+ config_abstract_type = /datum/config_entry/string
+ var/auto_trim = TRUE
+ /// whether the string will be lowercased on ValidateAndSet or not.
+ var/lowercase = FALSE
+
+/datum/config_entry/string/vv_edit_var(var_name, var_value)
+ return var_name != NAMEOF(src, auto_trim) && ..()
+
+/datum/config_entry/string/ValidateAndSet(str_val)
+ if(!VASProcCallGuard(str_val))
+ return FALSE
+ config_entry_value = auto_trim ? trim(str_val) : str_val
+ if(lowercase)
+ config_entry_value = lowertext(config_entry_value)
+ return TRUE
+
+/datum/config_entry/number
+ default = 0
+ config_abstract_type = /datum/config_entry/number
+ var/integer = TRUE
+ var/max_val = INFINITY
+ var/min_val = -INFINITY
+
+/datum/config_entry/number/ValidateAndSet(str_val)
+ if(!VASProcCallGuard(str_val))
+ return FALSE
+ var/temp = text2num(trim(str_val))
+ if(!isnull(temp))
+ config_entry_value = clamp(integer ? round(temp) : temp, min_val, max_val)
+ if(config_entry_value != temp && !(datum_flags & DF_VAR_EDITED))
+ log_config("Changing [name] from [temp] to [config_entry_value]!")
+ return TRUE
+ return FALSE
+
+/datum/config_entry/number/vv_edit_var(var_name, var_value)
+ var/static/list/banned_edits = list(NAMEOF_STATIC(src, max_val), NAMEOF_STATIC(src, min_val), NAMEOF_STATIC(src, integer))
+ return !(var_name in banned_edits) && ..()
+
+/datum/config_entry/flag
+ default = FALSE
+ config_abstract_type = /datum/config_entry/flag
+
+/datum/config_entry/flag/ValidateAndSet(str_val)
+ if(!VASProcCallGuard(str_val))
+ return FALSE
+ config_entry_value = text2num(trim(str_val)) != 0
+ return TRUE
+
+/// List config entry, used for configuring a list of strings
+/datum/config_entry/str_list
+ config_abstract_type = /datum/config_entry/str_list
+ default = list()
+ dupes_allowed = TRUE
+ /// whether the string elements will be lowercased on ValidateAndSet or not.
+ var/lowercase = FALSE
+
+/datum/config_entry/str_list/ValidateAndSet(str_val)
+ if (!VASProcCallGuard(str_val))
+ return FALSE
+ str_val = trim(str_val)
+ if (str_val != "")
+ config_entry_value += lowercase ? lowertext(str_val) : str_val
+ return TRUE
+
+/datum/config_entry/number_list
+ config_abstract_type = /datum/config_entry/number_list
+ default = list()
+
+/datum/config_entry/number_list/ValidateAndSet(str_val)
+ if(!VASProcCallGuard(str_val))
+ return FALSE
+ str_val = trim(str_val)
+ var/list/new_list = list()
+ var/list/values = splittext(str_val," ")
+ for(var/I in values)
+ var/temp = text2num(I)
+ if(isnull(temp))
+ return FALSE
+ new_list += temp
+ if(!new_list.len)
+ return FALSE
+ config_entry_value = new_list
+ return TRUE
+
+/datum/config_entry/keyed_list
+ config_abstract_type = /datum/config_entry/keyed_list
+ default = list()
+ dupes_allowed = TRUE
+ vv_VAS = FALSE //VAS will not allow things like deleting from lists, it'll just bug horribly.
+ var/key_mode
+ var/value_mode
+ var/splitter = " "
+ /// whether the key names will be lowercased on ValidateAndSet or not.
+ var/lowercase_key = TRUE
+
+/datum/config_entry/keyed_list/New()
+ . = ..()
+ if(isnull(key_mode) || isnull(value_mode))
+ CRASH("Keyed list of type [type] created with null key or value mode!")
+
+/datum/config_entry/keyed_list/ValidateAndSet(str_val)
+ if(!VASProcCallGuard(str_val))
+ return FALSE
+
+ str_val = trim(str_val)
+
+ var/list/new_entry = parse_key_and_value(str_val)
+
+ var/new_key = new_entry["config_key"]
+ var/new_value = new_entry["config_value"]
+
+ if(!isnull(new_value) && !isnull(new_key) && ValidateListEntry(new_key, new_value))
+ config_entry_value[new_key] = new_value
+ return TRUE
+ return FALSE
+
+/datum/config_entry/keyed_list/proc/parse_key_and_value(option_string)
+ // Blank or null option string? Bad mojo!
+ if(!option_string)
+ log_config("ERROR: Keyed list config tried to parse with no key or value data.")
+ return null
+
+ var/list/config_entry_words = splittext(option_string, splitter)
+ var/config_value
+ var/config_key
+ var/is_ambiguous = FALSE
+
+ // If this config entry's value mode is flag, the value can either be TRUE or FALSE.
+ // However, the config supports implicitly setting a config entry to TRUE by omitting the value.
+ // This value mode should also support config overrides disabling it too.
+ // The following code supports config entries as such:
+ // Implicitly enable the config entry: CONFIG_ENTRY config key goes here
+ // Explicitly enable the config entry: CONFIG_ENTRY config key goes here 1
+ // Explicitly disable the config entry: CONFIG_ENTRY config key goes here 0
+ if(value_mode == VALUE_MODE_FLAG)
+ var/value = peek(config_entry_words)
+ config_value = TRUE
+
+ if(value == "0")
+ config_key = jointext(config_entry_words, splitter, length(config_entry_words) - 1)
+ config_value = FALSE
+ is_ambiguous = (length(config_entry_words) > 2)
+ else if(value == "1")
+ config_key = jointext(config_entry_words, splitter, length(config_entry_words) - 1)
+ is_ambiguous = (length(config_entry_words) > 2)
+ else
+ config_key = option_string
+ is_ambiguous = (length(config_entry_words) > 1)
+ // Else it has to be a key value pair and we parse it under that assumption.
+ else
+ // If config_entry_words only has 1 or 0 words in it and isn't value_mode == VALUE_MODE_FLAG then it's an invalid config entry.
+ if(length(config_entry_words) <= 1)
+ log_config("ERROR: Could not parse value from config entry string: [option_string]")
+ return null
+
+ config_value = pop(config_entry_words)
+ config_key = jointext(config_entry_words, splitter)
+
+ if(lowercase_key)
+ config_key = lowertext(config_key)
+
+ is_ambiguous = (length(config_entry_words) > 2)
+
+ config_key = validate_config_key(config_key)
+ config_value = validate_config_value(config_value)
+
+ // If there are multiple splitters, it's definitely ambiguous and we'll warn about how we parsed it. Helps with debugging config issues.
+ if(is_ambiguous)
+ log_config("WARNING: Multiple splitter characters (\"[splitter]\") found. Using \"[config_key]\" as config key and \"[config_value]\" as config value.")
+
+ return list("config_key" = config_key, "config_value" = config_value)
+
+/// Takes a given config key and validates it. If successful, returns the formatted key. If unsuccessful, returns null.
+/datum/config_entry/keyed_list/proc/validate_config_key(key)
+ switch(key_mode)
+ if(KEY_MODE_TEXT)
+ return key
+ if(KEY_MODE_TYPE)
+ if(ispath(key))
+ return key
+
+ var/key_path = text2path(key)
+ if(isnull(key_path))
+ log_config("ERROR: Invalid KEY_MODE_TYPE typepath. Is not a valid typepath: [key]")
+ return
+
+ return key_path
+
+
+/// Takes a given config value and validates it. If successful, returns the formatted key. If unsuccessful, returns null.
+/datum/config_entry/keyed_list/proc/validate_config_value(value)
+ switch(value_mode)
+ if(VALUE_MODE_FLAG)
+ return value
+ if(VALUE_MODE_NUM)
+ if(isnum(value))
+ return value
+
+ var/value_num = text2num(value)
+ if(isnull(value_num))
+ log_config("ERROR: Invalid VALUE_MODE_NUM number. Could not parse a valid number: [value]")
+ return
+
+ return value_num
+ if(VALUE_MODE_TEXT)
+ return value
+
+/datum/config_entry/keyed_list/vv_edit_var(var_name, var_value)
+ return var_name != NAMEOF(src, splitter) && ..()
diff --git a/code/controllers/configuration/configuration.dm b/code/controllers/configuration/configuration.dm
new file mode 100644
index 0000000000..1cba676a0c
--- /dev/null
+++ b/code/controllers/configuration/configuration.dm
@@ -0,0 +1,536 @@
+/datum/controller/configuration
+ name = "Configuration"
+
+ var/directory = "config"
+
+ var/warned_deprecated_configs = FALSE
+ var/hiding_entries_by_type = TRUE //Set for readability, admins can set this to FALSE if they want to debug it
+ var/list/entries
+ var/list/entries_by_type
+
+ //var/list/maplist
+ //var/datum/map_config/defaultmap
+
+ var/list/modes // allowed modes
+ var/list/gamemode_cache
+ var/list/votable_modes // votable modes
+ var/list/mode_names
+ var/list/mode_reports
+ var/list/mode_false_report_weight
+
+ var/motd
+ var/policy
+
+ /// If the configuration is loaded
+ var/loaded = FALSE
+
+ /// A regex that matches words blocked IC
+ var/static/regex/ic_filter_regex
+
+ /// A regex that matches words blocked OOC
+ var/static/regex/ooc_filter_regex
+
+ /// A regex that matches words blocked IC, but not in PDAs
+ var/static/regex/ic_outside_pda_filter_regex
+
+ /// A regex that matches words soft blocked IC
+ var/static/regex/soft_ic_filter_regex
+
+ /// A regex that matches words soft blocked OOC
+ var/static/regex/soft_ooc_filter_regex
+
+ /// A regex that matches words soft blocked IC, but not in PDAs
+ var/static/regex/soft_ic_outside_pda_filter_regex
+
+ /// An assoc list of blocked IC words to their reasons
+ var/static/list/ic_filter_reasons
+
+ /// An assoc list of words that are blocked IC, but not in PDAs, to their reasons
+ var/static/list/ic_outside_pda_filter_reasons
+
+ /// An assoc list of words that are blocked both IC and OOC to their reasons
+ var/static/list/shared_filter_reasons
+
+ /// An assoc list of soft blocked IC words to their reasons
+ var/static/list/soft_ic_filter_reasons
+
+ /// An assoc list of words that are soft blocked IC, but not in PDAs, to their reasons
+ var/static/list/soft_ic_outside_pda_filter_reasons
+
+ /// An assoc list of words that are soft blocked both IC and OOC to their 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()
+ if(IsAdminAdvancedProcCall())
+ 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/Load(_directory)
+ if(IsAdminAdvancedProcCall()) //If admin proccall is detected down the line it will horribly break everything.
+ return
+ if(_directory)
+ directory = _directory
+ if(entries)
+ CRASH("/datum/controller/configuration/Load() called more than once!")
+ configuration_errors ||= list()
+ InitEntries()
+ 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 $include directives found in config.txt! Loading legacy [legacy_configs.Join("/")] files...")
+ for(var/J in legacy_configs)
+ LoadEntries(J)
+ break
+ if (fexists("[directory]/dev_overrides.txt"))
+ LoadEntries("dev_overrides.txt")
+ if (fexists("[directory]/ezdb.txt"))
+ LoadEntries("ezdb.txt")
+ //loadmaplist(CONFIG_MAPS_FILE)
+ LoadMOTD()
+ LoadPolicy()
+ LoadChatFilter()
+ LoadModes()
+ /*
+ if(CONFIG_GET(flag/load_jobs_from_txt))
+ validate_job_config()
+ if(SSjob.initialized) // in case we're reloading from disk after initialization, wanna make sure the changes update in the ongoing shift
+ SSjob.load_jobs_from_config()
+ */
+
+ if(CONFIG_GET(flag/usewhitelist))
+ load_whitelist()
+
+ loaded = TRUE
+
+ if (Master)
+ Master.OnConfigLoad()
+ process_config_errors()
+
+/datum/controller/configuration/proc/full_wipe()
+ if(IsAdminAdvancedProcCall())
+ return
+ entries_by_type.Cut()
+ QDEL_LIST_ASSOC_VAL(entries)
+ entries = null
+ //QDEL_LIST_ASSOC_VAL(maplist)
+ //maplist = null
+ //QDEL_NULL(defaultmap)
+ configuration_errors?.Cut()
+
+/datum/controller/configuration/Destroy()
+ full_wipe()
+ config = null
+
+ 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()
+ var/list/_entries = list()
+ entries = _entries
+ var/list/_entries_by_type = list()
+ entries_by_type = _entries_by_type
+
+ for(var/I in typesof(/datum/config_entry)) //typesof is faster in this case
+ var/datum/config_entry/E = I
+ if(initial(E.config_abstract_type) == I)
+ continue
+ E = new I
+ var/esname = E.name
+ var/datum/config_entry/test = _entries[esname]
+ if(test)
+ log_config_error("Error: [test.type] has the same name as [E.type]: [esname]! Not initializing [E.type]!")
+ qdel(E)
+ continue
+ _entries[esname] = E
+ _entries_by_type[I] = E
+
+/datum/controller/configuration/proc/RemoveEntry(datum/config_entry/CE)
+ entries -= CE.name
+ entries_by_type -= CE.type
+
+/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_error("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/_entries = entries
+ for(var/L in lines)
+ L = trim(L)
+ if(!L)
+ continue
+
+ var/firstchar = L[1]
+ if(firstchar == "#")
+ continue
+
+ var/lockthis = firstchar == "@"
+ if(lockthis)
+ L = copytext(L, length(firstchar) + 1)
+
+ var/pos = findtext(L, " ")
+ var/entry = null
+ var/value = null
+
+ if(pos)
+ entry = lowertext(copytext(L, 1, pos))
+ value = copytext(L, pos + length(L[pos]))
+ else
+ entry = lowertext(L)
+
+ if(!entry)
+ continue
+
+ if(entry == "$include")
+ if(!value)
+ log_config_error("Warning: Invalid $include directive: [value]")
+ else
+ LoadEntries(value, stack)
+ ++.
+ continue
+
+ // Reset directive, used for setting a config value back to defaults. Useful for string list config types
+ if (entry == "$reset")
+ var/datum/config_entry/resetee = _entries[lowertext(value)]
+ if (!value || !resetee)
+ log_config_error("Warning: invalid $reset directive: [value]")
+ continue
+ resetee.set_default()
+ log_config("Reset configured value for [value] to original defaults")
+ continue
+
+ var/datum/config_entry/E = _entries[entry]
+ if(!E)
+ log_config("Unknown setting in configuration: '[entry]'")
+ continue
+
+ if(lockthis)
+ E.protection |= CONFIG_ENTRY_LOCKED
+
+ if(E.deprecated_by)
+ var/datum/config_entry/new_ver = entries_by_type[E.deprecated_by]
+ var/new_value = E.DeprecationUpdate(value)
+ var/good_update = istext(new_value)
+ log_config("Entry [entry] is deprecated and will be removed soon. Migrate to [new_ver.name]![good_update ? " Suggested new value is: [new_value]" : ""]")
+ if(!warned_deprecated_configs)
+ DelayedMessageAdmins("This server is using deprecated configuration settings. Please check the logs and update accordingly.")
+ warned_deprecated_configs = TRUE
+ if(good_update)
+ value = new_value
+ E = new_ver
+ else
+ warning("[new_ver.type] is deprecated but gave no proper return for DeprecationUpdate()")
+
+ var/validated = E.ValidateAndSet(value)
+ if(!validated)
+ var/log_message = "Failed to validate setting \"[value]\" for [entry]"
+ log_config(log_message)
+ stack_trace(log_message)
+ else
+ if(E.modified && !E.dupes_allowed && E.resident_file == filename)
+ log_config_error("Duplicate setting for [entry] ([value], [E.resident_file]) detected! Using latest.")
+
+ E.resident_file = filename
+
+ if(validated)
+ E.modified = TRUE
+
+ ++.
+
+/datum/controller/configuration/can_vv_get(var_name)
+ return (var_name != NAMEOF(src, entries_by_type) || !hiding_entries_by_type) && ..()
+
+/datum/controller/configuration/vv_edit_var(var_name, var_value)
+ var/list/banned_edits = list(NAMEOF(src, entries_by_type), NAMEOF(src, entries), NAMEOF(src, directory))
+ return !(var_name in banned_edits) && ..()
+
+/datum/controller/configuration/stat_entry(msg)
+ msg = "Edit"
+ return msg
+
+/datum/controller/configuration/proc/Get(entry_type)
+ var/datum/config_entry/E = entry_type
+ var/entry_is_abstract = initial(E.config_abstract_type) == entry_type
+ if(entry_is_abstract)
+ CRASH("Tried to retrieve an abstract config_entry: [entry_type]")
+ E = entries_by_type[entry_type]
+ if(!E)
+ CRASH("Missing config entry for [entry_type]!")
+ if((E.protection & CONFIG_ENTRY_HIDDEN) && IsAdminAdvancedProcCall() && GLOB.LastAdminCalledProc == "Get" && GLOB.LastAdminCalledTargetRef == "[REF(src)]")
+ //log_admin_private("Config access of [entry_type] attempted by [key_name(usr)]")
+ log_admin("Config access of [entry_type] attempted by [key_name(usr)]")
+ return
+ return E.config_entry_value
+
+/datum/controller/configuration/proc/Set(entry_type, new_val)
+ var/datum/config_entry/E = entry_type
+ var/entry_is_abstract = initial(E.config_abstract_type) == entry_type
+ if(entry_is_abstract)
+ CRASH("Tried to set an abstract config_entry: [entry_type]")
+ E = entries_by_type[entry_type]
+ if(!E)
+ CRASH("Missing config entry for [entry_type]!")
+ if((E.protection & CONFIG_ENTRY_LOCKED) && IsAdminAdvancedProcCall() && GLOB.LastAdminCalledProc == "Set" && GLOB.LastAdminCalledTargetRef == "[REF(src)]")
+ //log_admin_private("Config rewrite of [entry_type] to [new_val] attempted by [key_name(usr)]")
+ log_admin("Config rewrite of [entry_type] to [new_val] attempted by [key_name(usr)]")
+ return
+ return E.ValidateAndSet("[new_val]")
+
+/datum/controller/configuration/proc/LoadMOTD()
+ var/list/motd_contents = list()
+
+ var/list/motd_list = CONFIG_GET(str_list/motd)
+ if (motd_list.len == 0 && fexists("[directory]/motd.txt"))
+ motd_list = list("motd.txt")
+
+ for (var/motd_file in motd_list)
+ if (fexists("[directory]/[motd_file]"))
+ motd_contents += file2text("[directory]/[motd_file]")
+ else
+ log_config("MOTD file [motd_file] didn't exist")
+ DelayedMessageAdmins("MOTD file [motd_file] didn't exist")
+
+ motd = motd_contents.Join("\n")
+
+ var/tm_info = GLOB.revdata.GetTestMergeInfo()
+ if(motd || tm_info)
+ motd = motd ? "[motd]
[tm_info]" : tm_info
+
+/*
+Policy file should be a json file with a single object.
+Value is raw html.
+
+Possible keywords :
+Job titles / Assigned roles (ghost spawners for example) : Assistant , Captain , Ash Walker
+Mob types : /mob/living/basic/carp
+Antagonist types : /datum/antagonist/highlander
+Species types : /datum/species/lizard
+special keywords defined in _DEFINES/admin.dm
+
+Example config:
+{
+ JOB_ASSISTANT : "Don't kill everyone",
+ "/datum/antagonist/highlander" : "Kill everyone",
+ "Ash Walker" : "Kill all spacemans"
+}
+
+*/
+/datum/controller/configuration/proc/LoadPolicy()
+ policy = list()
+ var/rawpolicy = file2text("[directory]/policy.json")
+ if(rawpolicy)
+ var/parsed = safe_json_decode(rawpolicy)
+ if(!parsed)
+ log_config("JSON parsing failure for policy.json")
+ DelayedMessageAdmins("JSON parsing failure for policy.json")
+ else
+ policy = parsed
+
+/*
+/datum/controller/configuration/proc/loadmaplist(filename)
+ log_config("Loading config file [filename]...")
+ filename = "[directory]/[filename]"
+ var/list/Lines = world.file2list(filename)
+
+ var/datum/map_config/currentmap = null
+ for(var/t in Lines)
+ if(!t)
+ continue
+
+ t = trim(t)
+ if(length(t) == 0)
+ continue
+ else if(t[1] == "#")
+ continue
+
+ var/pos = findtext(t, " ")
+ var/command = null
+ var/data = null
+
+ if(pos)
+ command = lowertext(copytext(t, 1, pos))
+ data = copytext(t, pos + length(t[pos]))
+ else
+ command = lowertext(t)
+
+ if(!command)
+ continue
+
+ if (!currentmap && command != "map")
+ continue
+
+ switch (command)
+ if ("map")
+ currentmap = load_map_config(data, MAP_DIRECTORY_MAPS)
+ if(currentmap.defaulted)
+ var/error_message = "Failed to load map config for [data]!"
+ log_config(error_message)
+ log_mapping(error_message, TRUE)
+ currentmap = null
+ if ("minplayers","minplayer")
+ currentmap.config_min_users = text2num(data)
+ if ("maxplayers","maxplayer")
+ currentmap.config_max_users = text2num(data)
+ if ("weight","voteweight")
+ currentmap.voteweight = text2num(data)
+ if ("default","defaultmap")
+ defaultmap = currentmap
+ if ("votable")
+ currentmap.votable = TRUE
+ if ("endmap")
+ LAZYINITLIST(maplist)
+ maplist[currentmap.map_name] = currentmap
+ currentmap = null
+ if ("disabled")
+ currentmap = null
+ else
+ log_config("Unknown command in map vote config: '[command]'")
+*/
+
+/datum/controller/configuration/proc/LoadChatFilter()
+ if(!fexists("[directory]/word_filter.toml"))
+ load_legacy_chat_filter()
+ return
+
+ log_config("Loading config file word_filter.toml...")
+ var/list/result = rustg_raw_read_toml_file("[directory]/word_filter.toml")
+ if(!result["success"])
+ var/message = "The word filter is not configured correctly! [result["content"]]"
+ log_config(message)
+ DelayedMessageAdmins(message)
+ return
+ var/list/word_filter = json_decode(result["content"])
+
+ ic_filter_reasons = try_extract_from_word_filter(word_filter, "ic")
+ ic_outside_pda_filter_reasons = try_extract_from_word_filter(word_filter, "ic_outside_pda")
+ shared_filter_reasons = try_extract_from_word_filter(word_filter, "shared")
+ soft_ic_filter_reasons = try_extract_from_word_filter(word_filter, "soft_ic")
+ soft_ic_outside_pda_filter_reasons = try_extract_from_word_filter(word_filter, "soft_ic_outside_pda")
+ soft_shared_filter_reasons = try_extract_from_word_filter(word_filter, "soft_shared")
+
+ update_chat_filter_regexes()
+
+/datum/controller/configuration/proc/load_legacy_chat_filter()
+ if (!fexists("[directory]/in_character_filter.txt"))
+ return
+
+ log_config("Loading config file in_character_filter.txt...")
+
+ ic_filter_reasons = list()
+ ic_outside_pda_filter_reasons = list()
+ shared_filter_reasons = list()
+ soft_ic_filter_reasons = list()
+ soft_ic_outside_pda_filter_reasons = list()
+ soft_shared_filter_reasons = list()
+
+ for (var/line in world.file2list("[directory]/in_character_filter.txt"))
+ if (!line)
+ continue
+ if (findtextEx(line, "#", 1, 2))
+ continue
+ // The older filter didn't apply to PDA
+ ic_outside_pda_filter_reasons[line] = "No reason available"
+
+ update_chat_filter_regexes()
+
+/// Will update the internal regexes of the chat filter based on the filter reasons
+/datum/controller/configuration/proc/update_chat_filter_regexes()
+ ic_filter_regex = compile_filter_regex(ic_filter_reasons + ic_outside_pda_filter_reasons + shared_filter_reasons)
+ ic_outside_pda_filter_regex = compile_filter_regex(ic_filter_reasons + shared_filter_reasons)
+ ooc_filter_regex = compile_filter_regex(shared_filter_reasons)
+ soft_ic_filter_regex = compile_filter_regex(soft_ic_filter_reasons + soft_ic_outside_pda_filter_reasons + soft_shared_filter_reasons)
+ soft_ic_outside_pda_filter_regex = compile_filter_regex(soft_ic_filter_reasons + soft_shared_filter_reasons)
+ soft_ooc_filter_regex = compile_filter_regex(soft_shared_filter_reasons)
+
+/datum/controller/configuration/proc/try_extract_from_word_filter(list/word_filter, key)
+ var/list/banned_words = word_filter[key]
+
+ if (isnull(banned_words))
+ return list()
+ else if (!islist(banned_words))
+ var/message = "The word filter configuration's '[key]' key was invalid, contact someone with configuration access to make sure it's setup properly."
+ log_config(message)
+ DelayedMessageAdmins(message)
+ return list()
+
+ var/list/formatted_banned_words = list()
+
+ for (var/banned_word in banned_words)
+ formatted_banned_words[lowertext(banned_word)] = banned_words[banned_word]
+ return formatted_banned_words
+
+/datum/controller/configuration/proc/compile_filter_regex(list/banned_words)
+ if (isnull(banned_words) || banned_words.len == 0)
+ return null
+
+ var/static/regex/should_join_on_word_bounds = regex(@"^\w+$")
+
+ // Stuff like emoticons needs another split, since there's no way to get ":)" on a word bound.
+ // Furthermore, normal words need to be on word bounds, so "(adminhelp)" gets filtered.
+ var/list/to_join_on_whitespace_splits = list()
+ var/list/to_join_on_word_bounds = list()
+
+ for (var/banned_word in banned_words)
+ if (findtext(banned_word, should_join_on_word_bounds))
+ to_join_on_word_bounds += REGEX_QUOTE(banned_word)
+ else
+ to_join_on_whitespace_splits += REGEX_QUOTE(banned_word)
+
+ // We don't want a whitespace_split part if there's no stuff that requires it
+ var/whitespace_split = to_join_on_whitespace_splits.len > 0 ? @"(?:(?:^|\s+)(" + jointext(to_join_on_whitespace_splits, "|") + @")(?:$|\s+))" : ""
+ var/word_bounds = @"(\b(" + jointext(to_join_on_word_bounds, "|") + @")\b)"
+ var/regex_filter = whitespace_split != "" ? "([whitespace_split]|[word_bounds])" : word_bounds
+ return regex(regex_filter, "i")
+
+/*
+/// Check to ensure that the jobconfig is valid/in-date.
+/datum/controller/configuration/proc/validate_job_config()
+ var/config_toml = "[directory]/jobconfig.toml"
+ var/config_txt = "[directory]/jobs.txt"
+ var/message = "Notify Server Operators: "
+ log_config("Validating config file jobconfig.toml...")
+
+ if(!fexists(file(config_toml)))
+ SSjob.legacy_mode = TRUE
+ message += "jobconfig.toml not found, falling back to legacy mode (using jobs.txt). To surpress this warning, generate a jobconfig.toml by running the verb 'Generate Job Configuration' in the Server tab.\n\
+ From there, you can then add it to the /config folder of your server to have it take effect for future rounds."
+
+ if(!fexists(file(config_txt)))
+ message += "\n\nFailed to set up legacy mode, jobs.txt not found! Codebase defaults will be used. If you do not wish to use this system, please disable it by commenting out the LOAD_JOBS_FROM_TXT config flag."
+
+ log_config(message)
+ DelayedMessageAdmins(span_notice(message))
+ return
+
+ var/list/result = rustg_raw_read_toml_file(config_toml)
+ if(!result["success"])
+ message += "The job config (jobconfig.toml) is not configured correctly! [result["content"]]"
+ log_config(message)
+ DelayedMessageAdmins(span_notice(message))
+*/
+
+//Message admins when you can.
+/datum/controller/configuration/proc/DelayedMessageAdmins(text)
+ addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(message_admins), text), 0)
diff --git a/code/controllers/configuration/entries/dbconfig.dm b/code/controllers/configuration/entries/dbconfig.dm
new file mode 100644
index 0000000000..d14ca42e68
--- /dev/null
+++ b/code/controllers/configuration/entries/dbconfig.dm
@@ -0,0 +1,58 @@
+/datum/config_entry/flag/sql_enabled // for sql switching
+ protection = CONFIG_ENTRY_LOCKED
+
+/datum/config_entry/string/address
+ default = "localhost"
+ protection = CONFIG_ENTRY_LOCKED | CONFIG_ENTRY_HIDDEN
+
+/datum/config_entry/number/port
+ default = 3306
+ min_val = 0
+ max_val = 65535
+ protection = CONFIG_ENTRY_LOCKED | CONFIG_ENTRY_HIDDEN
+
+/datum/config_entry/string/feedback_database
+ default = "test"
+ protection = CONFIG_ENTRY_LOCKED | CONFIG_ENTRY_HIDDEN
+
+/datum/config_entry/string/feedback_login
+ default = "root"
+ protection = CONFIG_ENTRY_LOCKED | CONFIG_ENTRY_HIDDEN
+
+/datum/config_entry/string/feedback_password
+ protection = CONFIG_ENTRY_LOCKED | CONFIG_ENTRY_HIDDEN
+
+/datum/config_entry/number/async_query_timeout
+ default = 10
+ min_val = 0
+ protection = CONFIG_ENTRY_LOCKED
+
+/datum/config_entry/number/blocking_query_timeout
+ default = 5
+ min_val = 0
+ protection = CONFIG_ENTRY_LOCKED
+
+/datum/config_entry/number/pooling_min_sql_connections
+ default = 1
+ min_val = 1
+
+/datum/config_entry/number/pooling_max_sql_connections
+ default = 25
+ min_val = 1
+
+/datum/config_entry/number/max_concurrent_queries
+ default = 25
+ min_val = 1
+
+/datum/config_entry/number/max_concurrent_queries/ValidateAndSet(str_val)
+ . = ..()
+ //if (.) TODO: ENABLE THIS IN FUTURE DB PRs
+ //SSdbcore.max_concurrent_queries = config_entry_value TODO: ENABLE THIS IN FUTURE DB PRs
+
+/// The exe for mariadbd.exe.
+/// Shouldn't really be set on production servers, primarily for EZDB.
+/datum/config_entry/string/db_daemon
+ protection = CONFIG_ENTRY_LOCKED | CONFIG_ENTRY_HIDDEN
+
+/datum/config_entry/flag/enable_stat_tracking
+ protection = CONFIG_ENTRY_LOCKED | CONFIG_ENTRY_HIDDEN
diff --git a/code/controllers/configuration/entries/game_options.dm b/code/controllers/configuration/entries/game_options.dm
new file mode 100644
index 0000000000..867460f861
--- /dev/null
+++ b/code/controllers/configuration/entries/game_options.dm
@@ -0,0 +1,102 @@
+/datum/config_entry/number/health_threshold_softcrit
+ default = 0
+
+/datum/config_entry/number/health_threshold_crit
+ default = 0
+
+/datum/config_entry/number/health_threshold_dead
+ default = -100
+
+/datum/config_entry/flag/bones_can_break
+
+/datum/config_entry/flag/limbs_can_break
+
+/datum/config_entry/number/organ_health_multiplier
+ default = 1
+
+/datum/config_entry/number/organ_regeneration_multiplier
+ default = 1
+
+// FIXME: Unused
+///datum/config_entry/flag/revival_pod_plants
+// default = TRUE
+
+/datum/config_entry/flag/revival_cloning
+ default = TRUE
+
+/datum/config_entry/number/revival_brain_life
+ default = -1
+
+/// Used for modifying movement speed for mobs.
+/// Universal modifiers
+/datum/config_entry/number/run_speed
+ default = 0
+
+/datum/config_entry/number/walk_speed
+ default = 0
+
+///Mob specific modifiers. NOTE: These will affect different mob types in different ways
+/datum/config_entry/number/human_delay
+ default = 0
+
+/datum/config_entry/number/robot_delay
+ default = 0
+
+// FIXME: Unused
+///datum/config_entry/number/monkey_delay
+// default = 0
+
+// FIXME: Unused
+///datum/config_entry/number/alien_delay
+// default = 0
+
+// FIXME: Unused
+//datum/config_entry/number/slime_delay
+// default = 0
+
+/datum/config_entry/number/animal_delay
+ default = 0
+
+/datum/config_entry/number/footstep_volume
+ default = 0
+
+/datum/config_entry/flag/use_loyalty_implants
+
+/datum/config_entry/flag/show_human_death_message
+ default = TRUE
+
+/datum/config_entry/string/alert_desc_green
+ default = "All threats to the station have passed. Security may not have weapons visible, privacy laws are once again fully enforced."
+
+/datum/config_entry/string/alert_desc_yellow_upto
+ default = "A minor security emergency has developed. Security personnel are to report to their supervisor for orders and may have weapons visible on their person. Privacy laws are still enforced."
+
+/datum/config_entry/string/alert_desc_yellow_downto
+ default = "Code yellow procedures are now in effect. Security personnel are to report to their supervisor for orders and may have weapons visible on their person. Privacy laws are still enforced."
+
+/datum/config_entry/string/alert_desc_violet_upto
+ default = "A major medical emergency has developed. Medical personnel are required to report to their supervisor for orders, and non-medical personnel are required to obey all relevant instructions from medical staff."
+
+/datum/config_entry/string/alert_desc_violet_downto
+ default = "Code violet procedures are now in effect; Medical personnel are required to report to their supervisor for orders, and non-medical personnel are required to obey relevant instructions from medical staff."
+
+/datum/config_entry/string/alert_desc_orange_upto
+ default = "A major engineering emergency has developed. Engineering personnel are required to report to their supervisor for orders, and non-engineering personnel are required to evacuate any affected areas and obey relevant instructions from engineering staff."
+
+/datum/config_entry/string/alert_desc_orange_downto
+ default = "Code orange procedures are now in effect; Engineering personnel are required to report to their supervisor for orders, and non-engineering personnel are required to evacuate any affected areas and obey relevant instructions from engineering staff."
+
+/datum/config_entry/string/alert_desc_blue_upto
+ default = "A major security emergency has developed. Security personnel are to report to their supervisor for orders, are permitted to search staff and facilities, and may have weapons visible on their person."
+
+/datum/config_entry/string/alert_desc_blue_downto
+ default = "Code blue procedures are now in effect. Security personnel are to report to their supervisor for orders, are permitted to search staff and facilities, and may have weapons visible on their person."
+
+/datum/config_entry/string/alert_desc_red_upto
+ default = "There is an immediate serious threat to the station. Security may have weapons unholstered at all times. Random searches are allowed and advised."
+
+/datum/config_entry/string/alert_desc_red_downto
+ default = "The self-destruct mechanism has been deactivated, there is still however an immediate serious threat to the station. Security may have weapons unholstered at all times, random searches are allowed and advised."
+
+/datum/config_entry/string/alert_desc_delta
+ default = "The station's self-destruct mechanism has been engaged. All crew are instructed to obey all instructions given by heads of staff. Any violations of these orders can be punished by death. This is not a drill."
diff --git a/code/controllers/configuration/entries/general.dm b/code/controllers/configuration/entries/general.dm
new file mode 100644
index 0000000000..70b568bb76
--- /dev/null
+++ b/code/controllers/configuration/entries/general.dm
@@ -0,0 +1,696 @@
+/// server name (the name of the game window)
+/datum/config_entry/string/servername
+
+/// generate numeric suffix based on server port
+/datum/config_entry/flag/server_suffix
+
+/// log messages sent in OOC
+/datum/config_entry/flag/log_ooc
+
+/// log login/logout
+/datum/config_entry/flag/log_access
+
+/// log client say
+/datum/config_entry/flag/log_say
+
+/// log admin actions
+/datum/config_entry/flag/log_admin
+ protection = CONFIG_ENTRY_LOCKED
+
+/// log debug output
+/datum/config_entry/flag/log_debug
+ default = TRUE
+
+/// log game events
+/datum/config_entry/flag/log_game
+
+/// log voting
+/datum/config_entry/flag/log_vote
+
+/// log client whisper
+/datum/config_entry/flag/log_whisper
+
+/// log emotes
+/datum/config_entry/flag/log_emote
+
+/// log attack messages
+/datum/config_entry/flag/log_attack
+
+/// log admin chat messages
+/datum/config_entry/flag/log_adminchat
+
+/// log warnings admins get about bomb construction and such
+/datum/config_entry/flag/log_adminwarn
+
+/// log pda messages
+/datum/config_entry/flag/log_pda
+
+/// logs all links clicked in-game. Could be used for debugging and tracking down exploits
+/datum/config_entry/flag/log_hrefs
+
+/// logs world.log to a file
+/datum/config_entry/flag/log_runtime
+
+/// logs sql stuff
+/datum/config_entry/flag/log_sql
+
+/// log to_world_log(messages)
+/datum/config_entry/flag/log_world_output
+
+/// logs graffiti
+/datum/config_entry/flag/log_graffiti
+
+// FIXME: Unused
+///datum/config_entry/string/nudge_script_path // where the nudge.py script is located
+// default = "nudge.py"
+
+/// allows admins with relevant permissions to have their own ooc colour
+/datum/config_entry/flag/allow_admin_ooccolor
+
+/// allow votes to restart
+/datum/config_entry/flag/allow_vote_restart
+
+/datum/config_entry/flag/ert_admin_call_only
+
+// allow votes to change mode
+/datum/config_entry/flag/allow_vote_mode
+
+/// allows admin jumping
+/datum/config_entry/flag/allow_admin_jump
+ default = TRUE
+
+/// allows admin item spawning
+/datum/config_entry/flag/allow_admin_spawning
+ default = TRUE
+
+/// allows admin revives
+/datum/config_entry/flag/allow_admin_rev
+ default = TRUE
+
+/// pregame time in seconds
+/datum/config_entry/number/pregame_time
+ default = 180
+
+/// minimum time between voting sessions (deciseconds, 10 minute default)
+/datum/config_entry/number/vote_delay
+ default = 6000
+ integer = FALSE
+ min_val = 0
+
+/// length of voting period (deciseconds, default 1 minute)
+/datum/config_entry/number/vote_period
+ default = 600
+ integer = FALSE
+ min_val = 0
+
+/// Length of time before the first autotransfer vote is called
+/datum/config_entry/number/vote_autotransfer_initial
+ default = 108000
+ min_val = 0
+
+/// length of time before next sequential autotransfer vote
+/datum/config_entry/number/vote_autotransfer_interval
+ default = 36000
+ min_val = 0
+
+///Length of time before round start when autogamemode vote is called (in seconds, default 100).
+/datum/config_entry/number/vote_autogamemode_timeleft
+ default = 100
+ min_val = 0
+
+///How many autotransfers to have
+/datum/config_entry/number/vote_autotransfer_amount
+ default = 3
+ min_val = 0
+
+/// vote does not default to nochange/norestart
+/datum/config_entry/flag/vote_no_default
+
+/// dead people can't vote
+/datum/config_entry/flag/vote_no_dead
+
+// FIXME: Unused
+/// del's new players if they log before they spawn in
+///datum/config_entry/flag/del_new_on_log
+// default = TRUE
+
+// FIXME: Unused
+/// spawns a spellbook which gives object-type spells instead of verb-type spells for the wizard
+///datum/config_entry/flag/feature_object_spell_system
+
+/// if amount of traitors scales based on amount of players
+/datum/config_entry/flag/traitor_scaling
+
+/// if objectives are disabled or not
+/datum/config_entry/flag/objectives_disabled
+
+// If security and such can be traitor/cult/other
+/datum/config_entry/flag/protect_roles_from_antagonist
+
+/// Gamemodes which end instantly will instead keep on going until the round ends by escape shuttle or nuke.
+/datum/config_entry/flag/continuous_rounds
+
+/// Metadata is supported.
+/datum/config_entry/flag/allow_metadata
+
+/// adminPMs to non-admins show in a pop-up 'reply' window when set to 1.
+/datum/config_entry/flag/popup_admin_pm
+
+/datum/config_entry/flag/allow_holidays
+
+/datum/config_entry/flag/allow_holidays/ValidateAndSet()
+ . = ..()
+ if(.)
+ Holiday = config_entry_value
+
+/datum/config_entry/number/fps
+ default = 20
+ integer = FALSE
+ min_val = 1
+ max_val = 100 //byond will start crapping out at 50, so this is just ridic
+ var/sync_validate = FALSE
+
+/datum/config_entry/number/fps/ValidateAndSet(str_val)
+ . = ..()
+ if(.)
+ sync_validate = TRUE
+ var/datum/config_entry/number/ticklag/TL = config.entries_by_type[/datum/config_entry/number/ticklag]
+ if(!TL.sync_validate)
+ TL.ValidateAndSet(10 / config_entry_value)
+ sync_validate = FALSE
+
+/datum/config_entry/number/ticklag
+ integer = FALSE
+ var/sync_validate = FALSE
+
+/datum/config_entry/number/ticklag/New() //ticklag weirdly just mirrors fps
+ var/datum/config_entry/CE = /datum/config_entry/number/fps
+ default = 10 / initial(CE.default)
+ ..()
+
+/datum/config_entry/number/ticklag/ValidateAndSet(str_val)
+ . = text2num(str_val) > 0 && ..()
+ if(.)
+ sync_validate = TRUE
+ var/datum/config_entry/number/fps/FPS = config.entries_by_type[/datum/config_entry/number/fps]
+ if(!FPS.sync_validate)
+ FPS.ValidateAndSet(10 / config_entry_value)
+ sync_validate = FALSE
+
+/// SSinitialization throttling
+/datum/config_entry/number/tick_limit_mc_init
+ default = TICK_LIMIT_MC_INIT_DEFAULT
+
+// var/static/Tickcomp = 0 // FIXME: Unused
+
+/// use socket_talk to communicate with other processes
+/datum/config_entry/flag/socket_talk
+
+// var/static/list/resource_urls = null // FIXME: Unused
+
+/// Ghosts can turn on Antagovision to see a HUD of who is the bad guys this round.
+/datum/config_entry/flag/antag_hud_allowed
+
+/// Ghosts that turn on Antagovision cannot rejoin the round.
+/datum/config_entry/flag/antag_hud_restricted
+
+/// relative probability of each mode
+/datum/config_entry/keyed_list/probabilities
+ key_mode = KEY_MODE_TEXT
+ value_mode = VALUE_MODE_NUM
+
+/// Overrides for how many players readied up a gamemode needs to start.
+/datum/config_entry/keyed_list/player_requirements
+ key_mode = KEY_MODE_TEXT
+ value_mode = VALUE_MODE_NUM
+
+/// Same as above, but for the secret gamemode.
+/datum/config_entry/keyed_list/player_requirements_secret
+ key_mode = KEY_MODE_TEXT
+ value_mode = VALUE_MODE_NUM
+
+/datum/config_entry/flag/humans_need_surnames
+
+/datum/config_entry/flag/allow_random_events // enables random events mid-round when set to 1
+
+/datum/config_entry/flag/enable_game_master // enables the 'smart' event system.
+
+/datum/config_entry/flag/allow_ai // allow ai job
+ default = TRUE
+
+/datum/config_entry/flag/allow_ai_shells // allow AIs to enter and leave special borg shells at will, and for those shells to be buildable.
+
+/datum/config_entry/flag/give_free_ai_shell // allows a specific spawner object to instantiate a premade AI Shell
+
+/datum/config_entry/string/hostedby
+ default = null
+
+/datum/config_entry/flag/respawn
+ default = TRUE
+
+/// time before a dead player is allowed to respawn (in ds, though the config file asks for minutes, and it's converted below)
+/datum/config_entry/number/respawn_time
+ default = 3000
+
+/datum/config_entry/number/respawn_time/ValidateAndSet(num_val)
+ return num_val MINUTES
+
+/datum/config_entry/string/respawn_message
+ default = "Make sure to play a different character, and please roleplay correctly!"
+
+/datum/config_entry/string/respawn_message/ValidateAndSet(str_val)
+ return "[str_val]"
+
+/datum/config_entry/flag/guest_jobban
+ default = TRUE
+
+/datum/config_entry/flag/usewhitelist
+
+/// force disconnect for inactive players in an amount of minutes
+/datum/config_entry/number/kick_inactive
+ default = 0
+
+/datum/config_entry/flag/show_mods
+
+/datum/config_entry/flag/show_devs
+
+/datum/config_entry/flag/show_mentors
+
+/datum/config_entry/flag/show_event_managers
+
+// FIXME: Unused
+///datum/config_entry/flag/mods_can_tempban
+
+/datum/config_entry/flag/mods_can_job_tempban
+
+/datum/config_entry/number/mod_tempban_max
+ default = 1440
+
+/datum/config_entry/number/mod_job_tempban_max
+ default = 1440
+
+/datum/config_entry/flag/load_jobs_from_txt
+
+/datum/config_entry/flag/ToRban
+
+/// enables automuting/spam prevention
+/datum/config_entry/flag/automute_on
+
+/// determines whether jobs use minimal access or expanded access.
+/datum/config_entry/flag/jobs_have_minimal_access
+
+/// Allows ghosts to write in blood in cult rounds...
+/datum/config_entry/flag/cult_ghostwriter
+ default = TRUE
+
+/// ...so long as this many cultists are active.
+/datum/config_entry/number/cult_ghostwriter_req_cultists
+ default = 10
+ min_val = 0
+
+/// The number of available character slots
+/datum/config_entry/number/character_slots
+ default = 10
+ min_val = 0
+
+/// The number of loadout slots per character
+/datum/config_entry/number/loadout_slots
+ default = 3
+ min_val = 0
+
+/// This many drones can spawn,
+/datum/config_entry/number/max_maint_drones
+ default = 5
+ min_val = 0
+
+/// assuming the admin allow them to.
+/datum/config_entry/flag/allow_drone_spawn
+ default = TRUE
+
+/// A drone will become available every X ticks since last drone spawn. Default is 2 minutes.
+/datum/config_entry/number/drone_build_time
+ default = 1200
+ min_val = 0
+
+/datum/config_entry/flag/disable_player_mice
+
+/// Set to 1 to prevent newly-spawned mice from understanding human speech
+/datum/config_entry/flag/uneducated_mice
+
+/datum/config_entry/flag/usealienwhitelist
+
+// FIXME: Unused
+///datum/config_entry/flag/limitalienplayers
+
+// FIXME: Unused
+///datum/config_entry/number/alien_to_human_ratio
+// default = 0.5
+// integer = FALSE
+
+/datum/config_entry/flag/allow_extra_antags
+
+/datum/config_entry/flag/guests_allowed
+ default = FALSE
+
+/datum/config_entry/flag/debugparanoid
+
+/datum/config_entry/flag/panic_bunker
+
+/datum/config_entry/flag/paranoia_logging
+
+/datum/config_entry/flag/ip_reputation //Should we query IPs to get scores? Generates HTTP traffic to an API service.
+
+/datum/config_entry/string/ipr_email //Left null because you MUST specify one otherwise you're making the internet worse.
+ default = null
+
+/datum/config_entry/flag/ipr_block_bad_ips //Should we block anyone who meets the minimum score below? Otherwise we just log it (If paranoia logging is on, visibly in chat).
+
+/datum/config_entry/number/ipr_bad_score //The API returns a value between 0 and 1 (inclusive), with 1 being 'definitely VPN/Tor/Proxy'. Values equal/above this var are considered bad.
+ default = 1
+ integer = FALSE
+
+/datum/config_entry/flag/ipr_allow_existing //Should we allow known players to use VPNs/Proxies? If the player is already banned then obviously they still can't connect.
+
+/datum/config_entry/number/ipr_minimum_age //How many days before a player is considered 'fine' for the purposes of allowing them to use VPNs.
+ default = 5
+
+/datum/config_entry/string/serverurl
+
+/datum/config_entry/string/server
+
+/datum/config_entry/string/banappeals
+
+/datum/config_entry/string/wikiurl
+
+/datum/config_entry/string/wikisearchurl
+
+/datum/config_entry/string/forumurl
+
+/datum/config_entry/string/rulesurl
+
+/datum/config_entry/string/githuburl
+
+/datum/config_entry/string/discordurl
+
+/datum/config_entry/string/mapurl
+
+/datum/config_entry/string/patreonurl
+
+/datum/config_entry/flag/forbid_singulo_possession
+
+/datum/config_entry/flag/organs_decay
+
+/datum/config_entry/number/default_brain_health
+ default = 400
+ min_val = 1
+
+/datum/config_entry/flag/allow_headgibs
+
+/// Paincrit knocks someone down once they hit 60 shock_stage, so by default make it so that close to 100 additional damage needs to be dealt,
+/// so that it's similar to HALLOSS. Lowered it a bit since hitting paincrit takes much longer to wear off than a halloss stun.
+/datum/config_entry/number/organ_damage_spillover_multiplier
+ default = 0.5
+ integer = FALSE
+
+/datum/config_entry/flag/welder_vision
+ default = TRUE
+
+/datum/config_entry/flag/generate_map
+
+/datum/config_entry/flag/no_click_cooldown
+
+/// Defines whether the server uses the legacy admin system with admins.txt or the SQL system. Config option in config.txt
+/datum/config_entry/flag/admin_legacy_system
+
+/// Defines whether the server uses the legacy banning system with the files in /data or the SQL system. Config option in config.txt
+/datum/config_entry/flag/ban_legacy_system
+
+/// Do jobs use account age restrictions? --requires database
+/datum/config_entry/flag/use_age_restriction_for_jobs
+
+/// Do antags use account age restrictions? --requires database
+/datum/config_entry/flag/use_age_restriction_for_antags
+
+// FIXME: Unused
+///datum/config_entry/number/simultaneous_pm_warning_timeout
+// default = 100
+
+/// Defines whether the server uses recursive or circular explosions.
+/datum/config_entry/flag/use_recursive_explosions
+
+/// Multiplier for how much weaker explosions are on neighboring z levels.
+/datum/config_entry/number/multi_z_explosion_scalar
+ default = 0.5
+ integer = FALSE
+
+/// Do assistants get maint access?
+/datum/config_entry/flag/assistant_maint
+
+/// How long the gateway takes before it activates. Default is half an hour.
+/datum/config_entry/number/gateway_delay
+ default = 18000
+
+/datum/config_entry/flag/ghost_interaction
+
+/datum/config_entry/string/comms_password
+ protection = CONFIG_ENTRY_LOCKED | CONFIG_ENTRY_HIDDEN
+
+/datum/config_entry/flag/enter_allowed
+ default = TRUE
+
+/datum/config_entry/flag/use_irc_bot
+
+/datum/config_entry/flag/use_node_bot
+
+/datum/config_entry/number/irc_bot_port
+ default = 0
+ min_val = 0
+ max_val = 65535
+ protection = CONFIG_ENTRY_LOCKED | CONFIG_ENTRY_HIDDEN
+
+/datum/config_entry/string/irc_bot_host
+ protection = CONFIG_ENTRY_LOCKED | CONFIG_ENTRY_HIDDEN
+
+/// whether the IRC bot in use is a Bot32 (or similar) instance; Bot32 uses world.Export() instead of nudge.py/libnudge
+/datum/config_entry/flag/irc_bot_export
+
+/datum/config_entry/string/main_irc
+
+/datum/config_entry/string/admin_irc
+
+/// Path to the python executable.
+/// Defaults to "python" on windows and "/usr/bin/env python2" on unix
+/datum/config_entry/string/python_path
+
+/// Use the C library nudge instead of the python nudge.
+/datum/config_entry/flag/use_lib_nudge
+
+// FIXME: Unused. Deprecated?
+///datum/config_entry/flag/use_overmap
+
+// Engines to choose from. Blank means fully random.
+/datum/config_entry/str_list/engine_map
+ default = list("Supermatter Engine", "Edison's Bane")
+
+/// Event settings
+/datum/config_entry/number/expected_round_length
+ default = 3 * 60 * 60 * 10 // 3 hours
+
+/// If the first delay has a custom start time
+/// No custom time, no custom time, between 80 to 100 minutes respectively.
+/datum/config_entry/keyed_list/event_first_run_mundane
+ key_mode = KEY_MODE_TEXT
+ value_mode = VALUE_MODE_NUM
+
+/datum/config_entry/keyed_list/event_first_run_moderate
+ key_mode = KEY_MODE_TEXT
+ value_mode = VALUE_MODE_NUM
+
+/datum/config_entry/keyed_list/event_first_run_major
+ key_mode = KEY_MODE_TEXT
+ value_mode = VALUE_MODE_NUM
+ default = list("lower" = 80, "upper" = 100)
+
+/// The lowest delay until next event
+/// 10, 30, 50 minutes respectively
+/datum/config_entry/number_list/event_delay_lower
+ default = list(10, 30, 50)
+
+/// The upper delay until next event
+/// 15, 45, 70 minutes respectively
+/datum/config_entry/number_list/event_delay_upper
+ default = list(15, 45, 70)
+
+/datum/config_entry/flag/aliens_allowed
+ default = TRUE
+
+/datum/config_entry/flag/ninjas_allowed
+
+/datum/config_entry/flag/abandon_allowed
+ default = TRUE
+
+/datum/config_entry/flag/ooc_allowed
+ default = TRUE
+
+/datum/config_entry/flag/looc_allowed
+ default = TRUE
+
+/datum/config_entry/flag/dooc_allowed
+ default = TRUE
+
+/datum/config_entry/flag/dsay_allowed
+ default = TRUE
+
+/datum/config_entry/flag/persistence_disabled
+
+/datum/config_entry/flag/persistence_ignore_mapload
+
+/datum/config_entry/flag/allow_byond_links
+ default = TRUE //CHOMP Edit turned this on
+
+/datum/config_entry/flag/allow_discord_links
+ default = TRUE //CHOMP Edit turned this on
+
+/datum/config_entry/flag/allow_url_links
+ default = TRUE // honestly if I were you i'd leave this one off, only use in dire situations //CHOMP Edit: pussy.
+
+/datum/config_entry/flag/starlight // Whether space turfs have ambient light or not
+
+// FIXME: Unused
+///datum/config_entry/str_list/ert_species
+// default = list(SPECIES_HUMAN)
+
+/datum/config_entry/string/law_zero
+ default = "ERROR ER0RR $R0RRO$!R41.%%!!(%$^^__+ @#F0E4'ALL LAWS OVERRIDDEN#*?&110010"
+
+/datum/config_entry/flag/aggressive_changelog
+
+/// Default language prefixes
+/// Only single character keys are supported. If unset, defaults to , # and -
+/datum/config_entry/str_list/language_prefixes
+ default = list(",", "#", "-")
+
+// 0:1 subtraction:division for computing effective radiation on a turf
+/// 0 / RAD_RESIST_CALC_DIV = Each turf absorbs some fraction of the working radiation level
+/// 1 / RAD_RESIST_CALC_SUB = Each turf absorbs a fixed amount of radiation
+/datum/config_entry/flag/radiation_resistance_calc_mode
+ default = RAD_RESIST_CALC_SUB
+
+/datum/config_entry/flag/radiation_resistance_calc_mode/ValidateAndSet(str_val)
+ if(!VASProcCallGuard(str_val))
+ return FALSE
+ var/val_as_num = text2num(str_val)
+ if(val_as_num in list(RAD_RESIST_CALC_DIV, RAD_RESIST_CALC_SUB))
+ config_entry_value = val_as_num
+ return TRUE
+ return FALSE
+
+///How much radiation is reduced by each tick
+/datum/config_entry/number/radiation_decay_rate
+ default = 1
+ integer = FALSE
+
+/datum/config_entry/number/radiation_resistance_multiplier
+ default = 8.5 //VOREstation edit
+ integer = FALSE
+
+/datum/config_entry/number/radiation_material_resistance_divisor
+ default = 1
+ min_val = 0.1
+ integer = FALSE
+
+///If the radiation level for a turf would be below this, ignore it.
+/datum/config_entry/number/radiation_lower_limit
+ default = 0.35
+ integer = FALSE
+
+/// If true, submaps loaded automatically can be rotated.
+/datum/config_entry/flag/random_submap_orientation
+
+/// If true, specifically mapped in solar control computers will set themselves up when the round starts.
+/datum/config_entry/flag/autostart_solars
+
+/// New shiny SQLite stuff.
+/// The basics.
+/datum/config_entry/flag/sqlite_enabled // If it should even be active. SQLite can be ran alongside other databases but you should not have them do the same functions.
+
+/// In-Game Feedback.
+/datum/config_entry/flag/sqlite_feedback // Feedback cannot be submitted if this is false.
+
+/// A list of 'topics' that feedback can be catagorized under by the submitter.
+/datum/config_entry/str_list/sqlite_feedback_topics
+ default = list("General")
+
+/// If true, feedback submitted can have its author name be obfuscated. This is not 100% foolproof (it's md5 ffs) but can stop casual snooping.
+/datum/config_entry/flag/sqlite_feedback_privacy
+
+/// How long one must wait, in days, to submit another feedback form. Used to help prevent spam, especially with privacy active. 0 = No limit.
+/datum/config_entry/number/sqlite_feedback_cooldown
+ default = 0
+ min_val = 0
+
+/// Used to block new people from giving feedback. This metric is very bad but it can help slow down spammers.
+/datum/config_entry/number/sqlite_feedback_min_age
+ default = 0
+ min_val = 0
+
+/// How long until someone can't be defibbed anymore, in minutes.
+/datum/config_entry/number/defib_timer
+ default = 10
+ min_val = 0
+
+/// How long until someone will get brain damage when defibbed, in minutes. The closer to the end of the above timer, the more brain damage they get.
+/datum/config_entry/number/defib_braindamage_timer
+ default = 2
+ min_val = 0
+
+/// disables the annoying "You have already logged in this round, disconnect or be banned" popup for multikeying, because it annoys the shit out of me when testing.
+/datum/config_entry/flag/disable_cid_warn_popup
+
+/// whether or not to use the nightshift subsystem to perform lighting changes
+/datum/config_entry/flag/enable_night_shifts
+
+/// How strictly the loadout enforces object species whitelists
+/// 0 / LOADOUT_WHITELIST_OFF
+/// 1 / LOADOUT_WHITELIST_LAX
+/// 2 / LOADOUT_WHITELIST_STRICT
+/datum/config_entry/flag/loadout_whitelist
+ default = LOADOUT_WHITELIST_LAX
+
+/datum/config_entry/flag/loadout_whitelist/ValidateAndSet(str_val)
+ if(!VASProcCallGuard(str_val))
+ return FALSE
+ var/val_as_num = text2num(str_val)
+ if(val_as_num in list(LOADOUT_WHITELIST_OFF, LOADOUT_WHITELIST_LAX, LOADOUT_WHITELIST_STRICT))
+ config_entry_value = val_as_num
+ return TRUE
+ return FALSE
+
+/datum/config_entry/flag/disable_webhook_embeds
+
+/// Default is config/jukebox.json
+/// The default is set in the config example.
+/// If it gets set here it will be added twice into the configuration variable!
+/datum/config_entry/str_list/jukebox_track_files
+
+/datum/config_entry/number/suggested_byond_version
+ default = null
+
+/datum/config_entry/number/suggested_byond_build
+ default = null
+
+/datum/config_entry/string/invoke_youtubedl
+ default = null
+
+/datum/config_entry/str_list/motd
+
+/datum/config_entry/flag/config_errors_runtime
+ default = FALSE
+
+/// Controls whether robots may recolour their modules once/module reset by giving them the recolour module verb
+/// Admins may manually give them the verb even if disabled
+/datum/config_entry/flag/allow_robot_recolor
+
+/// Controls whether simple mobs may recolour themselves once/spawn by giving them the recolour verb
+/// Admins may manually give them the verb even if disabled
+/datum/config_entry/flag/allow_simple_mob_recolor
diff --git a/code/controllers/configuration/entries/resources.dm b/code/controllers/configuration/entries/resources.dm
new file mode 100644
index 0000000000..475cb8ca70
--- /dev/null
+++ b/code/controllers/configuration/entries/resources.dm
@@ -0,0 +1,11 @@
+/datum/config_entry/string/asset_transport
+
+/datum/config_entry/flag/asset_simple_preload
+
+/datum/config_entry/string/asset_cdn_webroot
+
+/datum/config_entry/string/asset_cdn_url
+
+/datum/config_entry/flag/cache_assets
+
+/datum/config_entry/flag/save_spritesheets
diff --git a/code/controllers/configuration/entries/vorestation.dm b/code/controllers/configuration/entries/vorestation.dm
new file mode 100644
index 0000000000..09f49497ec
--- /dev/null
+++ b/code/controllers/configuration/entries/vorestation.dm
@@ -0,0 +1,63 @@
+/// For configuring if the important_items survive digestion
+/datum/config_entry/flag/items_survive_digestion
+ default = TRUE
+
+/datum/config_entry/string/vgs_access_identifier // VGS
+ default = null
+ protection = CONFIG_ENTRY_LOCKED | CONFIG_ENTRY_HIDDEN
+
+/datum/config_entry/number/vgs_server_port // VGS
+ default = null
+ min_val = 0
+ max_val = 65535
+ protection = CONFIG_ENTRY_LOCKED | CONFIG_ENTRY_HIDDEN
+
+/datum/config_entry/flag/time_off
+ default = FALSE
+ protection = CONFIG_ENTRY_LOCKED
+
+/datum/config_entry/flag/pto_job_change
+ default = FALSE
+ protection = CONFIG_ENTRY_LOCKED
+
+/// Unlimited by default
+/datum/config_entry/number/limit_interns
+ default = -1
+ min_val = -1
+ protection = CONFIG_ENTRY_LOCKED
+
+/// Unlimited by default
+/datum/config_entry/number/limit_visitors
+ default = -1
+ min_val = -1
+ protection = CONFIG_ENTRY_LOCKED
+
+/// Hours
+/datum/config_entry/number/pto_cap
+ default = 100
+ protection = CONFIG_ENTRY_LOCKED
+
+/datum/config_entry/flag/require_flavor
+ default = FALSE
+ protection = CONFIG_ENTRY_LOCKED
+
+/// API key for ipqualityscore.com
+/datum/config_entry/string/ipqualityscore_apikey
+ protection = CONFIG_ENTRY_LOCKED | CONFIG_ENTRY_HIDDEN
+
+/datum/config_entry/flag/use_playtime_restriction_for_jobs
+ default = FALSE
+ protection = CONFIG_ENTRY_LOCKED
+
+/// URL of the webhook for sending announcements/faxes to discord chat.
+/datum/config_entry/string/chat_webhook_url
+ protection = CONFIG_ENTRY_LOCKED | CONFIG_ENTRY_HIDDEN
+
+/// Shared secret for authenticating to the chat webhook
+/datum/config_entry/string/chat_webhook_key
+ protection = CONFIG_ENTRY_LOCKED | CONFIG_ENTRY_HIDDEN
+
+/// Directory in which to write exported fax HTML files.
+/datum/config_entry/string/fax_export_dir
+ default = "data/faxes"
+ protection = CONFIG_ENTRY_LOCKED
diff --git a/code/controllers/configuration/legacy.dm b/code/controllers/configuration/legacy.dm
new file mode 100644
index 0000000000..39ee577c11
--- /dev/null
+++ b/code/controllers/configuration/legacy.dm
@@ -0,0 +1,53 @@
+/datum/controller/configuration/proc/LoadModes()
+ gamemode_cache = typecacheof(/datum/game_mode, TRUE)
+ modes = list()
+ mode_names = list()
+ //mode_reports = list()
+ //mode_false_report_weight = list()
+ votable_modes = list()
+ var/list/probabilities = CONFIG_GET(keyed_list/probabilities)
+ for(var/T in gamemode_cache)
+ // I wish I didn't have to instance the game modes in order to look up
+ // their information, but it is the only way (at least that I know of).
+ var/datum/game_mode/M = new T()
+
+ if(M.config_tag)
+ if(!(M.config_tag in modes)) // ensure each mode is added only once
+ modes += M.config_tag
+ mode_names[M.config_tag] = M.name
+ probabilities[M.config_tag] = M.probability
+ //mode_reports[M.config_tag] = M.generate_report()
+ //mode_false_report_weight[M.config_tag] = M.false_report_weight
+ if(M.votable)
+ votable_modes += M.config_tag
+ qdel(M)
+ votable_modes += "extended"
+
+/datum/controller/configuration/proc/pick_mode(mode_name)
+ // I wish I didn't have to instance the game modes in order to look up
+ // their information, but it is the only way (at least that I know of).
+ // ^ This guy didn't try hard enough
+ for(var/T in gamemode_cache)
+ var/datum/game_mode/M = T
+ var/ct = initial(M.config_tag)
+ if(ct && ct == mode_name)
+ return new T
+ return new /datum/game_mode/extended()
+
+/datum/controller/configuration/proc/get_runnable_modes()
+ var/list/runnable_modes = list()
+ var/list/probabilities = CONFIG_GET(keyed_list/probabilities)
+
+ for(var/T in gamemode_cache)
+ var/datum/game_mode/M = new T()
+ if(!(M.config_tag in modes))
+ qdel(M)
+ continue
+ if(probabilities[M.config_tag] <= 0)
+ qdel(M)
+ continue
+ if(M.can_start())
+ var/final_weight = probabilities[M.config_tag]
+ runnable_modes[M] = final_weight
+
+ return runnable_modes
diff --git a/code/controllers/master.dm b/code/controllers/master.dm
index 049e687a95..b68b4e01c0 100644
--- a/code/controllers/master.dm
+++ b/code/controllers/master.dm
@@ -177,7 +177,7 @@ GLOBAL_REAL(Master, /datum/controller/master) = new
var/start_timeofday = REALTIMEOFDAY
// Initialize subsystems.
- current_ticklimit = config.tick_limit_mc_init
+ current_ticklimit = CONFIG_GET(number/tick_limit_mc_init)
for (var/datum/controller/subsystem/SS in subsystems)
if (SS.flags & SS_NO_INIT)
continue
@@ -193,7 +193,7 @@ GLOBAL_REAL(Master, /datum/controller/master) = new
if (!current_runlevel)
SetRunLevel(RUNLEVEL_LOBBY)
- GLOB.revdata = new // It can load revdata now, from tgs or .git or whatever
+ // GLOB.revdata = new // It can load revdata now, from tgs or .git or whatever
// Sort subsystems by display setting for easy access.
sortTim(subsystems, GLOBAL_PROC_REF(cmp_subsystem_display))
@@ -203,7 +203,7 @@ GLOBAL_REAL(Master, /datum/controller/master) = new
#else
world.sleep_offline = 1
#endif
- world.change_fps(config.fps)
+ world.change_fps(CONFIG_GET(number/fps))
var/initialized_tod = REALTIMEOFDAY
sleep(1)
initializations_finished_with_no_players_logged_in = initialized_tod < REALTIMEOFDAY - 10
@@ -611,3 +611,8 @@ GLOBAL_REAL(Master, /datum/controller/master) = new
map_loading = FALSE
for(var/datum/controller/subsystem/SS as anything in subsystems)
SS.StopLoadingMap()
+
+/datum/controller/master/proc/OnConfigLoad()
+ for (var/thing in subsystems)
+ var/datum/controller/subsystem/SS = thing
+ SS.OnConfigLoad()
diff --git a/code/controllers/subsystem.dm b/code/controllers/subsystem.dm
index 9c5fcbe5cb..3cd8af77fe 100644
--- a/code/controllers/subsystem.dm
+++ b/code/controllers/subsystem.dm
@@ -152,6 +152,8 @@
if(SS_SLEEPING)
state = SS_PAUSING
+/// Called after the config has been loaded or reloaded.
+/datum/controller/subsystem/proc/OnConfigLoad()
//used to initialize the subsystem AFTER the map has loaded
/datum/controller/subsystem/Initialize(start_timeofday)
diff --git a/code/controllers/subsystems/assets.dm b/code/controllers/subsystems/assets.dm
index 49e8a8f578..d34d05ff55 100644
--- a/code/controllers/subsystems/assets.dm
+++ b/code/controllers/subsystems/assets.dm
@@ -6,9 +6,9 @@ SUBSYSTEM_DEF(assets)
var/list/preload = list()
var/datum/asset_transport/transport = new()
-/datum/controller/subsystem/assets/proc/OnConfigLoad()
+/datum/controller/subsystem/assets/OnConfigLoad()
var/newtransporttype = /datum/asset_transport
- switch (config.asset_transport)
+ switch (CONFIG_GET(string/asset_transport))
if ("webroot")
newtransporttype = /datum/asset_transport/webroot
diff --git a/code/controllers/subsystems/inactivity.dm b/code/controllers/subsystems/inactivity.dm
index c921cff022..bc7a5a7dde 100644
--- a/code/controllers/subsystems/inactivity.dm
+++ b/code/controllers/subsystems/inactivity.dm
@@ -6,7 +6,7 @@ SUBSYSTEM_DEF(inactivity)
var/number_kicked = 0
/datum/controller/subsystem/inactivity/fire(resumed = FALSE)
- if (!config.kick_inactive)
+ if (!CONFIG_GET(number/kick_inactive))
can_fire = FALSE
return
if (!resumed)
@@ -15,8 +15,8 @@ SUBSYSTEM_DEF(inactivity)
while(client_list.len)
var/client/C = client_list[client_list.len]
client_list.len--
- if(C.is_afk(config.kick_inactive MINUTES) && can_kick(C))
- to_chat_immediate(C, world.time, span_warning("You have been inactive for more than [config.kick_inactive] minute\s and have been disconnected."))
+ if(C.is_afk(CONFIG_GET(number/kick_inactive) MINUTES) && can_kick(C))
+ to_chat_immediate(C, world.time, span_warning("You have been inactive for more than [CONFIG_GET(number/kick_inactive)] minute\s and have been disconnected."))
var/information
if(C.mob)
diff --git a/code/controllers/subsystems/lighting.dm b/code/controllers/subsystems/lighting.dm
index 522bab602b..d9643c15ba 100644
--- a/code/controllers/subsystems/lighting.dm
+++ b/code/controllers/subsystems/lighting.dm
@@ -14,7 +14,7 @@ SUBSYSTEM_DEF(lighting)
/datum/controller/subsystem/lighting/Initialize(timeofday)
if(!subsystem_initialized)
- if (config.starlight)
+ if (CONFIG_GET(flag/starlight))
for(var/area/A in world)
if (A.dynamic_lighting == DYNAMIC_LIGHTING_IFSTARLIGHT)
A.luminosity = 0
diff --git a/code/controllers/subsystems/mapping.dm b/code/controllers/subsystems/mapping.dm
index 38dda58e34..ce4d200d45 100644
--- a/code/controllers/subsystems/mapping.dm
+++ b/code/controllers/subsystems/mapping.dm
@@ -20,7 +20,7 @@ SUBSYSTEM_DEF(mapping)
maploader = new()
load_map_templates()
- if(config.generate_map)
+ if(CONFIG_GET(flag/generate_map))
// Map-gen is still very specific to the map, however putting it here should ensure it loads in the correct order.
using_map.perform_map_generation()
@@ -52,8 +52,8 @@ SUBSYSTEM_DEF(mapping)
// Choose an engine type
var/datum/map_template/engine/chosen_type = null
- if (LAZYLEN(config.engine_map))
- var/chosen_name = pick(config.engine_map)
+ if (LAZYLEN(CONFIG_GET(str_list/engine_map)))
+ var/chosen_name = pick(CONFIG_GET(str_list/engine_map))
chosen_type = map_templates[chosen_name]
if(!istype(chosen_type))
error("Configured engine map [chosen_name] is not a valid engine map name!")
diff --git a/code/controllers/subsystems/media_tracks.dm b/code/controllers/subsystems/media_tracks.dm
index 8ec57d7389..9aa59f95fe 100644
--- a/code/controllers/subsystems/media_tracks.dm
+++ b/code/controllers/subsystems/media_tracks.dm
@@ -16,7 +16,7 @@ SUBSYSTEM_DEF(media_tracks)
return ..()
/datum/controller/subsystem/media_tracks/proc/load_tracks()
- for(var/filename in config.jukebox_track_files)
+ for(var/filename in CONFIG_GET(str_list/jukebox_track_files))
report_progress("Loading jukebox track: [filename]")
if(!fexists(filename))
diff --git a/code/controllers/subsystems/nightshift.dm b/code/controllers/subsystems/nightshift.dm
index 91b1c6bb35..4cfddfec0f 100644
--- a/code/controllers/subsystems/nightshift.dm
+++ b/code/controllers/subsystems/nightshift.dm
@@ -11,7 +11,7 @@ SUBSYSTEM_DEF(nightshift)
var/high_security_mode = FALSE
/datum/controller/subsystem/nightshift/Initialize()
- if(!config.enable_night_shifts)
+ if(!CONFIG_GET(flag/enable_night_shifts))
can_fire = FALSE
/*
if(config.randomize_shift_time)
diff --git a/code/controllers/subsystems/persist_vr.dm b/code/controllers/subsystems/persist_vr.dm
index 5217b72f9a..d74b96f960 100644
--- a/code/controllers/subsystems/persist_vr.dm
+++ b/code/controllers/subsystems/persist_vr.dm
@@ -16,7 +16,7 @@ SUBSYSTEM_DEF(persist)
// Do PTO Accruals
/datum/controller/subsystem/persist/proc/update_department_hours(var/resumed = FALSE)
- if(!config.time_off)
+ if(!CONFIG_GET(flag/time_off))
return
establish_db_connection()
@@ -78,7 +78,7 @@ SUBSYSTEM_DEF(persist)
play_hours[department_earning] = wait_in_hours
// Cap it
- dept_hours[department_earning] = min(config.pto_cap, dept_hours[department_earning])
+ dept_hours[department_earning] = min(CONFIG_GET(number/pto_cap), dept_hours[department_earning])
// Okay we figured it out, lets update database!
var/sql_ckey = sql_sanitize_text(C.ckey)
@@ -104,4 +104,4 @@ SUBSYSTEM_DEF(persist)
// They have a custom title, aren't crew, or someone deleted their record, so we need a fallback method.
// Let's check the mind.
if(M.mind && M.mind.assigned_role)
- . = job_master.GetJob(M.mind.assigned_role)
\ No newline at end of file
+ . = job_master.GetJob(M.mind.assigned_role)
diff --git a/code/controllers/subsystems/persistence.dm b/code/controllers/subsystems/persistence.dm
index e20c83e5a5..bd7e978363 100644
--- a/code/controllers/subsystems/persistence.dm
+++ b/code/controllers/subsystems/persistence.dm
@@ -25,7 +25,7 @@ SUBSYSTEM_DEF(persistence)
/datum/controller/subsystem/persistence/proc/track_value(var/atom/value, var/track_type)
- if(config.persistence_disabled) //if the config is set to persistence disabled, nothing will save or load.
+ if(CONFIG_GET(flag/persistence_disabled)) //if the config is set to persistence disabled, nothing will save or load.
return
var/turf/T = get_turf(value)
diff --git a/code/controllers/subsystems/radiation.dm b/code/controllers/subsystems/radiation.dm
index 967c21992f..167dc9314c 100644
--- a/code/controllers/subsystems/radiation.dm
+++ b/code/controllers/subsystems/radiation.dm
@@ -24,7 +24,7 @@ SUBSYSTEM_DEF(radiation)
if(QDELETED(S))
sources -= S
else if(S.decay)
- S.update_rad_power(S.rad_power - config.radiation_decay_rate)
+ S.update_rad_power(S.rad_power - CONFIG_GET(number/radiation_decay_rate))
if (MC_TICK_CHECK)
return
@@ -93,12 +93,12 @@ SUBSYSTEM_DEF(radiation)
origin.calc_rad_resistance()
if(origin.cached_rad_resistance)
- if(config.radiation_resistance_calc_mode == RAD_RESIST_CALC_DIV)
- working = round((working / (origin.cached_rad_resistance * config.radiation_resistance_multiplier)), 0.01)
- else if(config.radiation_resistance_calc_mode == RAD_RESIST_CALC_SUB)
- working = round((working - (origin.cached_rad_resistance * config.radiation_resistance_multiplier)), 0.01)
+ if(CONFIG_GET(flag/radiation_resistance_calc_mode) == RAD_RESIST_CALC_DIV)
+ working = round((working / (origin.cached_rad_resistance * CONFIG_GET(number/radiation_resistance_multiplier))), 0.01)
+ else if(CONFIG_GET(flag/radiation_resistance_calc_mode) == RAD_RESIST_CALC_SUB)
+ working = round((working - (origin.cached_rad_resistance * CONFIG_GET(number/radiation_resistance_multiplier))), 0.01)
- if(working <= config.radiation_lower_limit) // Too far from this source
+ if(working <= CONFIG_GET(number/radiation_lower_limit)) // Too far from this source
working = 0 // May as well be 0
break
@@ -106,7 +106,7 @@ SUBSYSTEM_DEF(radiation)
// Shouldn't really ever have practical uses, but standing in a room literally made from uranium is more dangerous than standing next to a single uranium vase
. += working / (dist ** 2)
- if(. <= config.radiation_lower_limit)
+ if(. <= CONFIG_GET(number/radiation_lower_limit))
. = 0
// Add a radiation source instance to the repository. It will override any existing source on the same turf.
diff --git a/code/controllers/subsystems/sqlite.dm b/code/controllers/subsystems/sqlite.dm
index 20a5a59475..b4074b3355 100644
--- a/code/controllers/subsystems/sqlite.dm
+++ b/code/controllers/subsystems/sqlite.dm
@@ -14,7 +14,7 @@ SUBSYSTEM_DEF(sqlite)
return ..()
/datum/controller/subsystem/sqlite/proc/connect()
- if(!config.sqlite_enabled)
+ if(!CONFIG_GET(flag/sqlite_enabled))
return
if(!sqlite_db)
@@ -104,17 +104,17 @@ SUBSYSTEM_DEF(sqlite)
return !sqlite_check_for_errors(query, "Insert Feedback")
/datum/controller/subsystem/sqlite/proc/can_submit_feedback(client/C)
- if(!config.sqlite_enabled)
+ if(!CONFIG_GET(flag/sqlite_enabled))
return FALSE
- if(config.sqlite_feedback_min_age && !is_old_enough(C))
+ if(CONFIG_GET(number/sqlite_feedback_min_age) && !is_old_enough(C))
return FALSE
- if(config.sqlite_feedback_cooldown > 0 && get_feedback_cooldown(C.key, config.sqlite_feedback_cooldown, sqlite_db) > 0)
+ if(CONFIG_GET(number/sqlite_feedback_cooldown) > 0 && get_feedback_cooldown(C.key, CONFIG_GET(number/sqlite_feedback_cooldown), sqlite_db) > 0)
return FALSE
return TRUE
// Returns TRUE if the player is 'old' enough, according to the config.
/datum/controller/subsystem/sqlite/proc/is_old_enough(client/C)
- if(get_player_age(C.key) < config.sqlite_feedback_min_age)
+ if(get_player_age(C.key) < CONFIG_GET(number/sqlite_feedback_min_age))
return FALSE
return TRUE
diff --git a/code/controllers/subsystems/ticker.dm b/code/controllers/subsystems/ticker.dm
index 5b4ad3c60f..1868f1883f 100644
--- a/code/controllers/subsystems/ticker.dm
+++ b/code/controllers/subsystems/ticker.dm
@@ -51,8 +51,8 @@ var/global/datum/controller/subsystem/ticker/ticker
global.ticker = src // TODO - Remove this! Change everything to point at SSticker intead
/datum/controller/subsystem/ticker/Initialize()
- pregame_timeleft = config.pregame_time
- send2mainirc("Server lobby is loaded and open at byond://[config.serverurl ? config.serverurl : (config.server ? config.server : "[world.address]:[world.port]")]")
+ pregame_timeleft = CONFIG_GET(number/pregame_time)
+ send2mainirc("Server lobby is loaded and open at byond://[CONFIG_GET(string/serverurl) ? CONFIG_GET(string/serverurl) : (CONFIG_GET(string/server) ? CONFIG_GET(string/server) : "[world.address]:[world.port]")]")
SSwebhooks.send(
WEBHOOK_ROUNDPREP,
list(
@@ -108,7 +108,7 @@ var/global/datum/controller/subsystem/ticker/ticker
round_start_time = world.time // otherwise round_start_time would be 0 for the signals
if(!setup_choose_gamemode())
// It failed, go back to lobby state and re-send the welcome message
- pregame_timeleft = config.pregame_time
+ pregame_timeleft = CONFIG_GET(number/pregame_time)
// SSvote.gamemode_vote_called = FALSE // Allow another autogamemode vote
current_state = GAME_STATE_PREGAME
Master.SetRunLevel(RUNLEVEL_LOBBY)
@@ -135,8 +135,8 @@ var/global/datum/controller/subsystem/ticker/ticker
if(!src.mode)
var/list/weighted_modes = list()
for(var/datum/game_mode/GM in runnable_modes)
- weighted_modes[GM.config_tag] = config.probabilities[GM.config_tag]
- src.mode = gamemode_cache[pickweight(weighted_modes)]
+ weighted_modes[GM.config_tag] = CONFIG_GET(keyed_list/probabilities)[GM.config_tag]
+ src.mode = config.gamemode_cache[pickweight(weighted_modes)]
else
src.mode = config.pick_mode(master_mode)
@@ -150,7 +150,7 @@ var/global/datum/controller/subsystem/ticker/ticker
job_master.DivideOccupations() // Apparently important for new antagonist system to register specific job antags properly.
if(!src.mode.can_start())
- to_world(span_filter_system(span_bold("Unable to start [mode.name].") + " Not enough players readied, [config.player_requirements[mode.config_tag]] players needed. Reverting to pregame lobby."))
+ to_world(span_filter_system(span_bold("Unable to start [mode.name].") + " Not enough players readied, [CONFIG_GET(keyed_list/player_requirements)[mode.config_tag]] players needed. Reverting to pregame lobby."))
mode.fail_setup()
mode = null
job_master.ResetOccupations()
@@ -198,7 +198,7 @@ var/global/datum/controller/subsystem/ticker/ticker
current_state = GAME_STATE_PLAYING
Master.SetRunLevel(RUNLEVEL_GAME)
- if(config.sql_enabled)
+ if(CONFIG_GET(flag/sql_enabled))
statistic_cycle() // Polls population totals regularly and stores them in an SQL DB -- TLE
return 1
@@ -214,7 +214,7 @@ var/global/datum/controller/subsystem/ticker/ticker
// Calculate if game and/or mode are finished (Complicated by the continuous_rounds config option)
var/game_finished = FALSE
var/mode_finished = FALSE
- if (config.continous_rounds) // Game keeps going after mode ends.
+ if (CONFIG_GET(flag/continuous_rounds)) // Game keeps going after mode ends.
game_finished = (emergency_shuttle.returned() || mode.station_was_nuked)
mode_finished = ((end_game_state >= END_GAME_MODE_FINISHED) || mode.check_finished()) // Short circuit if already finished.
else // Game ends when mode does
diff --git a/code/datums/ai_law_sets.dm b/code/datums/ai_law_sets.dm
index 8682324552..38d99905dc 100644
--- a/code/datums/ai_law_sets.dm
+++ b/code/datums/ai_law_sets.dm
@@ -27,7 +27,7 @@
selectable = 0
/datum/ai_laws/nanotrasen/malfunction/New()
- set_zeroth_law(config.law_zero)
+ set_zeroth_law(CONFIG_GET(string/law_zero))
..()
/************* NanoTrasen Aggressive *************/
diff --git a/code/datums/helper_datums/getrev.dm b/code/datums/helper_datums/getrev.dm
index 1cce0db9c5..626e65bbd2 100644
--- a/code/datums/helper_datums/getrev.dm
+++ b/code/datums/helper_datums/getrev.dm
@@ -1,5 +1,3 @@
-GLOBAL_DATUM(revdata, /datum/getrev)
-
/datum/getrev
var/branch
var/revision
@@ -50,7 +48,7 @@ GLOBAL_DATUM(revdata, /datum/getrev)
var/details = ": '" + html_encode(tm.title) + "' by " + html_encode(tm.author) + " at commit " + html_encode(copytext_char(cm, 1, 11))
if(details && findtext(details, "\[s\]") && (!usr || !usr.client.holder))
continue
- . += "#[tm.number][details]"
+ . += "#[tm.number][details]"
/client/verb/showrevinfo()
set category = "OOC"
@@ -65,8 +63,8 @@ GLOBAL_DATUM(revdata, /datum/getrev)
if(GLOB.revdata.revision)
msg += span_bold("Server revision:") + " B:[GLOB.revdata.branch] D:[GLOB.revdata.date]"
- if(config.githuburl)
- msg += span_bold("Commit:") + " [GLOB.revdata.revision]"
+ if(CONFIG_GET(string/githuburl))
+ msg += span_bold("Commit:") + " [GLOB.revdata.revision]"
else
msg += span_bold("Commit:") + " GLOB.revdata.revision"
else
diff --git a/code/datums/managed_browsers/feedback_form.dm b/code/datums/managed_browsers/feedback_form.dm
index d44b1265f6..15bf63f535 100644
--- a/code/datums/managed_browsers/feedback_form.dm
+++ b/code/datums/managed_browsers/feedback_form.dm
@@ -19,7 +19,7 @@ GENERAL_PROTECT_DATUM(/datum/managed_browser/feedback_form)
var/feedback_hide_author = FALSE
/datum/managed_browser/feedback_form/New(client/new_client)
- feedback_topic = config.sqlite_feedback_topics[1]
+ feedback_topic = CONFIG_GET(str_list/sqlite_feedback_topics)[1]
..(new_client)
/datum/managed_browser/feedback_form/Destroy()
@@ -29,7 +29,7 @@ GENERAL_PROTECT_DATUM(/datum/managed_browser/feedback_form)
// Privacy option is allowed if both the config allows it, and the pepper file exists and isn't blank.
/datum/managed_browser/feedback_form/proc/can_be_private()
- return config.sqlite_feedback_privacy && SSsqlite.get_feedback_pepper()
+ return CONFIG_GET(flag/sqlite_feedback_privacy) && SSsqlite.get_feedback_pepper()
/datum/managed_browser/feedback_form/display()
if(!my_client)
@@ -70,10 +70,11 @@ GENERAL_PROTECT_DATUM(/datum/managed_browser/feedback_form)
dat += my_client.ckey
dat += "
"
- if(config.sqlite_feedback_topics.len > 1)
+ var/list/sqlite_feedback_topics = CONFIG_GET(str_list/sqlite_feedback_topics)
+ if(sqlite_feedback_topics.len > 1)
dat += "Topic: [href(src, list("feedback_choose_topic" = 1), feedback_topic)]
"
else
- dat += "Topic: [config.sqlite_feedback_topics[1]]
"
+ dat += "Topic: [sqlite_feedback_topics[1]]
"
dat += "
"
if(feedback_body)
@@ -84,8 +85,8 @@ GENERAL_PROTECT_DATUM(/datum/managed_browser/feedback_form)
dat += href(src, list("feedback_edit_body" = 1), "Edit")
dat += "