From d9af55ad870f7b61818787350f1df4a48c150a80 Mon Sep 17 00:00:00 2001 From: AffectedArc07 Date: Tue, 28 Jul 2020 19:46:15 +0100 Subject: [PATCH 1/4] *more* Tcomms Tweaks --- code/game/machinery/tcomms/_base.dm | 22 ++++++++++--- code/game/machinery/tcomms/core.dm | 45 +++++++++++++++++++++++-- code/game/machinery/tcomms/relay.dm | 51 +++++++++++++++++++++++++---- 3 files changed, 105 insertions(+), 13 deletions(-) diff --git a/code/game/machinery/tcomms/_base.dm b/code/game/machinery/tcomms/_base.dm index 05c7552aacc..c3531c7f674 100644 --- a/code/game/machinery/tcomms/_base.dm +++ b/code/game/machinery/tcomms/_base.dm @@ -106,23 +106,37 @@ GLOBAL_LIST_EMPTY(tcomms_machines) /** - * Start of Ion Anomalie Event + * Start of Ion Anomaly Event * - * Proc to easily start an Ion Anomalie's effects, and update the icon + * Proc to easily start an Ion Anomaly's effects, and update the icon */ /obj/machinery/tcomms/proc/start_ion() ion = TRUE update_icon() /** - * End of Ion Anomalie Event + * End of Ion Anomaly Event * - * Proc to easily stop an Ion Anomalie's effects, and update the icon + * Proc to easily stop an Ion Anomaly's effects, and update the icon */ /obj/machinery/tcomms/proc/end_ion() ion = FALSE update_icon() +/** + * Z-Level transit change helper + * + * Proc to make sure you cant have two of these active on a Z-level at once. It also makes sure to update the linkage + */ +/obj/machinery/tcomms/onTransitZ(old_z, new_z) + . = ..() + if(active) + active = FALSE + // This needs a timer because otherwise its on the shuttle Z and the message is missed + addtimer(CALLBACK(src, /atom.proc/visible_message, "Radio equipment on [src] has been overloaded by heavy bluespace interference. Please restart the machine."), 5) + update_icon() + + /** * Logging helper * diff --git a/code/game/machinery/tcomms/core.dm b/code/game/machinery/tcomms/core.dm index 46cd0e6df71..5bf72258457 100644 --- a/code/game/machinery/tcomms/core.dm +++ b/code/game/machinery/tcomms/core.dm @@ -14,6 +14,8 @@ name = "Telecommunications Core" desc = "A large rack full of communications equipment. Looks important." icon_state = "core" + // This starts as off so you cant make cores as hot spares + active = FALSE /// The NTTC config for this device var/datum/nttc_configuration/nttc = new() /// List of all reachable devices @@ -35,6 +37,10 @@ link_password = GenerateKey() reachable_zlevels |= loc.z component_parts += new /obj/item/circuitboard/tcomms/core(null) + if(check_power_on()) + active = TRUE + else + visible_message("Error: Another core is already active in this sector. Power-up cancelled due to radio interference.") /** * Destructor for the core. @@ -121,6 +127,38 @@ reachable_zlevels |= R.loc.z +/** + * Z-Level transit change helper + * + * Handles parent call of disabling the machine if it changes Z-level, but also rebuilds the list of reachable levels + */ +/obj/machinery/tcomms/core/onTransitZ(old_z, new_z) + . = ..() + refresh_zlevels() + +/** + * Power-on checker + * + * Checks the z-level to see if an existing core is already powered on, and deny this one turning on if there is one. Returns TRUE if it can power on, or FALSE if it cannot + */ +/obj/machinery/tcomms/core/proc/check_power_on() + // Cancel if we are already on + if(active) + return TRUE + + for(var/obj/machinery/tcomms/core/C in GLOB.tcomms_machines) + // Make sure we dont check ourselves + if(C == src) + continue + // We dont care about ones on other zlevels + if(C.z != z) + continue + // If another core is active, return FALSE + if(C.active) + return FALSE + // If we got here there isnt an active core on this Z-level. So return true + return TRUE + ////////////// // UI STUFF // ////////////// @@ -198,8 +236,11 @@ if(ui_tab == UI_TAB_CONFIG) // All the toggle on/offs go here if(href_list["toggle_active"]) - active = !active - update_icon() + if(check_power_on()) + active = !active + update_icon() + else + to_chat(usr, "Error: Another core is already active in this sector. Power-up cancelled due to radio interference.") // NTTC Toggles if(href_list["nttc_toggle_jobs"]) nttc.toggle_jobs = !nttc.toggle_jobs diff --git a/code/game/machinery/tcomms/relay.dm b/code/game/machinery/tcomms/relay.dm index b2faf9ce0cd..8dd518a4681 100644 --- a/code/game/machinery/tcomms/relay.dm +++ b/code/game/machinery/tcomms/relay.dm @@ -51,6 +51,40 @@ // Only ONE of these with one ID should exist per world break +/** + * Z-Level transit change helper + * + * Handles parent call of disabling the machine if it changes Z-level, but also rebuilds the list of reachable levels on the linked core + */ +/obj/machinery/tcomms/relay/onTransitZ(old_z, new_z) + . = ..() + if(linked_core) + linked_core.refresh_zlevels() + + +/** + * Power-on checker + * + * Checks the z-level to see if an existing relay is already powered on, and deny this one turning on if there is one. Returns TRUE if it can power on, or FALSE if it cannot + */ +/obj/machinery/tcomms/relay/proc/check_power_on() + // Cancel if we are already on + if(active) + return TRUE + + for(var/obj/machinery/tcomms/relay/R in GLOB.tcomms_machines) + // Make sure we dont check ourselves + if(R == src) + continue + // We dont care about ones on other zlevels + if(R.z != z) + continue + // If another relay is active, return FALSE + if(R.active) + return FALSE + // If we got here there isnt an active relay on this Z-level. So return TRUE + return TRUE + /** * Proc to link the relay to the core. * @@ -83,9 +117,9 @@ * Proc which ensures the host core has its zlevels updated (icons are updated by parent call) */ /obj/machinery/tcomms/relay/power_change() - ..() - if(linked_core) - linked_core.refresh_zlevels() + ..() + if(linked_core) + linked_core.refresh_zlevels() ////////////// // UI STUFF // @@ -127,10 +161,13 @@ // All the toggle on/offs go here if(href_list["toggle_active"]) - active = !active - update_icon() - if(linked_core) - linked_core.refresh_zlevels() + if(check_power_on()) + active = !active + update_icon() + if(linked_core) + linked_core.refresh_zlevels() + else + to_chat(usr, "Error: Another core is already active in this sector. Power-up cancelled due to radio interference.") // Set network ID if(href_list["network_id"]) From abd0d710baeb4be4d58acd3a099628c9d06a9720 Mon Sep 17 00:00:00 2001 From: AffectedArc07 Date: Tue, 28 Jul 2020 20:03:23 +0100 Subject: [PATCH 2/4] Forgot these --- code/game/machinery/tcomms/core.dm | 1 + code/game/machinery/tcomms/relay.dm | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/code/game/machinery/tcomms/core.dm b/code/game/machinery/tcomms/core.dm index 5bf72258457..fa371d3593f 100644 --- a/code/game/machinery/tcomms/core.dm +++ b/code/game/machinery/tcomms/core.dm @@ -41,6 +41,7 @@ active = TRUE else visible_message("Error: Another core is already active in this sector. Power-up cancelled due to radio interference.") + update_icon() /** * Destructor for the core. diff --git a/code/game/machinery/tcomms/relay.dm b/code/game/machinery/tcomms/relay.dm index 8dd518a4681..6c2e6b1a20d 100644 --- a/code/game/machinery/tcomms/relay.dm +++ b/code/game/machinery/tcomms/relay.dm @@ -9,6 +9,8 @@ name = "Telecommunications Relay" desc = "A large device with several radio antennas on it." icon_state = "relay" + // This starts as off so you cant make cores as hot spares + active = FALSE /// The host core for this relay var/obj/machinery/tcomms/core/linked_core /// ID of the hub to auto link to @@ -26,6 +28,11 @@ /obj/machinery/tcomms/relay/Initialize(mapload) . = ..() component_parts += new /obj/item/circuitboard/tcomms/relay(null) + if(check_power_on()) + active = TRUE + else + visible_message("Error: Another relay is already active in this sector. Power-up cancelled due to radio interference.") + update_icon() if(mapload && autolink_id) return INITIALIZE_HINT_LATELOAD @@ -167,7 +174,7 @@ if(linked_core) linked_core.refresh_zlevels() else - to_chat(usr, "Error: Another core is already active in this sector. Power-up cancelled due to radio interference.") + to_chat(usr, "Error: Another relay is already active in this sector. Power-up cancelled due to radio interference.") // Set network ID if(href_list["network_id"]) From 56d2f833b33f127b6987a58ddf202edf7f773294 Mon Sep 17 00:00:00 2001 From: AffectedArc07 Date: Tue, 28 Jul 2020 20:46:09 +0100 Subject: [PATCH 3/4] Lets fix verbage while we are at it --- code/game/objects/items/devices/radio/radio.dm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/code/game/objects/items/devices/radio/radio.dm b/code/game/objects/items/devices/radio/radio.dm index 7ddf11ab451..7aa631a5967 100644 --- a/code/game/objects/items/devices/radio/radio.dm +++ b/code/game/objects/items/devices/radio/radio.dm @@ -325,7 +325,7 @@ GLOBAL_LIST_INIT(default_medbay_channels, list( // If we were to send to a channel we don't have, drop it. return RADIO_CONNECTION_FAIL -/obj/item/radio/talk_into(mob/living/M as mob, list/message_pieces, channel, var/verb = "says") +/obj/item/radio/talk_into(mob/living/M as mob, list/message_pieces, channel, verbage = "says") if(!on) return 0 // the device has to be on // Fix for permacell radios, but kinda eh about actually fixing them. @@ -423,6 +423,7 @@ GLOBAL_LIST_INIT(default_medbay_channels, list( tcm.connection = connection tcm.vname = M.voice_name tcm.sender = M + tcm.verbage = verbage // Now put that through the stuff var/handled = FALSE if(connection) From ffb43d6fda26cf9bdeed0e0ab99039d470e16ee8 Mon Sep 17 00:00:00 2001 From: AffectedArc07 Date: Fri, 31 Jul 2020 21:08:51 +0100 Subject: [PATCH 4/4] Foxes --- code/game/machinery/tcomms/core.dm | 2 +- code/game/machinery/tcomms/relay.dm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/code/game/machinery/tcomms/core.dm b/code/game/machinery/tcomms/core.dm index fa371d3593f..622ce2e2b9f 100644 --- a/code/game/machinery/tcomms/core.dm +++ b/code/game/machinery/tcomms/core.dm @@ -152,7 +152,7 @@ if(C == src) continue // We dont care about ones on other zlevels - if(C.z != z) + if(!atoms_share_level(C, src)) continue // If another core is active, return FALSE if(C.active) diff --git a/code/game/machinery/tcomms/relay.dm b/code/game/machinery/tcomms/relay.dm index 6c2e6b1a20d..bf5e6e21a9c 100644 --- a/code/game/machinery/tcomms/relay.dm +++ b/code/game/machinery/tcomms/relay.dm @@ -84,7 +84,7 @@ if(R == src) continue // We dont care about ones on other zlevels - if(R.z != z) + if(!atoms_share_level(R, src)) continue // If another relay is active, return FALSE if(R.active)