From 697ea7ad93aed87c8ceca7e28ddfcf5309b0c3a3 Mon Sep 17 00:00:00 2001
From: silicons <2003111+silicons@users.noreply.github.com>
Date: Mon, 27 Sep 2021 17:40:53 -0700
Subject: [PATCH 1/3] fix
---
code/modules/client/client_defines.dm | 3 +++
code/modules/client/client_procs.dm | 4 ++++
code/modules/keybindings/bindings_client.dm | 2 ++
code/modules/tgui/tgui.dm | 1 +
4 files changed, 10 insertions(+)
diff --git a/code/modules/client/client_defines.dm b/code/modules/client/client_defines.dm
index 99f24107c7..950b2b5b25 100644
--- a/code/modules/client/client_defines.dm
+++ b/code/modules/client/client_defines.dm
@@ -187,3 +187,6 @@
var/list/block_parry_hinted = list()
/// moused over objects, currently capped at 7. this is awful, and should be replaced with a component to track it using signals for parrying at some point.
var/list/moused_over_objects = list()
+
+ /// AFK tracking
+ var/last_activity = 0
diff --git a/code/modules/client/client_procs.dm b/code/modules/client/client_procs.dm
index 571adb406b..475a85561d 100644
--- a/code/modules/client/client_procs.dm
+++ b/code/modules/client/client_procs.dm
@@ -83,6 +83,8 @@ GLOBAL_LIST_INIT(blacklisted_builds, list(
log_href("[src] (usr:[usr]\[[COORD(usr)]\]) : [hsrc ? "[hsrc] " : ""][href]")
return
+ last_activity = world.time
+
//Logs all hrefs
log_href("[src] (usr:[usr]\[[COORD(usr)]\]) : [hsrc ? "[hsrc] " : ""][href]")
@@ -850,6 +852,7 @@ GLOBAL_LIST_INIT(blacklisted_builds, list(
/client/Click(atom/object, atom/location, control, params, ignore_spam = FALSE, extra_info)
if(last_click > world.time - world.tick_lag)
return
+ last_activity = world.time
last_click = world.time
var/ab = FALSE
var/list/L = params2list(params)
@@ -922,6 +925,7 @@ GLOBAL_LIST_INIT(blacklisted_builds, list(
//checks if a client is afk
//3000 frames = 5 minutes
/client/proc/is_afk(duration = CONFIG_GET(number/inactivity_period))
+ var/inactivity = world.time - last_activity
if(inactivity > duration)
return inactivity
return FALSE
diff --git a/code/modules/keybindings/bindings_client.dm b/code/modules/keybindings/bindings_client.dm
index 3d12f89cfe..7c0c6216a5 100644
--- a/code/modules/keybindings/bindings_client.dm
+++ b/code/modules/keybindings/bindings_client.dm
@@ -6,6 +6,7 @@
set hidden = TRUE
client_keysend_amount += 1
+ last_activity = world.time
var/cache = client_keysend_amount
@@ -89,6 +90,7 @@
set hidden = TRUE
keys_held -= _key
+ last_activity = world.time
var/movement = movement_keys[_key]
if(!(next_move_dir_add & movement))
next_move_dir_sub |= movement
diff --git a/code/modules/tgui/tgui.dm b/code/modules/tgui/tgui.dm
index 55497b150a..0ed5515aba 100644
--- a/code/modules/tgui/tgui.dm
+++ b/code/modules/tgui/tgui.dm
@@ -295,6 +295,7 @@
process_status()
if(src_object.ui_act(act_type, payload, src, state))
SStgui.update_uis(src_object)
+ usr?.client?.last_activity = world.time
return FALSE
switch(type)
if("ready")
From b064d73b95369c62bfb5d53acd65bb0e16bacbab Mon Sep 17 00:00:00 2001
From: silicons <2003111+silicons@users.noreply.github.com>
Date: Mon, 27 Sep 2021 17:43:42 -0700
Subject: [PATCH 2/3] that too
---
code/modules/mob/say.dm | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/code/modules/mob/say.dm b/code/modules/mob/say.dm
index 3b6f37184a..d8ef440ef9 100644
--- a/code/modules/mob/say.dm
+++ b/code/modules/mob/say.dm
@@ -4,6 +4,7 @@
set name = "say_indicator"
set hidden = TRUE
set category = "IC"
+ client?.last_activity = world.time
display_typing_indicator()
var/message = input(usr, "", "say") as text|null
// If they don't type anything just drop the message.
@@ -21,12 +22,16 @@
to_chat(usr, "Speech is currently admin-disabled.")
return
clear_typing_indicator() // clear it immediately!
+
+ client?.last_activity = world.time
+
say(message)
/mob/verb/me_typing_indicator()
set name = "me_indicator"
set hidden = TRUE
set category = "IC"
+ client?.last_activity = world.time
display_typing_indicator()
var/message = input(usr, "", "me") as message|null
// If they don't type anything just drop the message.
@@ -52,6 +57,8 @@
message = trim(copytext_char(sanitize(message), 1, MAX_MESSAGE_LEN))
clear_typing_indicator() // clear it immediately!
+ client?.last_activity = world.time
+
usr.emote("me",1,message,TRUE)
/mob/say_mod(input, message_mode)
@@ -73,6 +80,7 @@
return lowertext(copytext_char(input, 1, customsayverb))
/mob/proc/whisper_keybind()
+ client?.last_activity = world.time
var/message = input(src, "", "whisper") as text|null
if(!length(message))
return
@@ -89,6 +97,7 @@
whisper(message)
/mob/proc/whisper(message, datum/language/language=null)
+ client?.last_activity = world.time
say(message, language) //only living mobs actually whisper, everything else just talks
/mob/proc/say_dead(var/message)
@@ -132,6 +141,7 @@
message = emoji_parse(message)
var/rendered = "DEAD: [name][alt_name] [emoji_parse(spanned)]"
log_talk(message, LOG_SAY, tag="DEAD")
+ client?.last_activity = world.time
deadchat_broadcast(rendered, follow_target = src, speaker_key = key)
/mob/proc/check_emote(message)
From 0ec7e92f820287a64650bc2bafef0aa2d87a52f8 Mon Sep 17 00:00:00 2001
From: silicons <2003111+silicons@users.noreply.github.com>
Date: Mon, 27 Sep 2021 17:44:14 -0700
Subject: [PATCH 3/3] that too
---
code/modules/client/client_procs.dm | 1 +
1 file changed, 1 insertion(+)
diff --git a/code/modules/client/client_procs.dm b/code/modules/client/client_procs.dm
index 475a85561d..10c8a14257 100644
--- a/code/modules/client/client_procs.dm
+++ b/code/modules/client/client_procs.dm
@@ -224,6 +224,7 @@ GLOBAL_LIST_INIT(blacklisted_builds, list(
///////////
/client/New(TopicData)
+ last_activity = world.time
world.SetConfig("APP/admin", ckey, "role=admin")
var/tdata = TopicData //save this for later use
TopicData = null //Prevent calls to client.Topic from connect