Updates signaler investigate code | Adds some nice QOL changes for signalers | Enforces cooldown on signaler circuitry (#78974)

## About The Pull Request

See title.
If someone was abusing signalers previously to cause server lag, going
into list signalers would actually cause even worse lag as byond sat
there and processed thousands of items into a string over and over,
which would cause string format operations on longer and longer strings,
resulting in more and more overhead. This is bad.
So instead there is now a limit to the size of the list, currently I
have that set to 500 although I am open to increasing and even reducing
the number.

I have also made signalers slightly more intuitive by having the
cooldown actually displayed in the ui as a tooltip instead of just being
a secret feature you didnt know about unless you code dived. Also made
the cooldown actually respected by things such as circuitry where it
didnt even implement the cooldown and would happily send as many signals
as you had items connected to your proximity circuit.
## Why It's Good For The Game

Admins won't accidentally kill the server by trying to parse a lag
machines signal list. Players lagging the server? No, how about the
admins trying to fix it!

## Changelog

🆑
qol: signalers now tell you their cooldown and also use balloon alerts
/🆑
This commit is contained in:
Zephyr
2023-10-21 20:18:59 +01:00
committed by GitHub
parent 14f000197a
commit e9448ad37d
7 changed files with 64 additions and 25 deletions
+18 -12
View File
@@ -10,15 +10,20 @@
drop_sound = 'sound/items/handling/component_drop.ogg'
pickup_sound = 'sound/items/handling/component_pickup.ogg'
/// The code sent by this signaler.
var/code = DEFAULT_SIGNALER_CODE
/// The frequency this signaler is set to.
var/frequency = FREQ_SIGNALER
/// How long of a cooldown exists on this signaller.
var/cooldown_length = 1 SECONDS
/// The radio frequency connection this signaler is using.
var/datum/radio_frequency/radio_connection
///Holds the mind that commited suicide.
/// Holds the mind that commited suicide.
var/datum/mind/suicider
///Holds a reference string to the mob, decides how much of a gamer you are.
/// Holds a reference string to the mob, decides how much of a gamer you are.
var/suicide_mob
/// How many tiles away can you hear when this signaler is used or gets activated.
var/hearing_range = 1
/// String containing the last piece of logging data relating to when this signaller has received a signal.
var/last_receive_signal_log
@@ -77,23 +82,26 @@
/obj/item/assembly/signaler/ui_data(mob/user)
var/list/data = list()
data["frequency"] = frequency
data["cooldown"] = cooldown_length
data["code"] = code
data["minFrequency"] = MIN_FREE_FREQ
data["maxFrequency"] = MAX_FREE_FREQ
return data
/obj/item/assembly/signaler/ui_act(action, params)
/obj/item/assembly/signaler/ui_act(action, params, datum/tgui/ui)
. = ..()
if(.)
return
switch(action)
if("signal")
if(TIMER_COOLDOWN_CHECK(src, COOLDOWN_SIGNALLER_SEND))
to_chat(usr, span_warning("[src] is still recharging..."))
return
TIMER_COOLDOWN_START(src, COOLDOWN_SIGNALLER_SEND, 1 SECONDS)
if(cooldown_length > 0)
if(TIMER_COOLDOWN_CHECK(src, COOLDOWN_SIGNALLER_SEND))
balloon_alert(ui.user, "recharging!")
return
TIMER_COOLDOWN_START(src, COOLDOWN_SIGNALLER_SEND, cooldown_length)
INVOKE_ASYNC(src, PROC_REF(signal))
balloon_alert(ui.user, "signaled")
. = TRUE
if("freq")
var/new_frequency = sanitize_frequency(unformat_frequency(params["freq"]), TRUE)
@@ -141,10 +149,8 @@
var/time = time2text(world.realtime,"hh:mm:ss")
var/turf/T = get_turf(src)
var/logging_data
if(usr)
logging_data = "[time] <B>:</B> [usr.key] used [src] @ location ([T.x],[T.y],[T.z]) <B>:</B> [format_frequency(frequency)]/[code]"
GLOB.lastsignalers.Add(logging_data)
var/logging_data = "[time] <B>:</B> [key_name(usr)] used [src] @ location ([T.x],[T.y],[T.z]) <B>:</B> [format_frequency(frequency)]/[code]"
add_to_signaler_investigate_log(logging_data)
var/datum/signal/signal = new(list("code" = code), logging_data = logging_data)
radio_connection.post_signal(src, signal)