From 01c8431742fb4adc550eb0e333f86778348d7a2f Mon Sep 17 00:00:00 2001 From: LetterN <24603524+LetterN@users.noreply.github.com> Date: Thu, 14 Nov 2024 16:02:38 +0800 Subject: [PATCH] guh --- citadel.dme | 1 - code/controllers/subsystem/inactivity.dm | 42 --------- code/controllers/subsystem/server_maint.dm | 99 ++++++++++++---------- code/game/world.dm | 10 +-- 4 files changed, 55 insertions(+), 97 deletions(-) delete mode 100644 code/controllers/subsystem/inactivity.dm diff --git a/citadel.dme b/citadel.dme index a6da8994250c..211ab9e33560 100644 --- a/citadel.dme +++ b/citadel.dme @@ -564,7 +564,6 @@ #include "code\controllers\subsystem\grids.dm" #include "code\controllers\subsystem\holomaps.dm" #include "code\controllers\subsystem\icon_smooth.dm" -#include "code\controllers\subsystem\inactivity.dm" #include "code\controllers\subsystem\input.dm" #include "code\controllers\subsystem\ipintel.dm" #include "code\controllers\subsystem\legacy_atc.dm" diff --git a/code/controllers/subsystem/inactivity.dm b/code/controllers/subsystem/inactivity.dm deleted file mode 100644 index 53e15c3bc179..000000000000 --- a/code/controllers/subsystem/inactivity.dm +++ /dev/null @@ -1,42 +0,0 @@ -SUBSYSTEM_DEF(inactivity) - name = "AFK Kick" - wait = 600 - subsystem_flags = SS_BACKGROUND | SS_NO_TICK_CHECK - -/datum/controller/subsystem/inactivity/fire() - if(config_legacy.kick_inactive) - for(var/i in GLOB.clients) - var/client/C = i - if(C.is_afk(config_legacy.kick_inactive MINUTES) && !C.holder) // Allow admins to idle - to_chat(C,"You have been inactive for more than [config_legacy.kick_inactive] minute\s and have been disconnected.") - var/information - - if(C.mob) - if(ishuman(C.mob)) - var/job - var/mob/living/carbon/human/H = C.mob - var/datum/data/record/R = find_general_record("name", H.real_name) - if(R) - job = R.fields["real_rank"] - if(!job && H.mind) - job = H.mind.assigned_role - if(!job && H.job) - job = H.job - if(job) - information = " while [job]." - - else if(issilicon(C.mob)) - information = " while a silicon." - if(isAI(C.mob)) - var/mob/living/silicon/ai/A = C.mob - GLOB.empty_playable_ai_cores += new /obj/structure/AIcore/deactivated(A.loc) - GLOB.global_announcer.autosay("[A] has been moved to intelligence storage.", "Artificial Intelligence Oversight") - A.clear_client() - information = " while an AI." - - var/adminlinks - adminlinks = " (JMP|CRYO)" - - log_and_message_admins("being kicked for AFK[information][adminlinks]", C.mob) - - qdel(C) diff --git a/code/controllers/subsystem/server_maint.dm b/code/controllers/subsystem/server_maint.dm index c8fe6fa4ba75..67a28191e9ec 100644 --- a/code/controllers/subsystem/server_maint.dm +++ b/code/controllers/subsystem/server_maint.dm @@ -8,81 +8,86 @@ SUBSYSTEM_DEF(server_maint) init_order = INIT_ORDER_SERVER_MAINT runlevels = RUNLEVEL_LOBBY | RUNLEVELS_DEFAULT var/list/currentrun - var/cleanup_SSticker = 0 + ///Associated list of list names to lists to clear of nulls + var/list/lists_to_clear + ///Delay between list clearings in ticks + var/delay = 5 + var/cleanup_ticker = 0 + +/datum/controller/subsystem/server_maint/PreInit() + world.hub_password = "" //quickly! before the hubbies see us. + +/datum/controller/subsystem/server_maint/Initialize() + if (fexists("tmp/")) + fdel("tmp/") + + if (CONFIG_GET(flag/hub)) + world.update_hub_visibility(TRUE) + + //Keep in mind, because of how delay works adding a list here makes each list take wait * delay more time to clear + //Do it for stuff that's properly important, and shouldn't have null checks inside its other uses + lists_to_clear = list( + "player_list" = GLOB.player_list, + "mob_list" = GLOB.mob_list, + "living_mob_list" = living_mob_list, + "dead_mob_list" = dead_mob_list + ) + + return ..() /datum/controller/subsystem/server_maint/fire(resumed = FALSE) if(!resumed) if(listclearnulls(GLOB.clients)) log_world("Found a null in clients list!") src.currentrun = GLOB.clients.Copy() - switch (cleanup_SSticker) // do only one of these at a time, once per 5 fires - if (0) - if(listclearnulls(GLOB.player_list)) - log_world("Found a null in GLOB.player_list!") - cleanup_SSticker++ - if (5) - if(listclearnulls(GLOB.mob_list)) - log_world("Found a null in GLOB.mob_list!") - cleanup_SSticker++ - if (10) - if(listclearnulls(living_mob_list)) - log_world("Found a null in living_mob_list!") - cleanup_SSticker++ - if (15) - if(listclearnulls(dead_mob_list)) - log_world("Found a null in dead_mob_list!") - cleanup_SSticker++ - if (20) - cleanup_SSticker = 0 - else - cleanup_SSticker++ - var/list/currentrun = src.currentrun + var/position_in_loop = (cleanup_ticker / delay) + 1 //Index at 1, thanks byond - /* - var/round_started = SSticker.HasRoundStarted() + if(!(position_in_loop % 1)) //If it's a whole number + var/listname = lists_to_clear[position_in_loop] + if(listclearnulls(lists_to_clear[listname])) + log_world("Found a null in [listname]!") + + cleanup_ticker++ - var/kick_inactive = CONFIG_GET(flag/kick_inactive) + var/amount_to_work = length(lists_to_clear) + if(cleanup_ticker >= amount_to_work * delay) //If we've already done a loop, reset + cleanup_ticker = 0 + + var/list/currentrun = src.currentrun + var/round_started = SSticker.HasRoundStarted() + var/kick_inactive = !!config_legacy.kick_inactive var/afk_period if(kick_inactive) - afk_period = CONFIG_GET(number/afk_period) - */ + afk_period = (config_legacy.kick_inactive MINUTES) for(var/I in currentrun) var/client/C = I + //handle kicking inactive players - /* - if(round_started && kick_inactive && C.is_afk(afk_period)) + if(round_started && kick_inactive && !C.holder && C.is_afk(afk_period)) var/cmob = C.mob - if(!(isobserver(cmob) || (isdead(cmob) && C.holder))) + if (!isnewplayer(cmob)) log_access("AFK: [key_name(C)]") - to_chat(C, "You have been inactive for more than [DisplayTimeText(afk_period)] and have been disconnected.") - qdel(C) - */ + to_chat(C, SPAN_USERDANGER("You have been inactive for more than [DisplayTimeText(afk_period)] and have been disconnected.
You may reconnect via the button in the file menu or by clicking here to reconnect.")) + QDEL_IN(C, 1) //to ensure they get our message before getting disconnected + continue if (!(!C || world.time - C.connection_time < PING_BUFFER_TIME || C.inactivity >= (wait-1))) - winset(C, null, "command=.update_ping+[world.time+world.tick_lag*TICK_USAGE_REAL/100]") + winset(C, null, "command=.update_ping+[num2text(world.time+world.tick_lag*TICK_USAGE_REAL/100, 32)]") if (MC_TICK_CHECK) //one day, when ss13 has 1000 people per server, you guys are gonna be glad I added this tick check return -/* /datum/controller/subsystem/server_maint/Shutdown() - kick_clients_in_lobby("The round came to an end with you in the lobby.", TRUE) //second parameter ensures only afk clients are kicked - var/server = CONFIG_GET(string/server) + if (fexists("tmp/")) + fdel("tmp/") + for(var/thing in GLOB.clients) if(!thing) continue var/client/C = thing - var/datum/chatOutput/co = C.chatOutput - if(co) - co.ehjax_send(data = "roundrestart") - if(server) //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://[server]") - var/tgsversion = world.TgsVersion() - if(tgsversion) - SSblackbox.record_feedback("text", "server_tools", 1, tgsversion) -*/ + C?.tgui_panel?.send_roundrestart() /datum/controller/subsystem/server_maint/proc/UpdateHubStatus() if(!CONFIG_GET(flag/hub) || !CONFIG_GET(number/max_hub_pop)) diff --git a/code/game/world.dm b/code/game/world.dm index 05ff88358b2f..5f84255cff1f 100644 --- a/code/game/world.dm +++ b/code/game/world.dm @@ -413,15 +413,11 @@ GLOBAL_LIST(topic_status_cache) status = . -/world/proc/update_hub_visibility(new_value) //CITADEL PROC: TG's method of changing visibility - if(new_value) //I'm lazy so this is how I wrap it to a bool number - new_value = TRUE - else - new_value = FALSE - if(new_value == visibility) +/world/proc/update_hub_visibility(new_visibility) + if(new_visibility == visibility) return - visibility = new_value + visibility = new_visibility if(visibility) hub_password = "kMZy3U5jJHSiBQjr" else