diff --git a/code/datums/beam.dm b/code/datums/beam.dm index b57a81c48f8..b6c6d1e5daa 100644 --- a/code/datums/beam.dm +++ b/code/datums/beam.dm @@ -22,6 +22,7 @@ origin_oldloc = get_turf(origin) target = beam_target target_oldloc = get_turf(target) + max_distance = maxdistance if(!origin || !target || !target_oldloc || !origin_oldloc || get_dist(origin_oldloc, target_oldloc) >= max_distance || origin_oldloc.z != target_oldloc.z) qdel(src) @@ -30,7 +31,6 @@ sleep_time = beam_sleep_time if(origin_oldloc == origin && target_oldloc == target) static_beam = TRUE - max_distance = maxdistance curr_distance = get_dist(origin_oldloc, target_oldloc) base_icon = new(beam_icon,beam_icon_state) icon = beam_icon @@ -171,7 +171,8 @@ /datum/beam/power/End() owner.beam = null - owner.untether(FALSE) + if(owner.source) + owner.untether(FALSE) return ..() /datum/beam/power/get_x_translation_vector() diff --git a/code/game/objects/items/weapons/tether.dm b/code/game/objects/items/weapons/tether.dm index 67c1cf1a999..7390cf31a35 100644 --- a/code/game/objects/items/weapons/tether.dm +++ b/code/game/objects/items/weapons/tether.dm @@ -72,9 +72,10 @@ var/list/global/all_tethers = list() /obj/item/tethering_device/proc/tether(var/obj/item/tethering_device/TD) linked_tethers |= TD var/datum/beam/exploration/B = new /datum/beam/exploration(src, TD, beam_icon_state = "explore_beam", time = -1, maxdistance = tether_range) - B.owner = src - B.Start() - active_beams[TD] = B + if(istype(B)) + B.owner = src + B.Start() + active_beams[TD] = B // untethering logic is primarily dictated by the beam itself, who will end if the max distance is reached, and call this proc /obj/item/tethering_device/proc/untether(var/obj/item/tethering_device/TD, var/destroy_beam = TRUE) @@ -83,4 +84,4 @@ var/list/global/all_tethers = list() return var/datum/beam/exploration/B = active_beams[TD] if(B) - B.End() \ No newline at end of file + B.End() diff --git a/code/modules/effects/map_effects/beam_point.dm b/code/modules/effects/map_effects/beam_point.dm index cca04178e48..b9f20720ce5 100644 --- a/code/modules/effects/map_effects/beam_point.dm +++ b/code/modules/effects/map_effects/beam_point.dm @@ -94,6 +94,8 @@ var/global/list/all_beam_points return FALSE var/datum/beam/new_beam = Beam(beam_target, beam_icon_state, beam_icon, beam_time, beam_max_distance, beam_type, beam_sleep_time) + if (!istype(new_beam)) + return FALSE my_beams += new_beam if(beam_creation_sound) playsound(src, beam_creation_sound, 70, 1) @@ -173,4 +175,4 @@ var/global/list/all_beam_points // Can only have one beam. /obj/effect/map_effect/beam_point/mono make_beams_on_init = TRUE - max_beams = 1 \ No newline at end of file + max_beams = 1 diff --git a/code/modules/modular_computers/hardware/tesla_link.dm b/code/modules/modular_computers/hardware/tesla_link.dm index 533bf2577ff..6caf6e62198 100644 --- a/code/modules/modular_computers/hardware/tesla_link.dm +++ b/code/modules/modular_computers/hardware/tesla_link.dm @@ -26,25 +26,21 @@ /obj/item/computer_hardware/tesla_link/charging_cable/Destroy() if(source || beam) - deactivate() + untether() return ..() /obj/item/computer_hardware/tesla_link/charging_cable/toggle(var/obj/machinery/power/power_source, mob/user) if(!source) + if(!istype(power_source)) + return if(in_range(power_source, src)) to_chat(user, SPAN_NOTICE("You connect \the [src] to \the [power_source].")) - activate(power_source) + tether(power_source) else to_chat(SPAN_NOTICE("\The [src] is too far from \the [power_source] to connect.")) else - deactivate() - -/obj/item/computer_hardware/tesla_link/charging_cable/proc/activate(var/obj/machinery/power/power_source) - if(istype(power_source)) - tether(power_source) - -/obj/item/computer_hardware/tesla_link/charging_cable/proc/deactivate() - untether() + untether(message=FALSE) + to_chat(user, SPAN_NOTICE("You disconnect \the [src] from \the [power_source].")) /obj/item/computer_hardware/tesla_link/charging_cable/check_functionality() ..() @@ -53,18 +49,23 @@ return TRUE /obj/item/computer_hardware/tesla_link/charging_cable/proc/tether(var/obj/machinery/power/P) + if(!istype(P)) + return source = P var/datum/beam/power/B = new(src, source, beam_icon_state = "explore_beam", time = -1, maxdistance = cable_length) - B.owner = src - B.Start() - beam = B + if(istype(B)) + playsound(get_turf(src), 'sound/machines/click.ogg', 30, 0) + B.owner = src + B.Start() + beam = B -/obj/item/computer_hardware/tesla_link/charging_cable/proc/untether(var/destroy_beam = TRUE) +/obj/item/computer_hardware/tesla_link/charging_cable/proc/untether(var/destroy_beam = TRUE, var/message=TRUE) source = null if(parent_computer) - parent_computer.visible_message(SPAN_WARNING("The charging cable suddenly disconnects from the APC, quickly reeling back into the computer!")) + if(message) + parent_computer.visible_message(SPAN_WARNING("The charging cable suddenly disconnects from the APC, quickly reeling back into the computer!")) playsound(get_turf(src), 'sound/machines/click.ogg', 30, 0) if(!destroy_beam) return if(beam) - beam.End() \ No newline at end of file + beam.End() diff --git a/html/changelogs/johnwildkins-beamfix.yml b/html/changelogs/johnwildkins-beamfix.yml new file mode 100644 index 00000000000..a9eae70f55d --- /dev/null +++ b/html/changelogs/johnwildkins-beamfix.yml @@ -0,0 +1,7 @@ +author: JohnWildkins + +delete-after: True + +changes: + - bugfix: "PDAs should no longer display multiple messages when disconnecting their charging cables. They also have a gentler message for purposeful disconnecting and play a sound when connecting a cable." + - bugfix: "Excessive runtimes should no longer occur from badly-formed beams."