From ea50ace23a65023f0a20eecb8d4fcdb3e85bbbe8 Mon Sep 17 00:00:00 2001 From: Kylerace Date: Tue, 8 Feb 2022 23:44:24 -0800 Subject: [PATCH] Fixes bug with headsets unsetting channels after moving them (#64763) Readds them to the global radio channels they belong to as opposed to setting what they belong to on equipped. --- .../game/objects/items/devices/radio/radio.dm | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/code/game/objects/items/devices/radio/radio.dm b/code/game/objects/items/devices/radio/radio.dm index d22d471f97b..5bcd3965f34 100644 --- a/code/game/objects/items/devices/radio/radio.dm +++ b/code/game/objects/items/devices/radio/radio.dm @@ -110,9 +110,9 @@ resetChannels() if(keyslot) - for(var/ch_name in keyslot.channels) - if(!(ch_name in channels)) - channels[ch_name] = keyslot.channels[ch_name] + for(var/channel_name in keyslot.channels) + if(!(channel_name in channels)) + channels[channel_name] = keyslot.channels[channel_name] if(keyslot.translate_binary) translate_binary = TRUE @@ -121,8 +121,8 @@ if(keyslot.independent) independent = TRUE - for(var/ch_name in channels) - secure_radio_connections[ch_name] = add_radio(src, GLOB.radiochannels[ch_name]) + for(var/channel_name in channels) + secure_radio_connections[channel_name] = add_radio(src, GLOB.radiochannels[channel_name]) // Used for cyborg override /obj/item/radio/proc/resetChannels() @@ -132,6 +132,13 @@ syndie = FALSE independent = FALSE +///goes through all radio channels we should be listening for and readds them to the global list +/obj/item/radio/proc/readd_listening_radio_channels() + for(var/channel_name in channels) + add_radio(src, GLOB.radiochannels[channel_name]) + + add_radio(src, FREQ_COMMON) + /obj/item/radio/proc/make_syndie() // Turns normal radios into Syndicate radios! qdel(keyslot) keyslot = new /obj/item/encryptionkey/syndicate @@ -179,8 +186,7 @@ should_be_listening = listening if(listening && on) - recalculateChannels() - add_radio(src, frequency) + readd_listening_radio_channels() else if(!listening) remove_radio_all(src)