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..01ab82d568 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 = 2 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 83eb6f3b34..2572017fdb 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -4794,6 +4794,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"