From 6e08e3cd8db3c593870d56b44a7f9ee9dbb49891 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Tue, 13 Oct 2020 23:04:07 +0200 Subject: [PATCH] [MIRROR] Adds a living time config to the panic bunker (#1289) * Adds a living time config to the panic bunker (#54341) * Adds a living time value to the panic bunker, so you can keep people out based on time spent playing the game * updates the admin verb, and enables %minutes% as an option * Makes a proc call more clear Co-authored-by: Jared-Fogle <35135081+Jared-Fogle@ users.noreply.github.com> * than Co-authored-by: Jared-Fogle <35135081+Jared-Fogle@ users.noreply.github.com> * Adds a living time config to the panic bunker Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com> Co-authored-by: Jared-Fogle <35135081+Jared-Fogle@ users.noreply.github.com> --- .../configuration/entries/general.dm | 2 ++ code/modules/admin/verbs/panicbunker.dm | 14 +++++++++++--- code/modules/client/client_procs.dm | 19 ++++++++++++++----- config/config.txt | 6 +++++- 4 files changed, 32 insertions(+), 9 deletions(-) diff --git a/code/controllers/configuration/entries/general.dm b/code/controllers/configuration/entries/general.dm index bd3d5ae5010..3d0646da4c7 100644 --- a/code/controllers/configuration/entries/general.dm +++ b/code/controllers/configuration/entries/general.dm @@ -312,6 +312,8 @@ /datum/config_entry/flag/panic_bunker // prevents people the server hasn't seen before from connecting +/datum/config_entry/number/panic_bunker_living // living time in minutes that a player needs to pass the panic bunker + /datum/config_entry/string/panic_bunker_message config_entry_value = "Sorry but the server is currently not accepting connections from never before seen players." diff --git a/code/modules/admin/verbs/panicbunker.dm b/code/modules/admin/verbs/panicbunker.dm index c86a1e972fa..846e5f9530a 100644 --- a/code/modules/admin/verbs/panicbunker.dm +++ b/code/modules/admin/verbs/panicbunker.dm @@ -6,10 +6,18 @@ return var/new_pb = !CONFIG_GET(flag/panic_bunker) + var/time_rec = 0 + var/message = "" + if(new_pb) + time_rec = input(src, "How many living minutes should they need to play?", "Shit's fucked isn't it", CONFIG_GET(number/panic_bunker_living)) as num + message = input(src, "What should they see when they log in?", "MMM", CONFIG_GET(string/panic_bunker_message)) as text + message = replacetext(message, "%minutes%", time_rec) + CONFIG_SET(number/panic_bunker_living, time_rec) + CONFIG_SET(string/panic_bunker_message, message) + CONFIG_SET(flag/panic_bunker, new_pb) - - log_admin("[key_name(usr)] has toggled the Panic Bunker, it is now [new_pb ? "on" : "off"]") - message_admins("[key_name_admin(usr)] has toggled the Panic Bunker, it is now [new_pb ? "enabled" : "disabled"].") + log_admin("[key_name(usr)] has toggled the Panic Bunker, it is now [new_pb ? "on and set to [time_rec] with a message of [message]" : "off"]") + message_admins("[key_name_admin(usr)] has toggled the Panic Bunker, it is now [new_pb ? "enabled with a living minutes requirement of [time_rec]" : "disabled"].") if (new_pb && !SSdbcore.Connect()) message_admins("The Database is not connected! Panic bunker will not work until the connection is reestablished.") SSblackbox.record_feedback("nested tally", "admin_toggle", 1, list("Toggle Panic Bunker", "[new_pb ? "Enabled" : "Disabled"]")) //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! diff --git a/code/modules/client/client_procs.dm b/code/modules/client/client_procs.dm index b925057af99..f761a7b57a2 100644 --- a/code/modules/client/client_procs.dm +++ b/code/modules/client/client_procs.dm @@ -544,11 +544,19 @@ GLOBAL_LIST_INIT(blacklisted_builds, list( if(!query_client_in_db.Execute()) qdel(query_client_in_db) return - if(!query_client_in_db.NextRow()) - if (CONFIG_GET(flag/panic_bunker) && !holder && !GLOB.deadmins[ckey]) - log_access("Failed Login: [key] - New account attempting to connect during panic bunker") - message_admins("Failed Login: [key] - New account attempting to connect during panic bunker") - to_chat(src, CONFIG_GET(string/panic_bunker_message)) + + //If we aren't an admin, and the flag is set + if(CONFIG_GET(flag/panic_bunker) && !holder && !GLOB.deadmins[ckey]) + var/living_recs = CONFIG_GET(number/panic_bunker_living) + //Relies on pref existing, but this proc is only called after that occurs, so we're fine. + var/minutes = get_exp_living(pure_numeric = TRUE) + if(minutes <= living_recs) + var/reject_message = "Failed Login: [key] - Account attempting to connect during panic bunker, but they do not have the required living time [minutes]/[living_recs]" + log_access(reject_message) + message_admins("[reject_message]") + var/message = CONFIG_GET(string/panic_bunker_message) + message = replacetext(message, "%minutes%", living_recs) + to_chat(src, message) var/list/connectiontopic_a = params2list(connectiontopic) var/list/panic_addr = CONFIG_GET(string/panic_server_address) if(panic_addr && !connectiontopic_a["redirect"]) @@ -560,6 +568,7 @@ GLOBAL_LIST_INIT(blacklisted_builds, list( qdel(src) return + if(!query_client_in_db.NextRow()) new_player = 1 account_join_date = findJoinDate() var/datum/db_query/query_add_player = SSdbcore.NewQuery({" diff --git a/config/config.txt b/config/config.txt index 27a2bf9e555..fae8632666d 100644 --- a/config/config.txt +++ b/config/config.txt @@ -343,8 +343,12 @@ NOTIFY_NEW_PLAYER_ACCOUNT_AGE 1 ## Requires database #PANIC_BUNKER +## If a player connects during a bunker with less then or this amount of living time (Minutes), we deny the connection +#PANIC_BUNKER_LIVING 90 + ## The message the Panic Bunker gives when someone is rejected by it -#PANIC_BUNKER_MESSAGE Sorry, but the server is currently not accepting connections from never before seen players. +## %minutes% is replaced with PANIC_BUNKER_LIVING on runtime, remove it if you don't want this +#PANIC_BUNKER_MESSAGE Sorry, but the server is currently not accepting connections from players with less than %minutes% minutes of living time. ## If panic bunker is on and a player is rejected (see above), attempt to send them to this connected server (see below) instead. ## You probably want this to be the same as CROSS_SERVER_ADDRESS