Fixes intercoms not working when in a comms blackouts (#17208)

This commit is contained in:
AffectedArc07
2021-12-11 12:50:43 +01:00
committed by GitHub
parent 41e22cf7e9
commit caffb4601e
@@ -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)