[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
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

View File

@@ -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))

View File

@@ -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)

View File

@@ -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

View File

@@ -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

View File

@@ -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)

View File

@@ -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

View File

@@ -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)

View File

@@ -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