From 4be533e20e6c3de7be813398c7ac16d88d0d7a99 Mon Sep 17 00:00:00 2001 From: BongaTheProto <93835010+BongaTheProto@users.noreply.github.com> Date: Sat, 9 Sep 2023 00:23:43 -0500 Subject: [PATCH 1/2] ghost orgy at cryo??? ZAMN!!! *mygod --- config/splurt/autocryo.txt | 6 ++++ .../configuration/entries/splurt_autocryo.dm | 9 +++++ .../code/controllers/subsystem/afk.dm | 34 ++++++++++++++++++- .../code/modules/mob/dead/observer/logout.dm | 4 +++ .../modules/mob/dead/observer/observer.dm | 3 ++ tgstation.dme | 1 + 6 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 modular_splurt/code/modules/mob/dead/observer/logout.dm diff --git a/config/splurt/autocryo.txt b/config/splurt/autocryo.txt index 4f42e8eacb..8ff48d3ad4 100644 --- a/config/splurt/autocryo.txt +++ b/config/splurt/autocryo.txt @@ -3,3 +3,9 @@ ## Time in ticks before sending SSD users to cryo AUTOCRYO_TIME_TRIGGER 24000 + +# Uncomment to enable automatic disconnected ghost culling +# GHOST_CHECKING + +## Time in ticks before deleting a ghost whose client has disconnected +GHOST_CHECK_TIME 6000 diff --git a/modular_splurt/code/controllers/configuration/entries/splurt_autocryo.dm b/modular_splurt/code/controllers/configuration/entries/splurt_autocryo.dm index c94e2e3d98..63cd6dfc4b 100644 --- a/modular_splurt/code/controllers/configuration/entries/splurt_autocryo.dm +++ b/modular_splurt/code/controllers/configuration/entries/splurt_autocryo.dm @@ -6,3 +6,12 @@ // Should this system be used? /datum/config_entry/flag/autocryo_enabled + +// Time before deleting a disconnected ghost +/datum/config_entry/number/ghost_check_time + config_entry_value = 10 MINUTES + min_val = 600 + integer = TRUE + +// Should the system check for ghosts to delete too? +/datum/config_entry/flag/ghost_checking diff --git a/modular_splurt/code/controllers/subsystem/afk.dm b/modular_splurt/code/controllers/subsystem/afk.dm index b96d7b1e12..4fd63770bd 100644 --- a/modular_splurt/code/controllers/subsystem/afk.dm +++ b/modular_splurt/code/controllers/subsystem/afk.dm @@ -1,19 +1,28 @@ // Define config entries for cryo #define SUBSYSTEM_CRYO_CAN_RUN CONFIG_GET(flag/autocryo_enabled) +#define SUBSYSTEM_CRYO_CHECK_GHOSTS CONFIG_GET(flag/ghost_checking) #define SUBSYSTEM_CRYO_TIME CONFIG_GET(number/autocryo_time_trigger) +#define SUBSYSTEM_CRYO_GHOST_PERIOD CONFIG_GET(number/ghost_check_time) SUBSYSTEM_DEF(auto_cryo) name = "Automated Cryogenics" flags = SS_BACKGROUND + wait = 5 MINUTES /datum/controller/subsystem/auto_cryo/Initialize() // Check config before running - if(!SUBSYSTEM_CRYO_CAN_RUN) + if(!SUBSYSTEM_CRYO_CAN_RUN && !SUBSYSTEM_CRYO_CHECK_GHOSTS) can_fire = FALSE return ..() /datum/controller/subsystem/auto_cryo/fire() + if(SUBSYSTEM_CRYO_CAN_RUN) + cryo_mobs() + if(SUBSYSTEM_CRYO_CHECK_GHOSTS) + cull_ghosts() + +/datum/controller/subsystem/auto_cryo/proc/cryo_mobs() // Check for any targets if(!LAZYLEN(GLOB.ssd_mob_list)) // No SSD mobs exist @@ -38,6 +47,29 @@ SUBSYSTEM_DEF(auto_cryo) // Log cryo interaction log_game("[cryo_mob] was sent to cryo after being SSD for [afk_time] ticks.") +/datum/controller/subsystem/auto_cryo/proc/cull_ghosts() + // Check for any targets + if(!LAZYLEN(GLOB.dead_mob_list)) + return + + // Check possible targets + for(var/mob/dead/observer/ghost_mob in GLOB.dead_mob_list) + // Get SSD time + // This is set when disconnecting + var/afk_time = world.time - ghost_mob.lastclienttime + + // Check if client meets the time requirement + if(ghost_mob.client || afk_time < SUBSYSTEM_CRYO_GHOST_PERIOD) + continue + + // Log del interaction + log_game("[ghost_mob] was deleted after being SSD for [afk_time] ticks.") + + // Send to valhalla + qdel(ghost_mob) + // Remove defines #undef SUBSYSTEM_CRYO_CAN_RUN +#undef SUBSYSTEM_CRYO_CHECK_GHOSTS #undef SUBSYSTEM_CRYO_TIME +#undef SUBSYSTEM_CRYO_GHOST_PERIOD diff --git a/modular_splurt/code/modules/mob/dead/observer/logout.dm b/modular_splurt/code/modules/mob/dead/observer/logout.dm new file mode 100644 index 0000000000..701fb64507 --- /dev/null +++ b/modular_splurt/code/modules/mob/dead/observer/logout.dm @@ -0,0 +1,4 @@ +/mob/dead/observer/Logout() + . = ..() + + lastclienttime = world.time diff --git a/modular_splurt/code/modules/mob/dead/observer/observer.dm b/modular_splurt/code/modules/mob/dead/observer/observer.dm index f4bc5fa07f..a257f2382c 100644 --- a/modular_splurt/code/modules/mob/dead/observer/observer.dm +++ b/modular_splurt/code/modules/mob/dead/observer/observer.dm @@ -1,3 +1,6 @@ +/mob/dead/observer + var/lastclienttime = 0 + /mob/dead/observer/view_manifest() if(!client) return diff --git a/tgstation.dme b/tgstation.dme index 582978187c..9e0ff03de3 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -4790,6 +4790,7 @@ #include "modular_splurt\code\modules\mob\dead\new_player\sprite_accesories\synthliz.dm" #include "modular_splurt\code\modules\mob\dead\new_player\sprite_accesories\tails.dm" #include "modular_splurt\code\modules\mob\dead\new_player\sprite_accesories\wings.dm" +#include "modular_splurt\code\modules\mob\dead\observer\logout.dm" #include "modular_splurt\code\modules\mob\dead\observer\observer.dm" #include "modular_splurt\code\modules\mob\living\emotes.dm" #include "modular_splurt\code\modules\mob\living\living.dm" From 05e68bd5beab6dd17337523666c6866c70944232 Mon Sep 17 00:00:00 2001 From: BongaTheProto <93835010+BongaTheProto@users.noreply.github.com> Date: Sat, 9 Sep 2023 00:50:55 -0500 Subject: [PATCH 2/2] Update afk.dm --- modular_splurt/code/controllers/subsystem/afk.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modular_splurt/code/controllers/subsystem/afk.dm b/modular_splurt/code/controllers/subsystem/afk.dm index 4fd63770bd..01ab82d568 100644 --- a/modular_splurt/code/controllers/subsystem/afk.dm +++ b/modular_splurt/code/controllers/subsystem/afk.dm @@ -7,7 +7,7 @@ SUBSYSTEM_DEF(auto_cryo) name = "Automated Cryogenics" flags = SS_BACKGROUND - wait = 5 MINUTES + wait = 2 MINUTES /datum/controller/subsystem/auto_cryo/Initialize() // Check config before running