From 1211d28c909509564ce04eb0117bef5b8befac50 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Fri, 25 Jun 2021 23:34:02 +0200 Subject: [PATCH] [MIRROR] Fixes blockers blocking themselves + cleanup (#6528) * Fixes blockers blocking themselves + cleanup (#59808) * Fixes blockers blocking themselves + cleanup Co-authored-by: Rohesie --- code/_onclick/adjacent.dm | 24 +++++++++---------- code/game/atoms_movable.dm | 2 +- code/game/machinery/doors/firedoor.dm | 2 ++ code/game/machinery/doors/windowdoor.dm | 3 +++ code/game/objects/structures/railings.dm | 3 +++ code/game/objects/structures/stairs.dm | 3 +++ .../objects/structures/windoor_assembly.dm | 3 +++ code/game/objects/structures/window.dm | 5 +++- .../ruins/objects_and_mobs/necropolis_gate.dm | 3 +++ 9 files changed, 34 insertions(+), 14 deletions(-) diff --git a/code/_onclick/adjacent.dm b/code/_onclick/adjacent.dm index 829f78b052c..e33ba9cb540 100644 --- a/code/_onclick/adjacent.dm +++ b/code/_onclick/adjacent.dm @@ -10,11 +10,11 @@ Note that in all cases the neighbor is handled simply; this is usually the user's mob, in which case it is up to you to check that the mob is not inside of something */ -/atom/proc/Adjacent(atom/neighbor) // basic inheritance, unused +/atom/proc/Adjacent(atom/neighbor, atom/target, atom/movable/mover) // basic inheritance, unused return // Not a sane use of the function and (for now) indicative of an error elsewhere -/area/Adjacent(atom/neighbor) +/area/Adjacent(atom/neighbor, atom/target, atom/movable/mover) CRASH("Call to /area/Adjacent(), unimplemented proc") @@ -25,7 +25,7 @@ * If you are diagonally adjacent, ensure you can pass through at least one of the mutually adjacent square. * Passing through in this case ignores anything with the LETPASSTHROW pass flag, such as tables, racks, and morgue trays. */ -/turf/Adjacent(atom/neighbor, atom/target = null, atom/movable/mover = null) +/turf/Adjacent(atom/neighbor, atom/target, atom/movable/mover) var/turf/T0 = get_turf(neighbor) if(T0 == src) //same turf @@ -37,7 +37,7 @@ // Non diagonal case if(T0.x == x || T0.y == y) // Check for border blockages - return T0.ClickCross(get_dir(T0,src), border_only = 1, target_atom = target, mover = mover) && src.ClickCross(get_dir(src,T0), border_only = 1, target_atom = target, mover = mover) + return T0.ClickCross(get_dir(T0, src), TRUE, target, mover) && ClickCross(get_dir(src, T0), TRUE, target, mover) // Diagonal case var/in_dir = get_dir(T0,src) // eg. northwest (1+8) = 9 (00001001) @@ -45,16 +45,16 @@ var/d2 = in_dir&12 // eg. west (1+8)&12 (0000 1100) = 8 (0000 1000) for(var/d in list(d1,d2)) - if(!T0.ClickCross(d, border_only = 1, target_atom = target, mover = mover)) + if(!T0.ClickCross(d, TRUE, target, mover)) continue // could not leave T0 in that direction var/turf/T1 = get_step(T0,d) if(!T1 || T1.density) continue - if(!T1.ClickCross(get_dir(T1,src), border_only = 0, target_atom = target, mover = mover) || !T1.ClickCross(get_dir(T1,T0), border_only = 0, target_atom = target, mover = mover)) + if(!T1.ClickCross(get_dir(T1, src), FALSE, target, mover) || !T1.ClickCross(get_dir(T1, T0), FALSE, target, mover)) continue // couldn't enter or couldn't leave T1 - if(!src.ClickCross(get_dir(src,T1), border_only = 1, target_atom = target, mover = mover)) + if(!ClickCross(get_dir(src, T1), TRUE, target, mover)) continue // could not enter src return TRUE // we don't care about our own density @@ -65,7 +65,7 @@ Adjacency (to anything else): * Must be on a turf */ -/atom/movable/Adjacent(atom/neighbor) +/atom/movable/Adjacent(atom/neighbor, atom/target, atom/movable/mover) if(neighbor == loc) return TRUE var/turf/T = loc @@ -76,12 +76,12 @@ return FALSE // This is necessary for storage items not on your person. -/obj/item/Adjacent(atom/neighbor, recurse = 1) +/obj/item/Adjacent(atom/neighbor, atom/target, atom/movable/mover, recurse = 1) if(neighbor == loc) return TRUE if(isitem(loc)) if(recurse > 0) - return loc.Adjacent(neighbor,recurse - 1) + return loc.Adjacent(neighbor, target, mover, recurse - 1) return FALSE return ..() @@ -90,11 +90,11 @@ This is defined as any dense ON_BORDER_1 object, or any dense object without LETPASSTHROW. The border_only flag allows you to not objects (for source and destination squares) */ -/turf/proc/ClickCross(target_dir, border_only, target_atom = null, atom/movable/mover = null) +/turf/proc/ClickCross(target_dir, border_only, atom/target, atom/movable/mover) for(var/obj/O in src) if((mover && O.CanPass(mover, target_dir)) || (!mover && !O.density)) continue - if(O == target_atom || O == mover || (O.pass_flags_self & LETPASSTHROW)) //check if there's a dense object present on the turf + if(O == target || O == mover || (O.pass_flags_self & LETPASSTHROW)) //check if there's a dense object present on the turf continue // LETPASSTHROW is used for anything you can click through (or the firedoor special case, see above) if( O.flags_1&ON_BORDER_1) // windows are on border, check them first diff --git a/code/game/atoms_movable.dm b/code/game/atoms_movable.dm index 8fb6169e60a..02954327742 100644 --- a/code/game/atoms_movable.dm +++ b/code/game/atoms_movable.dm @@ -305,7 +305,7 @@ /atom/movable/proc/Move_Pulled(atom/A) if(!pulling) return FALSE - if(pulling.anchored || pulling.move_resist > move_force || !pulling.Adjacent(src)) + if(pulling.anchored || pulling.move_resist > move_force || !pulling.Adjacent(src, src, pulling)) stop_pulling() return FALSE if(isliving(pulling)) diff --git a/code/game/machinery/doors/firedoor.dm b/code/game/machinery/doors/firedoor.dm index d001e1cb379..ed254402b58 100644 --- a/code/game/machinery/doors/firedoor.dm +++ b/code/game/machinery/doors/firedoor.dm @@ -279,6 +279,8 @@ /obj/machinery/door/firedoor/border_only/proc/on_exit(datum/source, atom/movable/leaving, direction) SIGNAL_HANDLER + if(leaving == src) + return // Let's not block ourselves. if(direction == dir && density) leaving.Bump(src) diff --git a/code/game/machinery/doors/windowdoor.dm b/code/game/machinery/doors/windowdoor.dm index 5fe187cfdad..ea17d88e232 100644 --- a/code/game/machinery/doors/windowdoor.dm +++ b/code/game/machinery/doors/windowdoor.dm @@ -141,6 +141,9 @@ /obj/machinery/door/window/proc/on_exit(datum/source, atom/movable/leaving, direction) SIGNAL_HANDLER + if(leaving == src) + return // Let's not block ourselves. + if((pass_flags_self & leaving.pass_flags) || ((pass_flags_self & LETPASSTHROW) && leaving.throwing)) return diff --git a/code/game/objects/structures/railings.dm b/code/game/objects/structures/railings.dm index 057f0957138..b684508801c 100644 --- a/code/game/objects/structures/railings.dm +++ b/code/game/objects/structures/railings.dm @@ -86,6 +86,9 @@ /obj/structure/railing/proc/on_exit(datum/source, atom/movable/leaving, direction) SIGNAL_HANDLER + if(leaving == src) + return // Let's not block ourselves. + if(!(direction & dir)) return diff --git a/code/game/objects/structures/stairs.dm b/code/game/objects/structures/stairs.dm index 9bbc9bc258a..4865fbdc816 100644 --- a/code/game/objects/structures/stairs.dm +++ b/code/game/objects/structures/stairs.dm @@ -63,6 +63,9 @@ /obj/structure/stairs/proc/on_exit(datum/source, atom/movable/leaving, direction) SIGNAL_HANDLER + if(leaving == src) + return // Let's not block ourselves. + if(!isobserver(leaving) && isTerminator() && direction == dir) INVOKE_ASYNC(src, .proc/stair_ascend, leaving) leaving.Bump(src) diff --git a/code/game/objects/structures/windoor_assembly.dm b/code/game/objects/structures/windoor_assembly.dm index eca723ff146..e52c0be74d2 100644 --- a/code/game/objects/structures/windoor_assembly.dm +++ b/code/game/objects/structures/windoor_assembly.dm @@ -77,6 +77,9 @@ /obj/structure/windoor_assembly/proc/on_exit(datum/source, atom/movable/leaving, direction) SIGNAL_HANDLER + if(leaving == src) + return // Let's not block ourselves. + if (leaving.pass_flags & pass_flags_self) return diff --git a/code/game/objects/structures/window.dm b/code/game/objects/structures/window.dm index 04a1de0371e..13a94e40b42 100644 --- a/code/game/objects/structures/window.dm +++ b/code/game/objects/structures/window.dm @@ -127,7 +127,10 @@ /obj/structure/window/proc/on_exit(datum/source, atom/movable/leaving, direction) SIGNAL_HANDLER - if (istype(leaving) && (leaving.pass_flags & pass_flags_self)) + if(leaving == src) + return // Let's not block ourselves. + + if (leaving.pass_flags & pass_flags_self) return if (fulltile) diff --git a/code/modules/ruins/objects_and_mobs/necropolis_gate.dm b/code/modules/ruins/objects_and_mobs/necropolis_gate.dm index cb59f114b25..72b93924db4 100644 --- a/code/modules/ruins/objects_and_mobs/necropolis_gate.dm +++ b/code/modules/ruins/objects_and_mobs/necropolis_gate.dm @@ -70,6 +70,9 @@ /obj/structure/necropolis_gate/proc/on_exit(datum/source, atom/movable/leaving, direction) SIGNAL_HANDLER + if(leaving == src) + return // Let's not block ourselves. + if (direction == dir && density) leaving.Bump(src) return COMPONENT_ATOM_BLOCK_EXIT