Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge afk kick into server_maint(enance) #6860

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion citadel.dme
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
42 changes: 0 additions & 42 deletions code/controllers/subsystem/inactivity.dm

This file was deleted.

99 changes: 52 additions & 47 deletions code/controllers/subsystem/server_maint.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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, "<span class='danger'>You have been inactive for more than [DisplayTimeText(afk_period)] and have been disconnected.</span>")
qdel(C)
*/
to_chat(C, SPAN_USERDANGER("You have been inactive for more than [DisplayTimeText(afk_period)] and have been disconnected.</span><br><span class='danger'>You may reconnect via the button in the file menu or by <b><u><a href='byond://winset?command=.reconnect'>clicking here to reconnect</a></u></b>."))
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("<span class='boldannounce'>The round came to an end with you in the lobby.</span>", 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))
Expand Down
10 changes: 3 additions & 7 deletions code/game/world.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading