mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-27 15:17:01 +01:00
Special radio channels now use bitflags instead of individual vars (#85150)
## About The Pull Request Radios/encryption keys now use a `RADIO_SPECIAL_XXXXX` bitflag for behaviors related to "special" radio channels (Binary, Centcom, Syndie). I decided to do this because I wanted to add a radio channel for pirates and hunters (hence the branch name), but it felt weird adding two more variables. The more I look at the changes I've made here the more I realize that the effort was probably not worth the utility but whatever. This also subtypes some varedited intercoms and makes them their own objects. ## Why It's Good For The Game Compresses a whopping three (3!) variables into a single one. Easier to scale (I guess?). I felt like adding a fourth/fifth variable and just moving on with the original project, but decided "lets do this the unnecessarily hard way instead". ## Changelog 🆑 Rhials code: Radios/encryption keys now use a single variable for "special" frequencies. Please report if you experience any strangeness with accessing/being unable to access the Centcom, Syndicate, or Cyborg radio. /🆑 --------- Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
This commit is contained in:
@@ -4,26 +4,22 @@
|
||||
icon = 'icons/obj/devices/circuitry_n_data.dmi'
|
||||
icon_state = "cypherkey_basic"
|
||||
w_class = WEIGHT_CLASS_TINY
|
||||
/// Can this radio key access the binary radio channel?
|
||||
var/translate_binary = FALSE
|
||||
/// Decrypts Syndicate radio transmissions.
|
||||
var/syndie = FALSE
|
||||
/// If true, the radio can say/hear on the special CentCom channel.
|
||||
var/independent = FALSE
|
||||
/// What channels does this encryption key grant to the parent headset.
|
||||
var/list/channels = list()
|
||||
/// Flags for which "special" radio networks should be accessible
|
||||
var/special_channels = NONE
|
||||
var/datum/language/translated_language
|
||||
greyscale_config = /datum/greyscale_config/encryptionkey_basic
|
||||
greyscale_colors = "#820a16#3758c4"
|
||||
|
||||
/obj/item/encryptionkey/examine(mob/user)
|
||||
. = ..()
|
||||
if(LAZYLEN(channels) || translate_binary)
|
||||
if(LAZYLEN(channels) || special_channels & RADIO_SPECIAL_BINARY)
|
||||
var/list/examine_text_list = list()
|
||||
for(var/i in channels)
|
||||
examine_text_list += "[GLOB.channel_tokens[i]] - [LOWER_TEXT(i)]"
|
||||
|
||||
if(translate_binary)
|
||||
if(special_channels & RADIO_SPECIAL_BINARY)
|
||||
examine_text_list += "[GLOB.channel_tokens[MODE_BINARY]] - [MODE_BINARY]"
|
||||
|
||||
. += span_notice("It can access the following channels; [jointext(examine_text_list, ", ")].")
|
||||
@@ -34,14 +30,14 @@
|
||||
name = "syndicate encryption key"
|
||||
icon_state = "cypherkey_syndicate"
|
||||
channels = list(RADIO_CHANNEL_SYNDICATE = 1)
|
||||
syndie = TRUE
|
||||
special_channels = RADIO_SPECIAL_SYNDIE
|
||||
greyscale_config = /datum/greyscale_config/encryptionkey_syndicate
|
||||
greyscale_colors = "#171717#990000"
|
||||
|
||||
/obj/item/encryptionkey/binary
|
||||
name = "binary translator key"
|
||||
icon_state = "cypherkey_basic"
|
||||
translate_binary = TRUE
|
||||
special_channels = RADIO_SPECIAL_BINARY
|
||||
translated_language = /datum/language/machine
|
||||
greyscale_config = /datum/greyscale_config/encryptionkey_basic
|
||||
greyscale_colors = "#24a157#3758c4"
|
||||
@@ -182,7 +178,7 @@
|
||||
/obj/item/encryptionkey/headset_cent
|
||||
name = "\improper CentCom radio encryption key"
|
||||
icon_state = "cypherkey_centcom"
|
||||
independent = TRUE
|
||||
special_channels = RADIO_SPECIAL_CENTCOM
|
||||
channels = list(RADIO_CHANNEL_CENTCOM = 1)
|
||||
greyscale_config = /datum/greyscale_config/encryptionkey_centcom
|
||||
greyscale_colors = "#24a157#dca01b"
|
||||
@@ -211,14 +207,14 @@
|
||||
RADIO_CHANNEL_SERVICE = 1,
|
||||
RADIO_CHANNEL_AI_PRIVATE = 1,
|
||||
)
|
||||
translate_binary = TRUE
|
||||
special_channels = RADIO_SPECIAL_BINARY
|
||||
translated_language = /datum/language/machine
|
||||
|
||||
/obj/item/encryptionkey/ai/evil //ported from NT, this goes 'inside' the AI.
|
||||
name = "syndicate binary encryption key"
|
||||
icon_state = "cypherkey_syndicate"
|
||||
channels = list(RADIO_CHANNEL_SYNDICATE = 1)
|
||||
syndie = TRUE
|
||||
special_channels = RADIO_SPECIAL_SYNDIE
|
||||
greyscale_config = /datum/greyscale_config/encryptionkey_syndicate
|
||||
greyscale_colors = "#171717#990000"
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ GLOBAL_LIST_INIT(channel_tokens, list(
|
||||
if(item_flags & IN_INVENTORY && loc == user)
|
||||
// construction of frequency description
|
||||
var/list/avail_chans = list("Use [RADIO_KEY_COMMON] for the currently tuned frequency")
|
||||
if(translate_binary)
|
||||
if(special_channels & RADIO_SPECIAL_BINARY)
|
||||
avail_chans += "use [MODE_TOKEN_BINARY] for [MODE_BINARY]"
|
||||
if(length(channels))
|
||||
for(var/i in 1 to length(channels))
|
||||
@@ -430,12 +430,7 @@ GLOBAL_LIST_INIT(channel_tokens, list(
|
||||
if(!(ch_name in src.channels))
|
||||
LAZYSET(channels, ch_name, keyslot2.channels[ch_name])
|
||||
|
||||
if(keyslot2.translate_binary)
|
||||
translate_binary = TRUE
|
||||
if(keyslot2.syndie)
|
||||
syndie = TRUE
|
||||
if(keyslot2.independent)
|
||||
independent = TRUE
|
||||
special_channels |= keyslot2.special_channels
|
||||
|
||||
for(var/ch_name in channels)
|
||||
secure_radio_connections[ch_name] = add_radio(src, GLOB.radiochannels[ch_name])
|
||||
|
||||
@@ -119,7 +119,7 @@
|
||||
return FALSE
|
||||
|
||||
if(freq == FREQ_SYNDICATE)
|
||||
if(!(syndie))
|
||||
if(!(special_channels &= RADIO_SPECIAL_SYNDIE))
|
||||
return FALSE//Prevents broadcast of messages over devices lacking the encryption
|
||||
|
||||
return TRUE
|
||||
@@ -219,6 +219,19 @@ WALL_MOUNT_DIRECTIONAL_HELPERS(/obj/item/radio/intercom)
|
||||
command = TRUE
|
||||
icon_off = "intercom_command-p"
|
||||
|
||||
/obj/item/radio/intercom/syndicate
|
||||
name = "syndicate intercom"
|
||||
desc = "Talk smack through this."
|
||||
command = TRUE
|
||||
special_channels = RADIO_SPECIAL_SYNDIE
|
||||
|
||||
/obj/item/radio/intercom/syndicate/freerange
|
||||
name = "syndicate wide-band intercom"
|
||||
desc = "A custom-made Syndicate-issue intercom used to transmit on all Nanotrasen frequencies. Particularly expensive."
|
||||
freerange = TRUE
|
||||
|
||||
WALL_MOUNT_DIRECTIONAL_HELPERS(/obj/item/radio/intercom/prison)
|
||||
WALL_MOUNT_DIRECTIONAL_HELPERS(/obj/item/radio/intercom/chapel)
|
||||
WALL_MOUNT_DIRECTIONAL_HELPERS(/obj/item/radio/intercom/command)
|
||||
WALL_MOUNT_DIRECTIONAL_HELPERS(/obj/item/radio/intercom/syndicate)
|
||||
WALL_MOUNT_DIRECTIONAL_HELPERS(/obj/item/radio/intercom/syndicate/freerange)
|
||||
|
||||
@@ -63,12 +63,8 @@
|
||||
|
||||
/// Encryption key handling
|
||||
var/obj/item/encryptionkey/keyslot
|
||||
/// If true, can hear the special binary channel.
|
||||
var/translate_binary = FALSE
|
||||
/// If true, can say/hear on the special CentCom channel.
|
||||
var/independent = FALSE
|
||||
/// If true, hears all well-known channels automatically, and can say/hear on the Syndicate channel. Also protects from radio jammers.
|
||||
var/syndie = FALSE
|
||||
/// Flags for which "special" radio networks should be accessible
|
||||
var/special_channels = NONE
|
||||
/// associative list of the encrypted radio channels this radio is currently set to listen/broadcast to, of the form: list(channel name = TRUE or FALSE)
|
||||
var/list/channels
|
||||
/// associative list of the encrypted radio channels this radio can listen/broadcast to, of the form: list(channel name = channel frequency)
|
||||
@@ -104,7 +100,7 @@
|
||||
perform_update_icon = FALSE
|
||||
set_listening(listening)
|
||||
set_broadcasting(broadcasting)
|
||||
set_frequency(sanitize_frequency(frequency, freerange, syndie))
|
||||
set_frequency(sanitize_frequency(frequency, freerange, (special_channels & RADIO_SPECIAL_SYNDIE)))
|
||||
set_on(on)
|
||||
perform_update_icon = TRUE
|
||||
|
||||
@@ -149,12 +145,7 @@
|
||||
if(!(channel_name in channels))
|
||||
channels[channel_name] = keyslot.channels[channel_name]
|
||||
|
||||
if(keyslot.translate_binary)
|
||||
translate_binary = TRUE
|
||||
if(keyslot.syndie)
|
||||
syndie = TRUE
|
||||
if(keyslot.independent)
|
||||
independent = TRUE
|
||||
special_channels = keyslot.special_channels
|
||||
|
||||
for(var/channel_name in channels)
|
||||
secure_radio_connections[channel_name] = add_radio(src, GLOB.radiochannels[channel_name])
|
||||
@@ -166,9 +157,7 @@
|
||||
/obj/item/radio/proc/resetChannels()
|
||||
channels = list()
|
||||
secure_radio_connections = list()
|
||||
translate_binary = FALSE
|
||||
syndie = FALSE
|
||||
independent = FALSE
|
||||
special_channels = NONE
|
||||
|
||||
///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()
|
||||
@@ -180,7 +169,7 @@
|
||||
/obj/item/radio/proc/make_syndie() // Turns normal radios into Syndicate radios!
|
||||
qdel(keyslot)
|
||||
keyslot = new /obj/item/encryptionkey/syndicate()
|
||||
syndie = TRUE
|
||||
special_channels |= RADIO_SPECIAL_SYNDIE
|
||||
recalculateChannels()
|
||||
|
||||
/obj/item/radio/interact(mob/user)
|
||||
@@ -337,7 +326,7 @@
|
||||
channel = null
|
||||
|
||||
// Nearby active jammers prevent the message from transmitting
|
||||
if(is_within_radio_jammer_range(src) && !syndie)
|
||||
if(is_within_radio_jammer_range(src) && !(special_channels & RADIO_SPECIAL_SYNDIE))
|
||||
return
|
||||
|
||||
// Determine the identity information which will be attached to the signal.
|
||||
@@ -347,7 +336,7 @@
|
||||
var/datum/signal/subspace/vocal/signal = new(src, freq, speaker, language, radio_message, spans, message_mods)
|
||||
|
||||
// Independent radios, on the CentCom frequency, reach all independent radios
|
||||
if (independent && (freq == FREQ_CENTCOM || freq == FREQ_CTF_RED || freq == FREQ_CTF_BLUE || freq == FREQ_CTF_GREEN || freq == FREQ_CTF_YELLOW))
|
||||
if (special_channels & RADIO_SPECIAL_CENTCOM && (freq == FREQ_CENTCOM || freq == FREQ_CTF_RED || freq == FREQ_CTF_BLUE || freq == FREQ_CTF_GREEN || freq == FREQ_CTF_YELLOW))
|
||||
signal.data["compression"] = 0
|
||||
signal.transmission_method = TRANSMISSION_SUPERSPACE
|
||||
signal.levels = list(0)
|
||||
@@ -415,7 +404,7 @@
|
||||
if(!position || !(position.z in levels))
|
||||
return FALSE
|
||||
|
||||
if (input_frequency == FREQ_SYNDICATE && !syndie)
|
||||
if (input_frequency == FREQ_SYNDICATE && !(special_channels & RADIO_SPECIAL_SYNDIE))
|
||||
return FALSE
|
||||
|
||||
// allow checks: are we listening on that frequency?
|
||||
@@ -423,7 +412,7 @@
|
||||
return TRUE
|
||||
for(var/ch_name in channels)
|
||||
if(channels[ch_name] & FREQ_LISTENING)
|
||||
if(GLOB.radiochannels[ch_name] == text2num(input_frequency) || syndie)
|
||||
if(GLOB.radiochannels[ch_name] == text2num(input_frequency) || special_channels & RADIO_SPECIAL_SYNDIE)
|
||||
return TRUE
|
||||
return FALSE
|
||||
|
||||
@@ -491,7 +480,7 @@
|
||||
tune = tune * 10
|
||||
. = TRUE
|
||||
if(.)
|
||||
set_frequency(sanitize_frequency(tune, freerange, syndie))
|
||||
set_frequency(sanitize_frequency(tune, freerange, (special_channels & RADIO_SPECIAL_SYNDIE)))
|
||||
if("listen")
|
||||
set_listening(!listening)
|
||||
. = TRUE
|
||||
@@ -590,7 +579,7 @@
|
||||
channels[ch_name] = TRUE
|
||||
|
||||
/obj/item/radio/borg/syndicate
|
||||
syndie = TRUE
|
||||
special_channels = RADIO_SPECIAL_SYNDIE
|
||||
keyslot = /obj/item/encryptionkey/syndicate
|
||||
|
||||
/obj/item/radio/borg/syndicate/Initialize(mapload)
|
||||
|
||||
Reference in New Issue
Block a user