From 463036a4f431f92bf77b46c6f581f4fb7bc04783 Mon Sep 17 00:00:00 2001 From: Putnam Date: Sat, 1 Feb 2020 08:44:05 -0800 Subject: [PATCH 1/7] made panic bunker save in json --- code/controllers/subsystem/persistence.dm | 14 ++++++++++++++ code/datums/world_topic.dm | 3 +++ code/modules/admin/chat_commands.dm | 2 +- code/modules/admin/verbs/panicbunker.dm | 2 ++ code/modules/client/client_procs.dm | 2 ++ 5 files changed, 22 insertions(+), 1 deletion(-) diff --git a/code/controllers/subsystem/persistence.dm b/code/controllers/subsystem/persistence.dm index e43c8f21a2..532f1162f7 100644 --- a/code/controllers/subsystem/persistence.dm +++ b/code/controllers/subsystem/persistence.dm @@ -39,6 +39,7 @@ SUBSYSTEM_DEF(persistence) if(CONFIG_GET(flag/use_antag_rep)) LoadAntagReputation() LoadRandomizedRecipes() + LoadPanicBunker() return ..() /datum/controller/subsystem/persistence/proc/LoadSatchels() @@ -259,6 +260,12 @@ SUBSYSTEM_DEF(persistence) if(CONFIG_GET(flag/use_antag_rep)) CollectAntagReputation() SaveRandomizedRecipes() + SavePanicBunker() + +/datum/controller/subsystem/persistence/proc/LoadPanicBunker() + var/bunker_path = file("data/bunker_passthrough.json") + if(fexists(bunker_path)) + GLOB.bunker_passthrough = json_decode(file2text(bunker_path)) /datum/controller/subsystem/persistence/proc/GetPhotoAlbums() var/album_path = file("data/photo_albums.json") @@ -381,6 +388,13 @@ SUBSYSTEM_DEF(persistence) fdel(json_file) WRITE_FILE(json_file, json_encode(file_data)) +/datum/controller/subsystem/persistence/proc/SavePanicBunker() + var/json_file = file("data/bunker_passthrough.json") + var/list/file_data = list() + file_data["data"] = GLOB.bunker_passthrough + fdel(json_file) + WRITE_FILE(json_file,json_encode(file_data)) + /datum/controller/subsystem/persistence/proc/remove_duplicate_trophies(list/trophies) var/list/ukeys = list() . = list() diff --git a/code/datums/world_topic.dm b/code/datums/world_topic.dm index 49fdd64a72..8e16cd3d7f 100644 --- a/code/datums/world_topic.dm +++ b/code/datums/world_topic.dm @@ -187,3 +187,6 @@ if(!key_valid) GLOB.topic_status_cache = . + +/datum/world_topic/panic_bunker + \ No newline at end of file diff --git a/code/modules/admin/chat_commands.dm b/code/modules/admin/chat_commands.dm index 52ba3c521e..3adaabce5e 100644 --- a/code/modules/admin/chat_commands.dm +++ b/code/modules/admin/chat_commands.dm @@ -137,7 +137,7 @@ GLOBAL_LIST(round_end_notifiees) return "The Database is not enabled!" GLOB.bunker_passthrough |= ckey(params) - + log_admin("[sender.friendly_name] has added [params] to the current round's bunker bypass list.") message_admins("[sender.friendly_name] has added [params] to the current round's bunker bypass list.") return "[params] has been added to the current round's bunker bypass list." diff --git a/code/modules/admin/verbs/panicbunker.dm b/code/modules/admin/verbs/panicbunker.dm index 2897427d6f..58d84538ab 100644 --- a/code/modules/admin/verbs/panicbunker.dm +++ b/code/modules/admin/verbs/panicbunker.dm @@ -24,6 +24,7 @@ return GLOB.bunker_passthrough |= ckey(ckeytobypass) + SSpersistence.SavePanicBunker() log_admin("[key_name(usr)] has added [ckeytobypass] to the current round's bunker bypass list.") message_admins("[key_name_admin(usr)] has added [ckeytobypass] to the current round's bunker bypass list.") send2irc("Panic Bunker", "[key_name(usr)] has added [ckeytobypass] to the current round's bunker bypass list.") @@ -37,6 +38,7 @@ return GLOB.bunker_passthrough -= ckey(ckeytobypass) + SSpersistence.SavePanicBunker() log_admin("[key_name(usr)] has removed [ckeytobypass] from the current round's bunker bypass list.") message_admins("[key_name_admin(usr)] has removed [ckeytobypass] from the current round's bunker bypass list.") send2irc("Panic Bunker", "[key_name(usr)] has removed [ckeytobypass] from the current round's bunker bypass list.") diff --git a/code/modules/client/client_procs.dm b/code/modules/client/client_procs.dm index 7e466caf8a..884d9cdcb5 100644 --- a/code/modules/client/client_procs.dm +++ b/code/modules/client/client_procs.dm @@ -526,6 +526,8 @@ GLOBAL_LIST_EMPTY(external_rsc_urls) if(!account_join_date) account_join_date = "Error" account_age = -1 + else if(ckey in GLOB.bunker_passthrough) + GLOB.bunker_passthrough -= ckey qdel(query_client_in_db) var/datum/DBQuery/query_get_client_age = SSdbcore.NewQuery("SELECT firstseen, DATEDIFF(Now(),firstseen), accountjoindate, DATEDIFF(Now(),accountjoindate) FROM [format_table_name("player")] WHERE ckey = '[sql_ckey]'") if(!query_get_client_age.Execute()) From aba0379bfb4903349b4619c0c4d4161093fcdba7 Mon Sep 17 00:00:00 2001 From: Putnam Date: Sat, 1 Feb 2020 08:53:19 -0800 Subject: [PATCH 2/7] also need these! --- code/modules/admin/chat_commands.dm | 2 +- code/modules/client/client_procs.dm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/code/modules/admin/chat_commands.dm b/code/modules/admin/chat_commands.dm index 3adaabce5e..5743fe35b0 100644 --- a/code/modules/admin/chat_commands.dm +++ b/code/modules/admin/chat_commands.dm @@ -137,7 +137,7 @@ GLOBAL_LIST(round_end_notifiees) return "The Database is not enabled!" GLOB.bunker_passthrough |= ckey(params) - + SSpersistence.SavePanicBunker() //we can do this every time, it's okay log_admin("[sender.friendly_name] has added [params] to the current round's bunker bypass list.") message_admins("[sender.friendly_name] has added [params] to the current round's bunker bypass list.") return "[params] has been added to the current round's bunker bypass list." diff --git a/code/modules/client/client_procs.dm b/code/modules/client/client_procs.dm index 884d9cdcb5..3fefbe2141 100644 --- a/code/modules/client/client_procs.dm +++ b/code/modules/client/client_procs.dm @@ -502,7 +502,7 @@ GLOBAL_LIST_EMPTY(external_rsc_urls) if (CONFIG_GET(flag/panic_bunker) && !holder && !GLOB.deadmins[ckey] && !(ckey in GLOB.bunker_passthrough)) 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, "You must first join the Discord to verify your account before joining this server.
To do so, read the rules and post a request in the #station-access-requests channel under the \"Main server\" category in the Discord server linked here: https://discord.gg/E6SQuhz
") //CIT CHANGE - makes the panic bunker disconnect message point to the discord + to_chat(src, "You must first join the Discord to verify your account before joining this server.
To do so, read the rules and post a request in the #station-access-requests channel under the \"Main server\" category in the Discord server linked here: https://discord.gg/E6SQuhz
If you have already done so, wait a few minutes then try again; sometimes the server needs to fully load before you can join.
") //CIT CHANGE - makes the panic bunker disconnect message point to the discord var/list/connectiontopic_a = params2list(connectiontopic) var/list/panic_addr = CONFIG_GET(string/panic_server_address) if(panic_addr && !connectiontopic_a["redirect"]) From 3dcce2b43a3cb9475efa05b977f1c6716934a16b Mon Sep 17 00:00:00 2001 From: Putnam Date: Sat, 1 Feb 2020 09:10:02 -0800 Subject: [PATCH 3/7] added some cleanup code --- code/controllers/subsystem/persistence.dm | 4 ++++ code/modules/admin/chat_commands.dm | 1 + code/modules/admin/verbs/panicbunker.dm | 3 ++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/code/controllers/subsystem/persistence.dm b/code/controllers/subsystem/persistence.dm index 532f1162f7..3f4064d78c 100644 --- a/code/controllers/subsystem/persistence.dm +++ b/code/controllers/subsystem/persistence.dm @@ -266,6 +266,10 @@ SUBSYSTEM_DEF(persistence) var/bunker_path = file("data/bunker_passthrough.json") if(fexists(bunker_path)) GLOB.bunker_passthrough = json_decode(file2text(bunker_path)) + var/round_id = GLOB.round_id + for(var/ckey in GLOB.bunker_passthrough) + if(round_id - GLOB.bunker_passthrough[ckey] > 30) + GLOB.bunker_passthrough -= ckey /datum/controller/subsystem/persistence/proc/GetPhotoAlbums() var/album_path = file("data/photo_albums.json") diff --git a/code/modules/admin/chat_commands.dm b/code/modules/admin/chat_commands.dm index 5743fe35b0..fae6e155c7 100644 --- a/code/modules/admin/chat_commands.dm +++ b/code/modules/admin/chat_commands.dm @@ -137,6 +137,7 @@ GLOBAL_LIST(round_end_notifiees) return "The Database is not enabled!" GLOB.bunker_passthrough |= ckey(params) + GLOB.bunker_passthrough[ckey(params)] = GLOB.round_id SSpersistence.SavePanicBunker() //we can do this every time, it's okay log_admin("[sender.friendly_name] has added [params] to the current round's bunker bypass list.") message_admins("[sender.friendly_name] has added [params] to the current round's bunker bypass list.") diff --git a/code/modules/admin/verbs/panicbunker.dm b/code/modules/admin/verbs/panicbunker.dm index 58d84538ab..6e7191e67f 100644 --- a/code/modules/admin/verbs/panicbunker.dm +++ b/code/modules/admin/verbs/panicbunker.dm @@ -24,7 +24,8 @@ return GLOB.bunker_passthrough |= ckey(ckeytobypass) - SSpersistence.SavePanicBunker() + GLOB.bunker_passthrough[ckey(ckeytobypass)] = GLOB.round_id + SSpersistence.SavePanicBunker() //we can do this every time, it's okay log_admin("[key_name(usr)] has added [ckeytobypass] to the current round's bunker bypass list.") message_admins("[key_name_admin(usr)] has added [ckeytobypass] to the current round's bunker bypass list.") send2irc("Panic Bunker", "[key_name(usr)] has added [ckeytobypass] to the current round's bunker bypass list.") From 8d5839c2d2b964ed8d4d017ae3b93ba06d4aa6df Mon Sep 17 00:00:00 2001 From: Putnam Date: Sat, 1 Feb 2020 10:01:49 -0800 Subject: [PATCH 4/7] up to 100 it is then --- code/controllers/subsystem/persistence.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/controllers/subsystem/persistence.dm b/code/controllers/subsystem/persistence.dm index 3f4064d78c..352e18162b 100644 --- a/code/controllers/subsystem/persistence.dm +++ b/code/controllers/subsystem/persistence.dm @@ -268,7 +268,7 @@ SUBSYSTEM_DEF(persistence) GLOB.bunker_passthrough = json_decode(file2text(bunker_path)) var/round_id = GLOB.round_id for(var/ckey in GLOB.bunker_passthrough) - if(round_id - GLOB.bunker_passthrough[ckey] > 30) + if(round_id - GLOB.bunker_passthrough[ckey] > 100) GLOB.bunker_passthrough -= ckey /datum/controller/subsystem/persistence/proc/GetPhotoAlbums() From c829d974183ee1214e5aa6dc2d14578f2b77928a Mon Sep 17 00:00:00 2001 From: Putnam Date: Sat, 1 Feb 2020 11:18:22 -0800 Subject: [PATCH 5/7] whoops --- code/datums/world_topic.dm | 3 --- 1 file changed, 3 deletions(-) diff --git a/code/datums/world_topic.dm b/code/datums/world_topic.dm index 8e16cd3d7f..49fdd64a72 100644 --- a/code/datums/world_topic.dm +++ b/code/datums/world_topic.dm @@ -187,6 +187,3 @@ if(!key_valid) GLOB.topic_status_cache = . - -/datum/world_topic/panic_bunker - \ No newline at end of file From 82fbef992066bff7661728943e90ad53c7d4f67f Mon Sep 17 00:00:00 2001 From: Putnam Date: Mon, 3 Feb 2020 03:13:19 -0800 Subject: [PATCH 6/7] Made it real time, added to config --- code/controllers/configuration/entries/general.dm | 4 ++++ code/controllers/subsystem/persistence.dm | 2 +- code/modules/admin/chat_commands.dm | 2 +- code/modules/admin/verbs/panicbunker.dm | 2 +- config/config.txt | 2 ++ 5 files changed, 9 insertions(+), 3 deletions(-) diff --git a/code/controllers/configuration/entries/general.dm b/code/controllers/configuration/entries/general.dm index 2b3d9d2f72..c3ae90cc1b 100644 --- a/code/controllers/configuration/entries/general.dm +++ b/code/controllers/configuration/entries/general.dm @@ -431,3 +431,7 @@ /datum/config_entry/flag/log_pictures /datum/config_entry/flag/picture_logging_camera + +/datum/config_entry/number/max_bunker_days + config_entry_value = 7 + min_val = 1 diff --git a/code/controllers/subsystem/persistence.dm b/code/controllers/subsystem/persistence.dm index 352e18162b..a4466775ae 100644 --- a/code/controllers/subsystem/persistence.dm +++ b/code/controllers/subsystem/persistence.dm @@ -268,7 +268,7 @@ SUBSYSTEM_DEF(persistence) GLOB.bunker_passthrough = json_decode(file2text(bunker_path)) var/round_id = GLOB.round_id for(var/ckey in GLOB.bunker_passthrough) - if(round_id - GLOB.bunker_passthrough[ckey] > 100) + if(daysSince(GLOB.bunker_passthrough[ckey]) >= CONFIG_GET(number/max_bunker_days)) GLOB.bunker_passthrough -= ckey /datum/controller/subsystem/persistence/proc/GetPhotoAlbums() diff --git a/code/modules/admin/chat_commands.dm b/code/modules/admin/chat_commands.dm index fae6e155c7..e2ddcdcf6a 100644 --- a/code/modules/admin/chat_commands.dm +++ b/code/modules/admin/chat_commands.dm @@ -137,7 +137,7 @@ GLOBAL_LIST(round_end_notifiees) return "The Database is not enabled!" GLOB.bunker_passthrough |= ckey(params) - GLOB.bunker_passthrough[ckey(params)] = GLOB.round_id + GLOB.bunker_passthrough[ckey(params)] = world.realtime SSpersistence.SavePanicBunker() //we can do this every time, it's okay log_admin("[sender.friendly_name] has added [params] to the current round's bunker bypass list.") message_admins("[sender.friendly_name] has added [params] to the current round's bunker bypass list.") diff --git a/code/modules/admin/verbs/panicbunker.dm b/code/modules/admin/verbs/panicbunker.dm index 6e7191e67f..daaf15c70f 100644 --- a/code/modules/admin/verbs/panicbunker.dm +++ b/code/modules/admin/verbs/panicbunker.dm @@ -24,7 +24,7 @@ return GLOB.bunker_passthrough |= ckey(ckeytobypass) - GLOB.bunker_passthrough[ckey(ckeytobypass)] = GLOB.round_id + GLOB.bunker_passthrough[ckey(ckeytobypass)] = world.realtime SSpersistence.SavePanicBunker() //we can do this every time, it's okay log_admin("[key_name(usr)] has added [ckeytobypass] to the current round's bunker bypass list.") message_admins("[key_name_admin(usr)] has added [ckeytobypass] to the current round's bunker bypass list.") diff --git a/config/config.txt b/config/config.txt index a89827809f..6d302a5512 100644 --- a/config/config.txt +++ b/config/config.txt @@ -470,6 +470,8 @@ DISABLE_HIGH_POP_MC_MODE_AMOUNT 60 ## Uncomment to set the number of /world/Reboot()s before the DreamDaemon restarts itself. 0 means restart every round. Requires tgstation server tools. #ROUNDS_UNTIL_HARD_RESTART 10 +## Number of days for an individual panic bunker passthrough entry to be wiped. Note that they're also wiped as soon as a player is in the database. +#MAX_BUNKER_DAYS 7 ##Default screen resolution, in tiles. ## By default, this is 15x15, which gets simplified to 7 by BYOND, as it is a 1:1 screen ratio. From bc52b99758b3464e8293c2137119e06a60dfbcdc Mon Sep 17 00:00:00 2001 From: Putnam Date: Mon, 3 Feb 2020 03:27:06 -0800 Subject: [PATCH 7/7] ok putnam --- code/controllers/subsystem/persistence.dm | 1 - 1 file changed, 1 deletion(-) diff --git a/code/controllers/subsystem/persistence.dm b/code/controllers/subsystem/persistence.dm index a4466775ae..2825f4343b 100644 --- a/code/controllers/subsystem/persistence.dm +++ b/code/controllers/subsystem/persistence.dm @@ -266,7 +266,6 @@ SUBSYSTEM_DEF(persistence) var/bunker_path = file("data/bunker_passthrough.json") if(fexists(bunker_path)) GLOB.bunker_passthrough = json_decode(file2text(bunker_path)) - var/round_id = GLOB.round_id for(var/ckey in GLOB.bunker_passthrough) if(daysSince(GLOB.bunker_passthrough[ckey]) >= CONFIG_GET(number/max_bunker_days)) GLOB.bunker_passthrough -= ckey