[s]Throttle mind notes (memories) (#45555)

* Throttle mind notes (memories)

Some dipshit is spamming this on ss13 servers

Limits to 100 times the message limit (removing old text after that), and one call every 5 game seconds.

* Throttle at the right place

* Not here

* We really need a generic throttler solution
This commit is contained in:
Kyle Spier-Swenson
2019-07-29 09:09:33 +12:00
committed by oranges
parent 3cb79721d3
commit 0fa87b7bbd
3 changed files with 11 additions and 4 deletions
+3
View File
@@ -129,6 +129,9 @@
last_death = world.time
/datum/mind/proc/store_memory(new_text)
var/newlength = length(memory) + length(new_text)
if (newlength > MAX_MESSAGE_LEN * 100)
memory = copytext(memory, -newlength-MAX_MESSAGE_LEN * 100)
memory += "[new_text]<BR>"
/datum/mind/proc/wipe_memory()
+6 -4
View File
@@ -536,11 +536,13 @@
/mob/verb/add_memory(msg as message)
set name = "Add Note"
set category = "IC"
msg = copytext(msg, 1, MAX_MESSAGE_LEN)
msg = sanitize(msg)
if(mind)
if (world.time < memory_throttle_time)
return
memory_throttle_time = world.time + 5 SECONDS
msg = copytext(msg, 1, MAX_MESSAGE_LEN)
msg = sanitize(msg)
mind.store_memory(msg)
else
to_chat(src, "You don't have a mind datum for some reason, so you can't add a note to it.")
+2
View File
@@ -199,3 +199,5 @@
///THe z level this mob is currently registered in
var/registered_z = null
var/memory_throttle_time = 0