From b6a6d4971462511c16e9f7524cdc2bc30db97765 Mon Sep 17 00:00:00 2001 From: Patrick Meade Date: Wed, 11 Mar 2020 04:52:12 -0500 Subject: [PATCH] Cleaned up bunker automation logic, added admin control verb --- code/modules/admin/admin_verbs.dm | 20 ++++++++++++++++++-- code/modules/client/client procs.dm | 15 ++++++++------- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/code/modules/admin/admin_verbs.dm b/code/modules/admin/admin_verbs.dm index b77eea08b7b..cbeccb337d9 100644 --- a/code/modules/admin/admin_verbs.dm +++ b/code/modules/admin/admin_verbs.dm @@ -78,7 +78,8 @@ var/list/admin_verbs_admin = list( /client/proc/toggle_advanced_interaction, /*toggle admin ability to interact with not only machines, but also atoms such as buttons and doors*/ /client/proc/list_ssds_afks, /client/proc/cmd_admin_headset_message, - /client/proc/spawn_floor_cluwne + /client/proc/spawn_floor_cluwne, + /client/proc/set_server_capacity ) var/list/admin_verbs_ban = list( /client/proc/unban_panel, @@ -143,7 +144,8 @@ var/list/admin_verbs_server = list( /client/proc/toggle_antagHUD_use, /client/proc/toggle_antagHUD_restrictions, /client/proc/set_ooc, - /client/proc/reset_ooc + /client/proc/reset_ooc, + /client/proc/set_server_capacity ) var/list/admin_verbs_debug = list( /client/proc/cmd_admin_list_open_jobs, @@ -1016,3 +1018,17 @@ var/list/admin_verbs_ticket = list( log_admin("[key_name(usr)] has [advanced_admin_interaction ? "activated" : "deactivated"] their advanced admin interaction.") message_admins("[key_name_admin(usr)] has [advanced_admin_interaction ? "activated" : "deactivated"] their advanced admin interaction.") + +/client/proc/set_server_capacity() + set name = "Set Server Capacity" + set category = "Admin" + set desc = "Prevent new players connecting when over capacity." + + if(!check_rights(R_ADMIN)) + return + + var/capacity = input("Please input the new Server Capacity (player count)", "Set Server Capacity", 150) as num + config.panic_bunker_threshold = Clamp(capacity, 0, 500) + + log_admin("[key_name(usr)] has set the Server Capacity to [capacity].") + message_admins("[key_name_admin(usr)] has set the Server Capacity to [capacity].") diff --git a/code/modules/client/client procs.dm b/code/modules/client/client procs.dm index e504a796052..76637f6568b 100644 --- a/code/modules/client/client procs.dm +++ b/code/modules/client/client procs.dm @@ -417,13 +417,14 @@ // Update the state of the panic bunker based on current playercount var/threshold = config.panic_bunker_threshold - if((playercount > threshold) && (GLOB.panic_bunker_enabled == FALSE)) - GLOB.panic_bunker_enabled = TRUE - message_admins("Panic bunker has been automatically enabled due to playercount rising above [threshold]") - - if((playercount < threshold) && (GLOB.panic_bunker_enabled == TRUE)) - GLOB.panic_bunker_enabled = FALSE - message_admins("Panic bunker has been automatically disabled due to playercount dropping below [threshold]") + if(GLOB.panic_bunker_enabled) + if(playercount < threshold) + GLOB.panic_bunker_enabled = FALSE + message_admins("Panic bunker has been automatically disabled due to playercount dropping below Server Capacity [threshold]") + else + if(playercount > threshold) + GLOB.panic_bunker_enabled = TRUE + message_admins("Panic bunker has been automatically enabled due to playercount rising above Server Capacity [threshold]") /client/proc/is_connecting_from_localhost() var/localhost_addresses = list("127.0.0.1", "::1") // Adresses