From 94fe50294d20cc042caa39879eacbeac76b449ab Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Sat, 7 Nov 2020 06:06:41 +0100 Subject: [PATCH] [MIRROR] Fixing GBJ cases where the disposal holder is forcemoved outside a pipe. (#1602) * Fixing GBJ cases where the disposal holder is forcemoved outside a pipe. (#54643) Title. Also turned movable/pipe_eject() into a comsig, since it was used only for gibs. * Fixing GBJ cases where the disposal holder is forcemoved outside a pipe. Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com> --- .../RandomRuins/SpaceRuins/mechtransport.dmm | 2 +- code/__DEFINES/dcs/signals.dm | 2 ++ .../effects/decals/cleanable/aliens.dm | 15 ++++++++ .../effects/decals/cleanable/humans.dm | 12 +++++++ .../effects/decals/cleanable/robots.dm | 15 ++++++++ code/modules/recycling/disposal/bin.dm | 16 ++------- code/modules/recycling/disposal/eject.dm | 35 +++++++------------ code/modules/recycling/disposal/holder.dm | 15 +++++++- code/modules/recycling/disposal/multiz.dm | 2 +- code/modules/recycling/disposal/outlet.dm | 10 ++---- code/modules/recycling/disposal/pipe.dm | 27 ++++++-------- .../recycling/disposal/pipe_sorting.dm | 2 -- 12 files changed, 87 insertions(+), 66 deletions(-) diff --git a/_maps/RandomRuins/SpaceRuins/mechtransport.dmm b/_maps/RandomRuins/SpaceRuins/mechtransport.dmm index e715917000a..d0988330415 100644 --- a/_maps/RandomRuins/SpaceRuins/mechtransport.dmm +++ b/_maps/RandomRuins/SpaceRuins/mechtransport.dmm @@ -145,7 +145,7 @@ /turf/open/floor/mineral/titanium/blue, /area/ruin/space/has_grav/powered/mechtransport) "K" = ( -/obj/effect/decal/cleanable/robot_debris/gib, +/obj/effect/decal/cleanable/robot_debris, /turf/open/floor/plating/airless, /area/ruin/space/has_grav/powered/mechtransport) "L" = ( diff --git a/code/__DEFINES/dcs/signals.dm b/code/__DEFINES/dcs/signals.dm index 19334f1fec0..644dcfb6297 100644 --- a/code/__DEFINES/dcs/signals.dm +++ b/code/__DEFINES/dcs/signals.dm @@ -285,6 +285,8 @@ ///called when the movable is added to a disposal holder object for disposal movement: (obj/structure/disposalholder/holder, obj/machinery/disposal/source) #define COMSIG_MOVABLE_DISPOSING "movable_disposing" +// called when movable is expelled from a disposal pipe, bin or outlet on obj/pipe_eject: (direction) +#define COMSIG_MOVABLE_PIPE_EJECTING "movable_pipe_ejecting" ///called when the movable sucessfully has it's anchored var changed, from base atom/movable/set_anchored(): (value) #define COMSIG_MOVABLE_SET_ANCHORED "movable_set_anchored" ///from base of atom/movable/setGrabState(): (newstate) diff --git a/code/game/objects/effects/decals/cleanable/aliens.dm b/code/game/objects/effects/decals/cleanable/aliens.dm index 1ef7c5cc891..ab702331ac9 100644 --- a/code/game/objects/effects/decals/cleanable/aliens.dm +++ b/code/game/objects/effects/decals/cleanable/aliens.dm @@ -26,6 +26,10 @@ random_icon_states = list("xgib1", "xgib2", "xgib3", "xgib4", "xgib5", "xgib6") mergeable_decal = FALSE +/obj/effect/decal/cleanable/xenoblood/xgibs/Initialize() + . = ..() + RegisterSignal(src, COMSIG_MOVABLE_PIPE_EJECTING, .proc/on_pipe_eject) + /obj/effect/decal/cleanable/xenoblood/xgibs/proc/streak(list/directions, mapload=FALSE) set waitfor = FALSE var/direction = pick(directions) @@ -37,6 +41,17 @@ if(!step_to(src, get_step(src, direction), 0)) break +/obj/effect/decal/cleanable/xenoblood/xgibs/proc/on_pipe_eject(atom/source, direction) + SIGNAL_HANDLER + + var/list/dirs + if(direction) + dirs = list(direction, turn(direction, -45), turn(direction, 45)) + else + dirs = GLOB.alldirs.Copy() + + streak(dirs) + /obj/effect/decal/cleanable/xenoblood/xgibs/ex_act() return diff --git a/code/game/objects/effects/decals/cleanable/humans.dm b/code/game/objects/effects/decals/cleanable/humans.dm index ef5a07a49e4..c4e46150e07 100644 --- a/code/game/objects/effects/decals/cleanable/humans.dm +++ b/code/game/objects/effects/decals/cleanable/humans.dm @@ -59,6 +59,7 @@ /obj/effect/decal/cleanable/blood/gibs/Initialize(mapload, list/datum/disease/diseases) . = ..() reagents.add_reagent(/datum/reagent/liquidgibs, 5) + RegisterSignal(src, COMSIG_MOVABLE_PIPE_EJECTING, .proc/on_pipe_eject) if(already_rotting) start_rotting(rename=FALSE) else @@ -78,6 +79,17 @@ playsound(loc, 'sound/effects/gib_step.ogg', HAS_TRAIT(L, TRAIT_LIGHT_STEP) ? 20 : 50, TRUE) . = ..() +/obj/effect/decal/cleanable/blood/gibs/proc/on_pipe_eject(atom/source, direction) + SIGNAL_HANDLER + + var/list/dirs + if(direction) + dirs = list(direction, turn(direction, -45), turn(direction, 45)) + else + dirs = GLOB.alldirs.Copy() + + streak(dirs) + /obj/effect/decal/cleanable/blood/gibs/proc/streak(list/directions, mapload=FALSE) set waitfor = FALSE var/list/diseases = list() diff --git a/code/game/objects/effects/decals/cleanable/robots.dm b/code/game/objects/effects/decals/cleanable/robots.dm index 5091102f49c..44558f75560 100644 --- a/code/game/objects/effects/decals/cleanable/robots.dm +++ b/code/game/objects/effects/decals/cleanable/robots.dm @@ -12,6 +12,10 @@ mergeable_decal = FALSE beauty = -50 +/obj/effect/decal/cleanable/robot_debris/Initialize() + . = ..() + RegisterSignal(src, COMSIG_MOVABLE_PIPE_EJECTING, .proc/on_pipe_eject) + /obj/effect/decal/cleanable/robot_debris/proc/streak(list/directions, mapload=FALSE) set waitfor = FALSE var/direction = pick(directions) @@ -28,6 +32,17 @@ if (!step_to(src, get_step(src, direction), 0)) break +/obj/effect/decal/cleanable/robot_debris/proc/on_pipe_eject(atom/source, direction) + SIGNAL_HANDLER + + var/list/dirs + if(direction) + dirs = list(direction, turn(direction, -45), turn(direction, 45)) + else + dirs = GLOB.alldirs.Copy() + + streak(dirs) + /obj/effect/decal/cleanable/robot_debris/ex_act() return diff --git a/code/modules/recycling/disposal/bin.dm b/code/modules/recycling/disposal/bin.dm index 204f60c3f75..584cafa456c 100644 --- a/code/modules/recycling/disposal/bin.dm +++ b/code/modules/recycling/disposal/bin.dm @@ -170,10 +170,7 @@ // eject the contents of the disposal unit /obj/machinery/disposal/proc/eject() - var/turf/T = get_turf(src) - for(var/atom/movable/AM in src) - AM.forceMove(T) - AM.pipe_eject(0) + pipe_eject(src, FALSE, FALSE) update_icon() /obj/machinery/disposal/proc/flush() @@ -206,18 +203,9 @@ /obj/machinery/disposal/proc/expel(obj/structure/disposalholder/H) H.active = FALSE - var/turf/T = get_turf(src) - var/turf/target playsound(src, 'sound/machines/hiss.ogg', 50, FALSE, FALSE) - for(var/A in H) - var/atom/movable/AM = A - - target = get_offset_target_turf(loc, rand(5)-rand(5), rand(5)-rand(5)) - - AM.forceMove(T) - AM.pipe_eject(0) - AM.throw_at(target, 5, 1) + pipe_eject(H) H.vent_gas(loc) qdel(H) diff --git a/code/modules/recycling/disposal/eject.dm b/code/modules/recycling/disposal/eject.dm index 48162f37456..b2f83ec3c20 100644 --- a/code/modules/recycling/disposal/eject.dm +++ b/code/modules/recycling/disposal/eject.dm @@ -1,23 +1,12 @@ -// called when movable is expelled from a disposal pipe or outlet -// by default does nothing, override for special behaviour - -/atom/movable/proc/pipe_eject(direction) - return - -/obj/effect/decal/cleanable/blood/gibs/pipe_eject(direction) - var/list/dirs - if(direction) - dirs = list(direction, turn(direction, -45), turn(direction, 45)) - else - dirs = GLOB.alldirs.Copy() - - streak(dirs) - -/obj/effect/decal/cleanable/robot_debris/gib/pipe_eject(direction) - var/list/dirs - if(direction) - dirs = list(direction, turn(direction, -45), turn(direction, 45)) - else - dirs = GLOB.alldirs.Copy() - - streak(dirs) +/** + * General proc used to expel a holder's contents through src (for bins holder is also the src). + */ +/obj/proc/pipe_eject(obj/holder, direction, throw_em = TRUE, turf/target, throw_range = 5, throw_speed = 1) + var/turf/src_T = get_turf(src) + for(var/A in holder) + var/atom/movable/AM = A + AM.forceMove(src_T) + SEND_SIGNAL(AM, COMSIG_MOVABLE_PIPE_EJECTING, direction) + if(throw_em && !QDELETED(AM)) + var/turf/T = target || get_offset_target_turf(loc, rand(5)-rand(5), rand(5)-rand(5)) + AM.throw_at(T, throw_range, throw_speed) diff --git a/code/modules/recycling/disposal/holder.dm b/code/modules/recycling/disposal/holder.dm index 469063aa6ac..bfbe59c34ec 100644 --- a/code/modules/recycling/disposal/holder.dm +++ b/code/modules/recycling/disposal/holder.dm @@ -80,12 +80,25 @@ set_glide_size(DELAY_TO_GLIDE_SIZE(ticks * world.tick_lag)) curr = curr.transfer(src) if(!curr && active) - last.expel(src, loc, dir) + last.expel(src, get_turf(src), dir) ticks = stoplag() if(!(count--)) active = FALSE +//failsafe in the case the holder is somehow forcemoved somewhere that's not a disposal pipe. Otherwise the above loop breaks. +/obj/structure/disposalholder/Moved(atom/oldLoc, dir) + . = ..() + var/static/list/pipes_typecache = typecacheof(/obj/structure/disposalpipe) + if(!pipes_typecache[loc.type]) + var/turf/T = get_turf(loc) + if(T) + vent_gas(T) + for(var/A in contents) + var/atom/movable/AM = A + AM.forceMove(drop_location()) + qdel(src) + // find the turf which should contain the next pipe /obj/structure/disposalholder/proc/nextloc() return get_step(src, dir) diff --git a/code/modules/recycling/disposal/multiz.dm b/code/modules/recycling/disposal/multiz.dm index fe94926b967..c6760e46a07 100644 --- a/code/modules/recycling/disposal/multiz.dm +++ b/code/modules/recycling/disposal/multiz.dm @@ -23,7 +23,7 @@ if(multiz_dir == MULTIZ_PIPE_DOWN) T = SSmapping.get_turf_below(get_turf(src)) if(!T) - expel(H) + expel(H, get_turf(src), pick(GLOB.cardinals)) return //Nothing located. var/obj/structure/disposalpipe/trunk/multiz/pipe = locate(/obj/structure/disposalpipe/trunk/multiz) in T if(pipe) diff --git a/code/modules/recycling/disposal/outlet.dm b/code/modules/recycling/disposal/outlet.dm index 581c6f60679..1de442ebbd7 100644 --- a/code/modules/recycling/disposal/outlet.dm +++ b/code/modules/recycling/disposal/outlet.dm @@ -57,15 +57,9 @@ if(!H) return - var/turf/T = get_turf(src) + pipe_eject(H, dir, TRUE, target, eject_range, throw_range) - for(var/A in H) - var/atom/movable/AM = A - AM.forceMove(T) - AM.pipe_eject(dir) - AM.throw_at(target, eject_range, eject_speed) - - H.vent_gas(T) + H.vent_gas(loc) qdel(H) /obj/structure/disposaloutlet/welder_act(mob/living/user, obj/item/I) diff --git a/code/modules/recycling/disposal/pipe.dm b/code/modules/recycling/disposal/pipe.dm index 010fe56746c..bb57b76fd96 100644 --- a/code/modules/recycling/disposal/pipe.dm +++ b/code/modules/recycling/disposal/pipe.dm @@ -69,21 +69,21 @@ var/turf/T = H.nextloc() var/obj/structure/disposalpipe/P = H.findpipe(T) - if(P) - // find other holder in next loc, if inactive merge it with current - var/obj/structure/disposalholder/H2 = locate() in P - if(H2 && !H2.active) - H.merge(H2) + if(!P) // if there wasn't a pipe, then they'll be expelled. + return + // find other holder in next loc, if inactive merge it with current + var/obj/structure/disposalholder/H2 = locate() in P + if(H2 && !H2.active) + H.merge(H2) - H.forceMove(P) - return P - else // if wasn't a pipe, then they're now in our turf - H.forceMove(get_turf(src)) - return null + H.forceMove(P) + return P // expel the held objects into a turf // called when there is a break in the pipe /obj/structure/disposalpipe/proc/expel(obj/structure/disposalholder/H, turf/T, direction) + if(!T) + T = get_turf(src) var/turf/target var/eject_range = 5 var/turf/open/floor/floorturf @@ -106,12 +106,7 @@ target = get_offset_target_turf(T, rand(5)-rand(5), rand(5)-rand(5)) playsound(src, 'sound/machines/hiss.ogg', 50, FALSE, FALSE) - for(var/A in H) - var/atom/movable/AM = A - AM.forceMove(get_turf(src)) - AM.pipe_eject(direction) - if(target) - AM.throw_at(target, eject_range, 1) + pipe_eject(H, direction, TRUE, target, eject_range) H.vent_gas(T) qdel(H) diff --git a/code/modules/recycling/disposal/pipe_sorting.dm b/code/modules/recycling/disposal/pipe_sorting.dm index b785f112e99..cc9dc5f1551 100644 --- a/code/modules/recycling/disposal/pipe_sorting.dm +++ b/code/modules/recycling/disposal/pipe_sorting.dm @@ -19,8 +19,6 @@ /obj/structure/disposalpipe/sorting/proc/check_sorting(obj/structure/disposalholder/H) return FALSE - - // Mail sorting junction, uses package tags to sort objects. /obj/structure/disposalpipe/sorting/mail flip_type = /obj/structure/disposalpipe/sorting/mail/flip