mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-23 05:00:55 +01:00
[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:
committed by
oranges
parent
3cb79721d3
commit
0fa87b7bbd
@@ -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()
|
||||
|
||||
@@ -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.")
|
||||
|
||||
@@ -199,3 +199,5 @@
|
||||
|
||||
///THe z level this mob is currently registered in
|
||||
var/registered_z = null
|
||||
|
||||
var/memory_throttle_time = 0
|
||||
|
||||
Reference in New Issue
Block a user