Skip to content

Commit

Permalink
[MIRROR] Further Prevention of Disposals Qdeletion [MDB IGNORE] (#634)
Browse files Browse the repository at this point in the history
* Further Prevention of Disposals Qdeletion (#79714)

---------

Co-authored-by: SkyratBot <[email protected]>
Co-authored-by: san7890 <[email protected]>
  • Loading branch information
3 people authored Nov 15, 2023
1 parent 5c7ed1e commit 85b0bf1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 deletions.
38 changes: 30 additions & 8 deletions code/modules/recycling/disposal/eject.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,33 @@
* 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)
var/turf/origin_turf = get_turf(src)
var/turf/target_turf
if(isnull(target)) // done up here as a safety
target_turf = get_offset_target_turf(loc, rand(5) - rand(5), rand(5) - rand(5))
else
target_turf = target

if(QDELETED(origin_turf))
stack_trace("pipe_eject() attempted to operate on a qdeleted turf! In order to avoid sending things to nullspace, we are going to send everything directly to the target turf instead.")
origin_turf = target_turf

var/list/contents_to_eject = holder.contents
var/list/contents_to_throw = list()

for(var/atom/movable/thing in contents_to_eject)
thing.forceMove(origin_turf)
SEND_SIGNAL(thing, COMSIG_MOVABLE_PIPE_EJECTING, direction)
if(QDELETED(thing))
continue

contents_to_throw += thing

if(!throw_em)
return

for(var/atom/movable/throwable as anything in contents_to_throw)
if(isnull(target)) // we want the thrown things to be spread out a bit if we weren't given a target
target_turf = get_offset_target_turf(loc, rand(5) - rand(5), rand(5) - rand(5))

throwable.throw_at(target_turf, throw_range, throw_speed)
4 changes: 2 additions & 2 deletions code/modules/recycling/disposal/outlet.dm
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@
if((start_eject + 30) < world.time)
start_eject = world.time
playsound(src, 'sound/machines/warning-buzzer.ogg', 50, FALSE, FALSE)
addtimer(CALLBACK(src, PROC_REF(expel_holder), H, TRUE), 20)
addtimer(CALLBACK(src, PROC_REF(expel_holder), H, TRUE), 2 SECONDS)
else
addtimer(CALLBACK(src, PROC_REF(expel_holder), H), 20)
addtimer(CALLBACK(src, PROC_REF(expel_holder), H), 2 SECONDS)

/obj/structure/disposaloutlet/proc/expel_holder(obj/structure/disposalholder/H, playsound=FALSE)
if(playsound)
Expand Down

0 comments on commit 85b0bf1

Please sign in to comment.