From eacb690b92068bb55cdde1a16bef38077c4908f6 Mon Sep 17 00:00:00 2001
From: Tsar-Salat <62388554+Tsar-Salat@users.noreply.github.com>
Date: Tue, 24 Oct 2023 13:56:26 -0400
Subject: [PATCH] https://github.com/tgstation/tgstation/pull/54325 (#9881)
---
code/game/machinery/computer/teleporter.dm | 1 +
code/game/machinery/teleporter.dm | 9 ++-------
code/modules/unit_tests/_unit_tests.dm | 1 +
code/modules/unit_tests/teleporters.dm | 10 ++++++++++
4 files changed, 14 insertions(+), 7 deletions(-)
create mode 100644 code/modules/unit_tests/teleporters.dm
diff --git a/code/game/machinery/computer/teleporter.dm b/code/game/machinery/computer/teleporter.dm
index 70abe70b40292..05bf4d60f341f 100644
--- a/code/game/machinery/computer/teleporter.dm
+++ b/code/game/machinery/computer/teleporter.dm
@@ -37,6 +37,7 @@
for(var/direction in GLOB.cardinals)
power_station = locate(/obj/machinery/teleport/station, get_step(src, direction))
if(power_station)
+ power_station.link_console_and_hub()
break
ui_update()
return power_station
diff --git a/code/game/machinery/teleporter.dm b/code/game/machinery/teleporter.dm
index b88c15bb69f28..f703c91d3107c 100644
--- a/code/game/machinery/teleporter.dm
+++ b/code/game/machinery/teleporter.dm
@@ -44,6 +44,7 @@
for(var/direction in GLOB.cardinals)
power_station = locate(/obj/machinery/teleport/station, get_step(src, direction))
if(power_station)
+ power_station.link_console_and_hub()
break
return power_station
@@ -136,7 +137,7 @@
if(!panel_open)
. += "The panel is screwed in, obstructing the linking device and wiring panel."
else
- . += "The linking device is now able to be scanned with a multitool.
The wiring can be connected to a nearby console and hub with a pair of wirecutters."
+ . += "The linking device is now able to be scanned with a multitool."
if(in_range(user, src) || isobserver(user))
. += "The status display reads: This station can be linked to [efficiency] other station(s)."
@@ -173,12 +174,6 @@
else if(default_deconstruction_crowbar(W))
return
-
- else if(W.tool_behaviour == TOOL_WIRECUTTER)
- if(panel_open)
- link_console_and_hub()
- to_chat(user, "You reconnect the station to nearby machinery.")
- return
else
return ..()
diff --git a/code/modules/unit_tests/_unit_tests.dm b/code/modules/unit_tests/_unit_tests.dm
index 98cee111c5566..399c075014490 100644
--- a/code/modules/unit_tests/_unit_tests.dm
+++ b/code/modules/unit_tests/_unit_tests.dm
@@ -88,6 +88,7 @@
#include "subsystem_metric_sanity.dm"
#include "surgery_linking.dm"
#include "techweb_sanity.dm"
+#include "teleporters.dm"
#include "tgui_create_message.dm"
#include "timer_sanity.dm"
#include "unit_test.dm"
diff --git a/code/modules/unit_tests/teleporters.dm b/code/modules/unit_tests/teleporters.dm
new file mode 100644
index 0000000000000..2cb047304fbb5
--- /dev/null
+++ b/code/modules/unit_tests/teleporters.dm
@@ -0,0 +1,10 @@
+/datum/unit_test/auto_teleporter_linking/Run()
+ // Put down the teleporter machinery
+ var/obj/machinery/teleport/hub/hub = allocate(/obj/machinery/teleport/hub)
+ var/obj/machinery/teleport/station/station = allocate(/obj/machinery/teleport/station, locate(run_loc_floor_bottom_left.x + 1, run_loc_floor_bottom_left.y, run_loc_floor_bottom_left.z))
+ var/obj/machinery/computer/teleporter/computer = allocate(/obj/machinery/computer/teleporter, locate(run_loc_floor_bottom_left.x + 2, run_loc_floor_bottom_left.y, run_loc_floor_bottom_left.z))
+
+ TEST_ASSERT_EQUAL(hub.power_station, station, "Hub didn't link to the station")
+ TEST_ASSERT_EQUAL(station.teleporter_console, computer, "Station didn't link to the teleporter console")
+ TEST_ASSERT_EQUAL(station.teleporter_hub, hub, "Station didn't link to the hub")
+ TEST_ASSERT_EQUAL(computer.power_station, station, "Teleporter console didn't link to the hub")