From 73d6dc9f6ebfcde6006a8be2708a53e9936581b4 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Sun, 12 Jun 2022 03:34:45 +0200 Subject: [PATCH] [MIRROR] Makes ore silo connecting work on multi-z [MDB IGNORE] (#14257) * Makes ore silo connecting work on multi-z (#67640) * makes ore silo connecting work on multi-z * I merged the two checks for same z level when connecting an ore silo, and disconnecting it. This was because I didn't want to copy paste the code to use it twice, which was what now caused the problem of multi-z maps being unable to connect ore silos on the same level. At the time it was also intentional since it's easier to connect than to disconnect something, but I realize that this inconsistency isn't great or beneficial to anyone. * Turns it into a helper instead * Makes ore silo connecting work on multi-z Co-authored-by: John Willard <53777086+JohnFulpWillard@users.noreply.github.com> --- code/__HELPERS/levels.dm | 19 +++++++++++++++++++ code/datums/components/remote_materials.dm | 9 +++------ tgstation.dme | 1 + 3 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 code/__HELPERS/levels.dm diff --git a/code/__HELPERS/levels.dm b/code/__HELPERS/levels.dm new file mode 100644 index 00000000000..218c1013bed --- /dev/null +++ b/code/__HELPERS/levels.dm @@ -0,0 +1,19 @@ +/** + * - is_valid_z_level + * + * Checks if source_loc and checking_loc is both on the station, or on the same z level. + * This is because the station's several levels aren't considered the same z, so multi-z stations need this special case. + * + * Args: + * source_loc - turf of the source we're comparing. + * checking_loc - turf we are comparing to source_loc. + * + * returns TRUE if connection is valid, FALSE otherwise. + */ +/proc/is_valid_z_level(turf/source_loc, turf/checking_loc) + // if we're both on "station", regardless of multi-z, we'll pass by. + if(is_station_level(source_loc.z) && is_station_level(checking_loc.z)) + return TRUE + if(source_loc.z == checking_loc.z) + return TRUE + return FALSE diff --git a/code/datums/components/remote_materials.dm b/code/datums/components/remote_materials.dm index 0edff309c38..2ae9bd96775 100644 --- a/code/datums/components/remote_materials.dm +++ b/code/datums/components/remote_materials.dm @@ -108,7 +108,7 @@ handles linking back and forth. return COMPONENT_BLOCK_TOOL_ATTACK var/turf/silo_turf = get_turf(M.buffer) var/turf/user_loc = get_turf(user) - if(user_loc.z != silo_turf.z) + if(!is_valid_z_level(silo_turf, user_loc)) to_chat(user, span_warning("[parent] is too far away to get a connection signal!")) return COMPONENT_BLOCK_TOOL_ATTACK if (silo) @@ -130,11 +130,8 @@ handles linking back and forth. return var/turf/silo_turf = get_turf(silo) - if(is_station_level(silo_turf.z) && is_station_level(new_turf.z)) // if we're both on "station", regardless of multi-z, we'll pass by. - return - if(silo_turf.z == new_turf.z) - return - disconnect_from(silo) + if(!is_valid_z_level(silo_turf, new_turf)) + disconnect_from(silo) /datum/component/remote_materials/proc/on_hold() return silo?.holds["[get_area(parent)]/[category]"] diff --git a/tgstation.dme b/tgstation.dme index d452e1b8589..03589f1c44b 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -362,6 +362,7 @@ #include "code\__HELPERS\icons.dm" #include "code\__HELPERS\jatum.dm" #include "code\__HELPERS\level_traits.dm" +#include "code\__HELPERS\levels.dm" #include "code\__HELPERS\lighting.dm" #include "code\__HELPERS\maths.dm" #include "code\__HELPERS\matrices.dm"