From c4e01aa7397411403ca127269dfe97d16c756d3a Mon Sep 17 00:00:00 2001 From: Leshana Date: Tue, 20 Jul 2021 22:50:17 -0400 Subject: [PATCH] Fix falling when moving diagonally past an open space. This was happening because the decision to call handle_fall was made when over the open space, but execution deferred until the next tick. By that time it is too late for the checks in handle_fall to abort falling, so lets call those in advance. We do so in a separate proc from can_fall() because implementing it would be awkward, some types that override can_fall to avoid the anchored check would need to repeat the entire code or else delegate it. --- code/modules/multiz/movement.dm | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/code/modules/multiz/movement.dm b/code/modules/multiz/movement.dm index 1fb93aae85..5095405e88 100644 --- a/code/modules/multiz/movement.dm +++ b/code/modules/multiz/movement.dm @@ -265,7 +265,7 @@ return //VOREStation Edit End - if(can_fall()) + if(can_fall() && can_fall_to(below)) // We spawn here to let the current move operation complete before we start falling. fall() is normally called from // Entered() which is part of Move(), by spawn()ing we let that complete. But we want to preserve if we were in client movement // or normal movement so other move behavior can continue. @@ -318,6 +318,18 @@ if(..()) return species.can_fall(src) +// Another check that we probably can just merge into can_fall exept for messing up overrides +/atom/movable/proc/can_fall_to(turf/landing) + // Check if there is anything in our turf we are standing on to prevent falling. + for(var/obj/O in loc) + if(!O.CanFallThru(src, landing)) + return FALSE + // See if something in turf below prevents us from falling into it. + for(var/atom/A in landing) + if(!A.CanPass(src, src.loc, 1, 0)) + return FALSE + return TRUE + // Check if this atom prevents things standing on it from falling. Return TRUE to allow the fall. /obj/proc/CanFallThru(atom/movable/mover as mob|obj, turf/target as turf) if(!isturf(mover.loc)) // VORESTATION EDIT. We clearly didn't have enough backup checks. @@ -357,15 +369,6 @@ /atom/movable/proc/handle_fall(var/turf/landing) var/turf/oldloc = loc - // Check if there is anything in our turf we are standing on to prevent falling. - for(var/obj/O in loc) - if(!O.CanFallThru(src, landing)) - return FALSE - // See if something in turf below prevents us from falling into it. - for(var/atom/A in landing) - if(!A.CanPass(src, src.loc, 1, 0)) - return FALSE - // Now lets move there! if(!Move(landing)) return 1