Skip to content

Commit

Permalink
Bandaid the null clients in GLOB.clients (#4700)
Browse files Browse the repository at this point in the history
# About the pull request

Apparently we are somehow getting nulls into GLOB.clients now, and I
don't know why. Stat panel is the most egregious spammer about this
fact, but a rather slow subsystem will also periodically check too.

# Explain why it's good for the game

We don't need tens of thousands of runtimes.

# Testing Photographs and Procedure
<details>
<summary>Screenshots & Videos</summary>

Put screenshots and videos here with an empty line between the
screenshots and the `<details>` tags.

</details>


# Changelog
:cl: Drathek
fix: Bandaided a problem with nulls in GLOB.clients
/:cl:
  • Loading branch information
Drulikar committed Oct 19, 2023
1 parent 6501857 commit b6d25b0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
30 changes: 18 additions & 12 deletions code/controllers/subsystem/inactivity.dm
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
#define INACTIVITY_KICK 6000 //10 minutes in ticks (approx.)
#define INACTIVITY_KICK 10 MINUTES

SUBSYSTEM_DEF(inactivity)
name = "Inactivity"
wait = INACTIVITY_KICK
wait = 1 MINUTES
flags = SS_NO_INIT | SS_BACKGROUND
priority = SS_PRIORITY_INACTIVITY
runlevels = RUNLEVELS_DEFAULT|RUNLEVEL_LOBBY

/datum/controller/subsystem/inactivity/fire(resumed = FALSE)
if (CONFIG_GET(flag/kick_inactive))
for(var/i in GLOB.clients)
var/client/C = i
if(C.admin_holder && C.admin_holder.rights & R_ADMIN) //Skip admins.
continue
if (C.is_afk(INACTIVITY_KICK))
if (!istype(C.mob, /mob/dead))
log_access("AFK: [key_name(C)]")
to_chat(C, SPAN_WARNING("You have been inactive for more than 10 minutes and have been disconnected."))
qdel(C)
if(list_clear_nulls(GLOB.clients))
debug_log("Removed nulls from GLOB.clients!")
if(list_clear_nulls(GLOB.player_list))
debug_log("Removed nulls from GLOB.player_list!")

if (!CONFIG_GET(flag/kick_inactive))
return

for(var/client/current as anything in GLOB.clients)
if(current.admin_holder && current.admin_holder.rights & R_ADMIN) //Skip admins.
continue
if(current.is_afk(INACTIVITY_KICK))
if(!istype(current.mob, /mob/dead))
log_access("AFK: [key_name(current)]")
to_chat(current, SPAN_WARNING("You have been inactive for more than [INACTIVITY_KICK / 600] minutes and have been disconnected."))
qdel(current)
3 changes: 3 additions & 0 deletions code/controllers/subsystem/statpanel.dm
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ SUBSYSTEM_DEF(statpanels)
var/client/target = currentrun[length(currentrun)]
currentrun.len--

if(!target)
continue

if(!target.stat_panel.is_ready())
continue

Expand Down

0 comments on commit b6d25b0

Please sign in to comment.