From a2bb281be870c5460931907d7acd1dd345686d61 Mon Sep 17 00:00:00 2001 From: Lucy Date: Wed, 18 Dec 2024 22:07:17 -0500 Subject: [PATCH] add temporary topic logging for 516 --- code/modules/client/client_procs.dm | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/code/modules/client/client_procs.dm b/code/modules/client/client_procs.dm index dd5c2b429c12..181a3821506f 100644 --- a/code/modules/client/client_procs.dm +++ b/code/modules/client/client_procs.dm @@ -17,6 +17,7 @@ GLOBAL_LIST_INIT(blacklisted_builds, list( #define CURRENT_MINUTE 3 #define MINUTE_COUNT 4 #define ADMINSWARNED_AT 5 + /* When somebody clicks a link in game, this Topic is called first. It does the stuff in this proc and then is redirected to the Topic() proc for the src=[0xWhatever] @@ -33,8 +34,17 @@ GLOBAL_LIST_INIT(blacklisted_builds, list( If you have any questions about this stuff feel free to ask. ~Carn */ +#ifdef CIBUILDING +#warn REMOVE MTL/STL LOGGING BEFORE FULL MERGE!!! +#endif +/client + var/list/_mtl_log + var/_mtl_logged = FALSE + var/list/_stl_log + var/_stl_logged = FALSE + //the undocumented 4th argument is for ?[0x\ref] style topic links. hsrc is set to the reference and anything after the ] gets put into hsrc_command -/client/Topic(href, href_list, hsrc, hsrc_command) +/client/Topic(href, list/href_list, hsrc, hsrc_command) if(!usr || usr != mob) //stops us calling Topic for somebody else's client. Also helps prevent usr=null return @@ -51,6 +61,7 @@ GLOBAL_LIST_INIT(blacklisted_builds, list( return // Rate limiting + var/is_516 = byond_version == 516 if(!holder && href_list["window_id"] != "statbrowser") var/mtl = CONFIG_GET(number/minute_topic_limit) if (mtl) @@ -60,8 +71,15 @@ GLOBAL_LIST_INIT(blacklisted_builds, list( if (minute != topiclimiter[CURRENT_MINUTE]) topiclimiter[CURRENT_MINUTE] = minute topiclimiter[MINUTE_COUNT] = 0 + _mtl_logged = FALSE + LAZYNULL(_mtl_log) topiclimiter[MINUTE_COUNT] += 1 + if(is_516 && !_mtl_logged) + LAZYADD(_mtl_log, list(href_list.Copy())) if (topiclimiter[MINUTE_COUNT] > mtl) + if(is_516 && !_mtl_logged) + _mtl_logged = TRUE + log_href("[key_name(src)] hit mtl on 516:\n[json_encode(_mtl_log, JSON_PRETTY_PRINT)]") var/msg = "Your previous action was ignored because you've done too many in a minute." if (minute != topiclimiter[ADMINSWARNED_AT]) //only one admin message per-minute. (if they spam the admins can just boot/ban them) topiclimiter[ADMINSWARNED_AT] = minute @@ -75,12 +93,19 @@ GLOBAL_LIST_INIT(blacklisted_builds, list( if (stl) var/second = round(world.time, 1 SECONDS) if (!topiclimiter) - topiclimiter = new(LIMITER_SIZE) + topiclimiter = new(LIMITER_SIZE + 1) if (second != topiclimiter[CURRENT_SECOND]) topiclimiter[CURRENT_SECOND] = second topiclimiter[SECOND_COUNT] = 0 + _stl_logged = FALSE + LAZYNULL(_stl_log) topiclimiter[SECOND_COUNT] += 1 + if(is_516 && !_stl_logged) + LAZYADD(_stl_log, list(href_list.Copy())) if (topiclimiter[SECOND_COUNT] > stl) + if(is_516 && !_stl_logged) + _stl_logged = TRUE + log_href("[key_name(src)] hit stl on 516:\n[json_encode(_stl_log, JSON_PRETTY_PRINT)]") to_chat(src, span_danger("Your previous action was ignored because you've done too many in a second")) return