From 9b73fa8347f1f317515ed5b4496aa1e710a68775 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 20 Oct 2019 18:41:35 -0400 Subject: [PATCH 1/2] Cleans up radio code Mostly just updates it to baystation standard when relevant. Fixes a few bugs with adhoc_fallback in the process. I still want to fix the bug where adhoc_fallback fails to work in regions without telecoms. --- .../game/objects/items/devices/radio/radio.dm | 47 +++++++++---------- 1 file changed, 21 insertions(+), 26 deletions(-) diff --git a/code/game/objects/items/devices/radio/radio.dm b/code/game/objects/items/devices/radio/radio.dm index e3411ba15c..00bc391c96 100644 --- a/code/game/objects/items/devices/radio/radio.dm +++ b/code/game/objects/items/devices/radio/radio.dm @@ -92,7 +92,7 @@ var/global/list/default_medbay_channels = list( /obj/item/device/radio/interact(mob/user) if(!user) - return 0 + return FALSE if(b_stat) wires.Interact(user) @@ -148,10 +148,10 @@ var/global/list/default_medbay_channels = list( /obj/item/device/radio/proc/has_channel_access(var/mob/user, var/freq) if(!user) - return 0 + return FALSE if(!(freq in internal_channels)) - return 0 + return FALSE return user.has_internal_radio_channel_access(internal_channels[freq]) @@ -188,7 +188,7 @@ var/global/list/default_medbay_channels = list( /obj/item/device/radio/Topic(href, href_list) if(..()) - return 1 + return TRUE usr.set_machine(src) if (href_list["track"]) @@ -226,7 +226,7 @@ var/global/list/default_medbay_channels = list( set_frequency(text2num(freq)) . = 1 if(href_list["nowindow"]) // here for pAIs, maybe others will want it, idk - return 1 + return TRUE if(.) SSnanoui.update_uis(src) @@ -243,15 +243,11 @@ var/global/list/default_medbay_channels = list( channel = null if (!istype(connection)) return - if (!connection) - return - var/static/mob/living/silicon/ai/announcer/A = new /mob/living/silicon/ai/announcer(src, null, null, 1) - A.SetName(from) - Broadcast_Message(connection, A, - 0, "*garbled automated announcement*", src, - message, from, "Automated Announcement", from, "synthesized voice", - 4, 0, list(0), connection.frequency, "states") + var/mob/living/silicon/ai/A = new /mob/living/silicon/ai(src, null, null, 1) + A.fully_replace_character_name(null,from) + talk_into(A, message, channel,"states") + qdel(A) // Interprets the message mode when talking into a radio, possibly returning a connection datum /obj/item/device/radio/proc/handle_message_mode(mob/living/M as mob, message, message_mode) @@ -271,18 +267,18 @@ var/global/list/default_medbay_channels = list( return null /obj/item/device/radio/talk_into(mob/living/M as mob, message, channel, var/verb = "says", var/datum/language/speaking = null) - if(!on) return 0 // the device has to be on + if(!on) return FALSE // the device has to be on // Fix for permacell radios, but kinda eh about actually fixing them. - if(!M || !message) return 0 + if(!M || !message) return FALSE - if(speaking && (speaking.flags & (SIGNLANG|NONVERBAL))) return 0 + if(speaking && (speaking.flags & (SIGNLANG|NONVERBAL))) return FALSE if(istype(M)) M.trigger_aiming(TARGET_CAN_RADIO) // Uncommenting this. To the above comment: // The permacell radios aren't suppose to be able to transmit, this isn't a bug and this "fix" is just making radio wires useless. -Giacom if(wires.IsIndexCut(WIRE_TRANSMIT)) // The device has to have all its wires and shit intact - return 0 + return FALSE if(!radio_connection) set_frequency(frequency) @@ -301,9 +297,7 @@ var/global/list/default_medbay_channels = list( //#### Grab the connection datum ####// var/datum/radio_frequency/connection = handle_message_mode(M, message, channel) if (!istype(connection)) - return 0 - if (!connection) - return 0 + return FALSE var/turf/position = get_turf(src) @@ -363,7 +357,7 @@ var/global/list/default_medbay_channels = list( if(jamming) var/distance = jamming["distance"] to_chat(M,"\icon[src] You hear the [distance <= 2 ? "loud hiss" : "soft hiss"] of static.") - return 0 + return FALSE // First, we want to generate a new radio signal var/datum/signal/signal = new @@ -411,6 +405,7 @@ var/global/list/default_medbay_channels = list( for(var/obj/machinery/telecomms/allinone/R in telecomms_list) R.receive_signal(signal) + // Receiving code can be located in Telecommunications.dm if(signal.data["done"] && position.z in signal.data["level"]) return TRUE //Huzzah, sent via subspace @@ -471,13 +466,13 @@ var/global/list/default_medbay_channels = list( to_chat(loc,"\The [src] pings as it reestablishes subspace communications.") subspace_transmission = TRUE // we're done here. - return 1 + return TRUE // Oh my god; the comms are down or something because the signal hasn't been broadcasted yet in our level. // Send a mundane broadcast with limited targets: //THIS IS TEMPORARY. YEAH RIGHT - if(!connection) return 0 //~Carn + if(!connection) return FALSE //~Carn return Broadcast_Message(connection, M, voicemask, pick(M.speak_emote), src, message, displayname, jobname, real_name, M.voice_name, filter_type, signal.data["compression"], GetConnectedZlevels(position.z), connection.frequency,verb,speaking) @@ -493,7 +488,7 @@ var/global/list/default_medbay_channels = list( /obj/item/device/radio/proc/accept_rad(obj/item/device/radio/R as obj, message) if ((R.frequency == frequency && message)) - return 1 + return TRUE else if else @@ -533,7 +528,7 @@ var/global/list/default_medbay_channels = list( if (!accept) for (var/ch_name in channels) var/datum/radio_frequency/RF = secure_radio_connections[ch_name] - if (RF.frequency==freq && (channels[ch_name]&FREQ_LISTENING)) + if (RF && RF.frequency==freq && (channels[ch_name]&FREQ_LISTENING)) accept = 1 break if (!accept) @@ -684,7 +679,7 @@ var/global/list/default_medbay_channels = list( /obj/item/device/radio/borg/Topic(href, href_list) if(..()) - return 1 + return TRUE if (href_list["mode"]) var/enable_subspace_transmission = text2num(href_list["mode"]) if(enable_subspace_transmission != subspace_transmission) From 1a39adb0544223cc84777aff76eed6c0e5bd6424 Mon Sep 17 00:00:00 2001 From: Unknown Date: Mon, 21 Oct 2019 23:39:03 -0400 Subject: [PATCH 2/2] Reverts nonfunctional code --- code/game/objects/items/devices/radio/radio.dm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/code/game/objects/items/devices/radio/radio.dm b/code/game/objects/items/devices/radio/radio.dm index 00bc391c96..efc3fa549e 100644 --- a/code/game/objects/items/devices/radio/radio.dm +++ b/code/game/objects/items/devices/radio/radio.dm @@ -244,10 +244,12 @@ var/global/list/default_medbay_channels = list( if (!istype(connection)) return - var/mob/living/silicon/ai/A = new /mob/living/silicon/ai(src, null, null, 1) - A.fully_replace_character_name(null,from) - talk_into(A, message, channel,"states") - qdel(A) + var/static/mob/living/silicon/ai/announcer/A = new /mob/living/silicon/ai/announcer(src, null, null, 1) + A.SetName(from) + Broadcast_Message(connection, A, + 0, "*garbled automated announcement*", src, + message, from, "Automated Announcement", from, "synthesized voice", + 4, 0, list(0), connection.frequency, "states") // Interprets the message mode when talking into a radio, possibly returning a connection datum /obj/item/device/radio/proc/handle_message_mode(mob/living/M as mob, message, message_mode)