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"