From caffb4601e3ef715c6c58af1badb337d0171a9bb Mon Sep 17 00:00:00 2001 From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com> Date: Sat, 11 Dec 2021 11:50:43 +0000 Subject: [PATCH] Fixes intercoms not working when in a comms blackouts (#17208) --- code/game/objects/items/devices/radio/radio.dm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/code/game/objects/items/devices/radio/radio.dm b/code/game/objects/items/devices/radio/radio.dm index ee06d563aad..f5f340afed4 100644 --- a/code/game/objects/items/devices/radio/radio.dm +++ b/code/game/objects/items/devices/radio/radio.dm @@ -462,8 +462,7 @@ GLOBAL_LIST_INIT(default_medbay_channels, list( tcm.zlevels = list(position.z) if(!instant) // Simulate two seconds of lag - addtimer(CALLBACK(GLOBAL_PROC, .proc/broadcast_message, tcm), 20) - QDEL_IN(tcm, 20) + addtimer(CALLBACK(src, .proc/broadcast_callback, tcm), 2 SECONDS) else // Nukeops + Deathsquad headsets are instant and should work the same, whether there is comms or not broadcast_message(tcm) @@ -480,6 +479,13 @@ GLOBAL_LIST_INIT(default_medbay_channels, list( if(get_dist(src, M) <= canhear_range) talk_into(M, message_pieces, null, verb) +// To the person who asks "Why is this in a callback?" +// You see, if you use QDEL_IN on the tcm and on broadcast_message() +// The timer SS races itself and the message can be deleted before its sent +// Having both in this callback removes that risk +/obj/item/radio/proc/broadcast_callback(datum/tcomms_message/tcm) + broadcast_message(tcm) + qdel(tcm) // Delete the message datum /* /obj/item/radio/proc/accept_rad(obj/item/radio/R as obj, message)