From 817773b692b9f49a56d23b672ec5389389f6f36f Mon Sep 17 00:00:00 2001 From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com> Date: Tue, 24 Mar 2026 21:51:17 +0000 Subject: [PATCH] Puts server regions behind a define (#31766) --- code/_compile_options.dm | 3 +++ .../configuration/sections/system_configuration.dm | 4 ++++ code/game/world.dm | 6 ++++++ code/modules/client/client_procs.dm | 5 +++++ code/modules/client/preference/preferences_mysql.dm | 3 +++ code/modules/mob/new_player/new_player.dm | 4 ++++ 6 files changed, 25 insertions(+) diff --git a/code/_compile_options.dm b/code/_compile_options.dm index da63456b376..0b7d0978fd0 100644 --- a/code/_compile_options.dm +++ b/code/_compile_options.dm @@ -15,6 +15,9 @@ // Uncomment this to enable support for multiple instances // #define MULTIINSTANCE +// Uncomment this to enable support for server regions +// #define SERVERREGIONS + #ifdef LOCAL_GAME_TESTS #define GAME_TESTS #define MAP_TESTS diff --git a/code/controllers/configuration/sections/system_configuration.dm b/code/controllers/configuration/sections/system_configuration.dm index 4e9393ed734..eac494de3e0 100644 --- a/code/controllers/configuration/sections/system_configuration.dm +++ b/code/controllers/configuration/sections/system_configuration.dm @@ -29,7 +29,9 @@ /// Map datum of the map to use, overriding the defaults, and `data/next_map.txt` var/override_map = null /// Assoc list of region names and their server IPs. Used for geo-routing. + #ifdef SERVERREGIONS var/list/region_map = list() + #endif /// Send a system toast on init completion? var/toast_on_init_complete = FALSE /// The URL for a ss13-yt-wrap server (https://github.com/Absolucy/ss13-yt-wrap) to use. @@ -59,7 +61,9 @@ // Load region overrides + #ifdef SERVERREGIONS if(islist(data["regional_servers"])) region_map.Cut() for(var/list/kvset in data["regional_servers"]) region_map[kvset["name"]] = kvset["ip"] + #endif diff --git a/code/game/world.dm b/code/game/world.dm index 85bb5732836..f65feeea907 100644 --- a/code/game/world.dm +++ b/code/game/world.dm @@ -159,6 +159,7 @@ GLOBAL_LIST_EMPTY(world_topic_handlers) // Send the reboot banner to all players for(var/client/C in GLOB.clients) C?.tgui_panel?.send_roundrestart() + #ifdef SERVERREGIONS if(C.prefs.server_region) // Keep them on the same relay C << link(GLOB.configuration.system.region_map[C.prefs.server_region]) @@ -166,6 +167,11 @@ GLOBAL_LIST_EMPTY(world_topic_handlers) // Use the default if(GLOB.configuration.url.server_url) // If you set a server location in config.txt, it sends you there instead of trying to reconnect to the same world address. -- NeoFite C << link("byond://[GLOB.configuration.url.server_url]") + #else + // Use the default + if(GLOB.configuration.url.server_url) // If you set a server location in config.txt, it sends you there instead of trying to reconnect to the same world address. -- NeoFite + C << link("byond://[GLOB.configuration.url.server_url]") + #endif // And begin the real shutdown rustlibs_log_close_all() // Past this point, no logging procs can be used, at risk of data loss. diff --git a/code/modules/client/client_procs.dm b/code/modules/client/client_procs.dm index b84c479ae7e..2ee79a56a3a 100644 --- a/code/modules/client/client_procs.dm +++ b/code/modules/client/client_procs.dm @@ -455,9 +455,12 @@ if(holder && holder.restricted_by_2fa) to_chat(src,SPAN_BOLDANNOUNCEOOC("You do not have 2FA enabled. Admin verbs will be unavailable until you have enabled 2FA.\nTo setup 2FA, head to the following menu: Game Preferences")) // Very fucking obvious + + #ifdef SERVERREGIONS // Tell client about their connection to_chat(src, SPAN_NOTICE("You are currently connected [prefs.server_region ? "via the [prefs.server_region] relay" : "directly"] to Paradise.")) to_chat(src, SPAN_NOTICE("You can change this using the Change Region verb in the OOC tab, as selecting a region closer to you may reduce latency.")) + #endif display_job_bans(TRUE) /client/proc/is_connecting_from_localhost() @@ -1150,6 +1153,7 @@ popup.set_content(output) popup.open(FALSE) +#ifdef SERVERREGIONS /client/verb/change_region() set category = "OOC" set name = "Change Region" @@ -1178,6 +1182,7 @@ src << link("byond://[GLOB.configuration.url.server_url]") else src << link(GLOB.configuration.system.region_map[choice]) +#endif /client/proc/set_eye(new_eye) if(new_eye == eye) diff --git a/code/modules/client/preference/preferences_mysql.dm b/code/modules/client/preference/preferences_mysql.dm index e52c7d617eb..6789a2d16f5 100644 --- a/code/modules/client/preference/preferences_mysql.dm +++ b/code/modules/client/preference/preferences_mysql.dm @@ -69,9 +69,12 @@ map_vote_pref_json = json_decode(raw_fptp) catch map_vote_pref_json = list() + + #ifdef SERVERREGIONS // Sanitize the region if(!(server_region in GLOB.configuration.system.region_map)) server_region = null // This region doesnt exist anymore + #endif return TRUE diff --git a/code/modules/mob/new_player/new_player.dm b/code/modules/mob/new_player/new_player.dm index 24706c7d83a..4abaf5514f8 100644 --- a/code/modules/mob/new_player/new_player.dm +++ b/code/modules/mob/new_player/new_player.dm @@ -83,8 +83,10 @@ if(GLOB.join_tos) output += "

Terms of Service

" + #ifdef SERVERREGIONS if(length(GLOB.configuration.system.region_map)) output += "

Set region (reduces ping)

" + #endif output += "" @@ -211,9 +213,11 @@ privacy_consent() return FALSE + #ifdef SERVERREGIONS if(href_list["setregion"]) usr.client.change_region() return FALSE + #endif if(href_list["late_join"]) if(!client.tos_consent)