Merge pull request #14360 from Kyep/radio_fixes

Fixes station bounced radios / intercomms
This commit is contained in:
AffectedArc07
2020-09-18 09:38:08 +01:00
committed by GitHub
7 changed files with 80 additions and 64 deletions
@@ -45,9 +45,6 @@
QDEL_NULL(keyslot2)
return ..()
/obj/item/radio/headset/list_channels(var/mob/user)
return list_secure_channels()
/obj/item/radio/headset/examine(mob/user)
. = ..()
if(in_range(src, user) && radio_desc)
@@ -245,14 +245,7 @@
usesound = 'sound/items/deconstruct.ogg'
/obj/item/radio/intercom/locked
var/locked_frequency
/obj/item/radio/intercom/locked/set_frequency(var/frequency)
if(frequency == locked_frequency)
..(locked_frequency)
/obj/item/radio/intercom/locked/list_channels()
return ""
freqlock = TRUE
/obj/item/radio/intercom/locked/ai_private
name = "\improper AI intercom"
+27 -27
View File
@@ -129,7 +129,10 @@ GLOBAL_LIST_INIT(default_medbay_channels, list(
/obj/item/radio/tgui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = TRUE, datum/tgui/master_ui = null, datum/tgui_state/state = GLOB.tgui_default_state)
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
if(!ui)
ui = new(user, src, ui_key, "Radio", name, 360, 150 + (length(channels) * 20), master_ui, state)
var/list/schannels = list_secure_channels(user)
var/list/ichannels = list_internal_channels(user)
var/calc_height = 150 + (schannels.len * 20) + (ichannels.len * 10)
ui = new(user, src, ui_key, "Radio", name, 400, calc_height, master_ui, state)
ui.open()
/obj/item/radio/tgui_data(mob/user)
@@ -142,9 +145,8 @@ GLOBAL_LIST_INIT(default_medbay_channels, list(
data["maxFrequency"] = freerange ? RADIO_HIGH_FREQ : PUBLIC_HIGH_FREQ
data["canReset"] = frequency == initial(frequency) ? FALSE : TRUE
data["freqlock"] = freqlock
data["channels"] = list()
for(var/channel in channels)
data["channels"][channel] = channels[channel] & FREQ_LISTENING
data["schannels"] = list_secure_channels(user)
data["ichannels"] = list_internal_channels(user)
data["has_loudspeaker"] = has_loudspeaker
data["loudspeaker"] = loudspeaker
@@ -173,6 +175,12 @@ GLOBAL_LIST_INIT(default_medbay_channels, list(
usr << browse(null, "window=radio")
if(.)
set_frequency(sanitize_frequency(tune, freerange))
if("ichannel") // change primary frequency to an internal channel authorized by access
if(freqlock)
return
var/freq = params["ichannel"]
if(has_channel_access(usr, freq))
set_frequency(text2num(freq))
if("listen")
listening = !listening
if("broadcast")
@@ -198,34 +206,29 @@ GLOBAL_LIST_INIT(default_medbay_channels, list(
if(.)
add_fingerprint(usr)
/obj/item/radio/proc/list_channels(var/mob/user)
return list_internal_channels(user)
/obj/item/radio/proc/list_secure_channels(var/mob/user)
var/dat[0]
for(var/ch_name in channels)
var/chan_stat = channels[ch_name]
var/listening = !!(chan_stat & FREQ_LISTENING) != 0
dat.Add(list(list("chan" = ch_name, "display_name" = ch_name, "secure_channel" = 1, "sec_channel_listen" = !listening, "chan_span" = SSradio.frequency_span_class(SSradio.radiochannels[ch_name]))))
/obj/item/radio/proc/list_secure_channels(mob/user)
var/list/dat = list()
for(var/channel in channels)
dat[channel] = channels[channel] & FREQ_LISTENING
return dat
/obj/item/radio/proc/list_internal_channels(var/mob/user)
var/dat[0]
/obj/item/radio/proc/list_internal_channels(mob/user)
var/list/dat = list()
if(freqlock)
return dat
for(var/internal_chan in internal_channels)
var/freqnum = text2num(internal_chan)
var/freqname = get_frequency_name(freqnum)
if(has_channel_access(user, internal_chan))
dat.Add(list(list("chan" = internal_chan, "display_name" = get_frequency_name(text2num(internal_chan)), "chan_span" = SSradio.frequency_span_class(text2num(internal_chan)))))
dat[freqname] = freqnum // unlike secure_channels, this is set to the freq number so Radio.js can use it as an arg
return dat
/obj/item/radio/proc/has_channel_access(var/mob/user, var/freq)
/obj/item/radio/proc/has_channel_access(mob/user, freq)
if(!user)
return 0
return FALSE
if(!(freq in internal_channels))
return 0
return FALSE
return user.has_internal_radio_channel_access(user, internal_channels[freq])
@@ -603,7 +606,7 @@ GLOBAL_LIST_INIT(default_medbay_channels, list(
/obj/item/radio/borg
name = "Cyborg Radio"
var/mob/living/silicon/robot/myborg = null // Cyborg which owns this radio. Used for power checks
var/obj/item/encryptionkey/keyslot = null//Borg radios can handle a single encryption key
var/obj/item/encryptionkey/keyslot = new /obj/item/encryptionkey/heads/ai_integrated //Borg radios can handle a single encryption key
icon = 'icons/obj/robot_component.dmi' // Cyborgs radio icons should look like the component.
icon_state = "radio"
has_loudspeaker = TRUE
@@ -623,9 +626,6 @@ GLOBAL_LIST_INIT(default_medbay_channels, list(
myborg = null
return ..()
/obj/item/radio/borg/list_channels(var/mob/user)
return list_secure_channels(user)
/obj/item/radio/borg/syndicate/New()
..()
syndiekey = keyslot
@@ -131,6 +131,7 @@ GLOBAL_LIST_INIT(robot_verbs_default, list(
update_headlamp()
radio = new /obj/item/radio/borg(src)
radio.recalculateChannels()
common_radio = radio
init(alien, connect_to_AI, ai_to_sync_to)
+10
View File
@@ -104,6 +104,11 @@ export const RADIO_CHANNELS = [
freq: 1355,
color: '#57b8f0',
},
{
name: 'Medical(I)',
freq: 1485,
color: '#57b8f0',
},
{
name: 'Engineering',
freq: 1357,
@@ -114,6 +119,11 @@ export const RADIO_CHANNELS = [
freq: 1359,
color: '#dd3535',
},
{
name: 'Security(I)',
freq: 1475,
color: '#dd3535',
},
{
name: 'AI Private',
freq: 1343,
+39 -24
View File
@@ -27,13 +27,17 @@ export const Radio = (props, context) => {
rc = RADIO_CHANNELS[i];
colorMap[rc["name"]] = rc["color"];
}
const channels = map((value, key) => ({
const schannels = map((value, key) => ({
name: key,
status: !!value,
}))(data.channels);
}))(data.schannels);
const ichannels = map((value, key) => ({
name: key,
freq: value,
}))(data.ichannels);
return (
<Window>
<Window.Content>
<Window resizable>
<Window.Content scrollable>
<Section>
<LabeledList>
<LabeledList.Item label="Frequency">
@@ -99,27 +103,38 @@ export const Radio = (props, context) => {
onClick={() => act('loudspeaker')} />
)}
</LabeledList.Item>
<LabeledList.Item label="Channels">
{channels.length === 0 && (
<Box inline color="bad">
No encryption keys installed.
</Box>
)}
{channels.map(channel => (
<Box key={channel.name}>
<Button
icon={channel.status ? 'check-square-o' : 'square-o'}
selected={channel.status}
content=""
onClick={() => act('channel', {
channel: channel.name,
})} />
<Box inline color={colorMap[channel.name]}>
{channel.name}
{schannels.length !== 0 && (
<LabeledList.Item label="Keyed Channels">
{schannels.map(channel => (
<Box key={channel.name}>
<Button
icon={channel.status ? 'check-square-o' : 'square-o'}
selected={channel.status}
content=""
onClick={() => act('channel', {
channel: channel.name,
})} />
<Box inline color={colorMap[channel.name]}>
{channel.name}
</Box>
</Box>
</Box>
))}
</LabeledList.Item>
))}
</LabeledList.Item>
)}
{ichannels.length !== 0 && (
<LabeledList.Item label="Standard Channel">
{ichannels.map(channel => (
<Button
key={"i_" + channel.name}
icon="arrow-right"
content={channel.name}
selected={tunedChannel.name === channel.name}
onClick={() => act('ichannel', {
ichannel: channel.freq,
})} />
))}
</LabeledList.Item>
)}
</LabeledList>
</Section>
</Window.Content>
File diff suppressed because one or more lines are too long