From 29bb098d13598e86f0201bb4f1b32acb4364edea Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Fri, 2 Feb 2024 18:39:25 +0100 Subject: [PATCH] [MIRROR] Fix teleportation putting you outside of reservations (#26319) * Fix teleportation putting you outside of reservations (#81203) ## About The Pull Request Blocks teleportation if someone is about to be transported into a reservation not intended for them. Fixes #45529 ## Why It's Good For The Game Prevents people from GBJing themselves in the reservation level or getting into a reservation they're not allowed to enter. ## Changelog :cl: fix: Teleportations will no longer exceed reservation bounds. /:cl: * Fix teleportation putting you outside of reservations --------- Co-authored-by: distributivgesetz --- code/datums/helper_datums/teleport.dm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/code/datums/helper_datums/teleport.dm b/code/datums/helper_datums/teleport.dm index 0938ab66d1f..bee48a2bb49 100644 --- a/code/datums/helper_datums/teleport.dm +++ b/code/datums/helper_datums/teleport.dm @@ -65,7 +65,7 @@ return FALSE if(!forced) - if(!check_teleport_valid(teleatom, destination, channel)) + if(!check_teleport_valid(teleatom, destturf, channel, original_destination = destination)) if(ismob(teleatom)) teleatom.balloon_alert(teleatom, "something holds you back!") return FALSE @@ -185,7 +185,7 @@ return pick(turfs) /// Validates that the teleport being attempted is valid or not -/proc/check_teleport_valid(atom/teleported_atom, atom/destination, channel) +/proc/check_teleport_valid(atom/teleported_atom, atom/destination, channel, atom/original_destination = null) var/area/origin_area = get_area(teleported_atom) var/turf/origin_turf = get_turf(teleported_atom) @@ -195,6 +195,11 @@ if(HAS_TRAIT(teleported_atom, TRAIT_NO_TELEPORT)) return FALSE + // prevent unprecise teleports from landing you outside of the destination's reserved area + if(is_reserved_level(destination_turf.z) && istype(original_destination) \ + && SSmapping.get_reservation_from_turf(destination_turf) != SSmapping.get_reservation_from_turf(get_turf(original_destination))) + return FALSE + if((origin_area.area_flags & NOTELEPORT) || (destination_area.area_flags & NOTELEPORT)) return FALSE