[MIRROR] Fixes blockers blocking themselves + cleanup (#6528)

* Fixes blockers blocking themselves + cleanup (#59808)

* Fixes blockers blocking themselves + cleanup

Co-authored-by: Rohesie <rohesie@gmail.com>
This commit is contained in:
SkyratBot
2021-06-25 23:34:02 +02:00
committed by GitHub
parent 155c921b91
commit 1211d28c90
9 changed files with 34 additions and 14 deletions

View File

@@ -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 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 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 return
// Not a sane use of the function and (for now) indicative of an error elsewhere // 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") 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. * 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. * 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) var/turf/T0 = get_turf(neighbor)
if(T0 == src) //same turf if(T0 == src) //same turf
@@ -37,7 +37,7 @@
// Non diagonal case // Non diagonal case
if(T0.x == x || T0.y == y) if(T0.x == x || T0.y == y)
// Check for border blockages // 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 // Diagonal case
var/in_dir = get_dir(T0,src) // eg. northwest (1+8) = 9 (00001001) 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) var/d2 = in_dir&12 // eg. west (1+8)&12 (0000 1100) = 8 (0000 1000)
for(var/d in list(d1,d2)) 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 continue // could not leave T0 in that direction
var/turf/T1 = get_step(T0,d) var/turf/T1 = get_step(T0,d)
if(!T1 || T1.density) if(!T1 || T1.density)
continue 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 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 continue // could not enter src
return TRUE // we don't care about our own density return TRUE // we don't care about our own density
@@ -65,7 +65,7 @@
Adjacency (to anything else): Adjacency (to anything else):
* Must be on a turf * Must be on a turf
*/ */
/atom/movable/Adjacent(atom/neighbor) /atom/movable/Adjacent(atom/neighbor, atom/target, atom/movable/mover)
if(neighbor == loc) if(neighbor == loc)
return TRUE return TRUE
var/turf/T = loc var/turf/T = loc
@@ -76,12 +76,12 @@
return FALSE return FALSE
// This is necessary for storage items not on your person. // 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) if(neighbor == loc)
return TRUE return TRUE
if(isitem(loc)) if(isitem(loc))
if(recurse > 0) if(recurse > 0)
return loc.Adjacent(neighbor,recurse - 1) return loc.Adjacent(neighbor, target, mover, recurse - 1)
return FALSE return FALSE
return ..() return ..()
@@ -90,11 +90,11 @@
This is defined as any dense ON_BORDER_1 object, or any dense object without LETPASSTHROW. 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) 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) for(var/obj/O in src)
if((mover && O.CanPass(mover, target_dir)) || (!mover && !O.density)) if((mover && O.CanPass(mover, target_dir)) || (!mover && !O.density))
continue 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) 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 if( O.flags_1&ON_BORDER_1) // windows are on border, check them first

View File

@@ -305,7 +305,7 @@
/atom/movable/proc/Move_Pulled(atom/A) /atom/movable/proc/Move_Pulled(atom/A)
if(!pulling) if(!pulling)
return FALSE 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() stop_pulling()
return FALSE return FALSE
if(isliving(pulling)) if(isliving(pulling))

View File

@@ -279,6 +279,8 @@
/obj/machinery/door/firedoor/border_only/proc/on_exit(datum/source, atom/movable/leaving, direction) /obj/machinery/door/firedoor/border_only/proc/on_exit(datum/source, atom/movable/leaving, direction)
SIGNAL_HANDLER SIGNAL_HANDLER
if(leaving == src)
return // Let's not block ourselves.
if(direction == dir && density) if(direction == dir && density)
leaving.Bump(src) leaving.Bump(src)

View File

@@ -141,6 +141,9 @@
/obj/machinery/door/window/proc/on_exit(datum/source, atom/movable/leaving, direction) /obj/machinery/door/window/proc/on_exit(datum/source, atom/movable/leaving, direction)
SIGNAL_HANDLER SIGNAL_HANDLER
if(leaving == src)
return // Let's not block ourselves.
if((pass_flags_self & leaving.pass_flags) || ((pass_flags_self & LETPASSTHROW) && leaving.throwing)) if((pass_flags_self & leaving.pass_flags) || ((pass_flags_self & LETPASSTHROW) && leaving.throwing))
return return

View File

@@ -86,6 +86,9 @@
/obj/structure/railing/proc/on_exit(datum/source, atom/movable/leaving, direction) /obj/structure/railing/proc/on_exit(datum/source, atom/movable/leaving, direction)
SIGNAL_HANDLER SIGNAL_HANDLER
if(leaving == src)
return // Let's not block ourselves.
if(!(direction & dir)) if(!(direction & dir))
return return

View File

@@ -63,6 +63,9 @@
/obj/structure/stairs/proc/on_exit(datum/source, atom/movable/leaving, direction) /obj/structure/stairs/proc/on_exit(datum/source, atom/movable/leaving, direction)
SIGNAL_HANDLER SIGNAL_HANDLER
if(leaving == src)
return // Let's not block ourselves.
if(!isobserver(leaving) && isTerminator() && direction == dir) if(!isobserver(leaving) && isTerminator() && direction == dir)
INVOKE_ASYNC(src, .proc/stair_ascend, leaving) INVOKE_ASYNC(src, .proc/stair_ascend, leaving)
leaving.Bump(src) leaving.Bump(src)

View File

@@ -77,6 +77,9 @@
/obj/structure/windoor_assembly/proc/on_exit(datum/source, atom/movable/leaving, direction) /obj/structure/windoor_assembly/proc/on_exit(datum/source, atom/movable/leaving, direction)
SIGNAL_HANDLER SIGNAL_HANDLER
if(leaving == src)
return // Let's not block ourselves.
if (leaving.pass_flags & pass_flags_self) if (leaving.pass_flags & pass_flags_self)
return return

View File

@@ -127,7 +127,10 @@
/obj/structure/window/proc/on_exit(datum/source, atom/movable/leaving, direction) /obj/structure/window/proc/on_exit(datum/source, atom/movable/leaving, direction)
SIGNAL_HANDLER 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 return
if (fulltile) if (fulltile)

View File

@@ -70,6 +70,9 @@
/obj/structure/necropolis_gate/proc/on_exit(datum/source, atom/movable/leaving, direction) /obj/structure/necropolis_gate/proc/on_exit(datum/source, atom/movable/leaving, direction)
SIGNAL_HANDLER SIGNAL_HANDLER
if(leaving == src)
return // Let's not block ourselves.
if (direction == dir && density) if (direction == dir && density)
leaving.Bump(src) leaving.Bump(src)
return COMPONENT_ATOM_BLOCK_EXIT return COMPONENT_ATOM_BLOCK_EXIT