Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Teleporter machinery now autolinks. Adds unit test. #9881

Merged
merged 1 commit into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions code/game/machinery/computer/teleporter.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 2 additions & 7 deletions code/game/machinery/teleporter.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -140,7 +141,7 @@
if(!panel_open)
. += "<span class='notice'>The panel is <i>screwed</i> in, obstructing the linking device and wiring panel.</span>"
else
. += "<span class='notice'>The <i>linking</i> device is now able to be <i>scanned</i> with a multitool.<br>The <i>wiring</i> can be <i>connected<i> to a nearby console and hub with a pair of wirecutters.</span>"
. += "<span class='notice'>The <i>linking</i> device is now able to be <i>scanned</i> with a multitool.</span>"
if(in_range(user, src) || isobserver(user))
. += "<span class='notice'>The status display reads: This station can be linked to <b>[efficiency]</b> other station(s).</span>"

Expand Down Expand Up @@ -177,12 +178,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, "<span class='notice'>You reconnect the station to nearby machinery.</span>")
return
else
return ..()

Expand Down
1 change: 1 addition & 0 deletions code/modules/unit_tests/_unit_tests.dm
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,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"
Expand Down
10 changes: 10 additions & 0 deletions code/modules/unit_tests/teleporters.dm
Original file line number Diff line number Diff line change
@@ -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))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this unit test does not account for placement order

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it matter

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe? If you place them in different orders a regression might cause one to fail. It's just a coverage thing. I suppose it's fine as is.


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")