From 13149fa93a4933bee3d30e467ba28735fcc20343 Mon Sep 17 00:00:00 2001 From: Kyep Date: Tue, 21 Jul 2020 11:56:59 -0700 Subject: [PATCH] Fixes runtimes from moving SSD/AFK people out of machines --- code/game/dna/dna_modifier.dm | 3 +++ code/game/machinery/Sleeper.dm | 3 +++ code/game/machinery/cryo.dm | 3 +++ code/game/machinery/cryopod.dm | 7 +++++++ code/game/machinery/machinery.dm | 5 +++++ code/game/machinery/suit_storage_unit.dm | 11 +++++++---- 6 files changed, 28 insertions(+), 4 deletions(-) diff --git a/code/game/dna/dna_modifier.dm b/code/game/dna/dna_modifier.dm index fb0ccff32cb..d887153c6d5 100644 --- a/code/game/dna/dna_modifier.dm +++ b/code/game/dna/dna_modifier.dm @@ -282,6 +282,9 @@ occupant = null icon_state = "scanner_open" +/obj/machinery/dna_scannernew/force_eject_occupant() + go_out(null, TRUE) + /obj/machinery/dna_scannernew/ex_act(severity) if(occupant) occupant.ex_act(severity) diff --git a/code/game/machinery/Sleeper.dm b/code/game/machinery/Sleeper.dm index e4d0befa61e..7c5a03e29e6 100644 --- a/code/game/machinery/Sleeper.dm +++ b/code/game/machinery/Sleeper.dm @@ -411,6 +411,9 @@ for(var/atom/movable/A in contents - component_parts - list(beaker)) A.forceMove(loc) +/obj/machinery/sleeper/force_eject_occupant() + go_out() + /obj/machinery/sleeper/proc/inject_chemical(mob/living/user as mob, chemical, amount) if(!(chemical in possible_chems)) to_chat(user, "The sleeper does not offer that chemical!") diff --git a/code/game/machinery/cryo.dm b/code/game/machinery/cryo.dm index 4213ff517bf..8be09ef30b7 100644 --- a/code/game/machinery/cryo.dm +++ b/code/game/machinery/cryo.dm @@ -443,6 +443,9 @@ for(var/atom/movable/A in contents - component_parts - list(beaker)) A.forceMove(get_step(loc, SOUTH)) +/obj/machinery/atmospherics/unary/cryo_cell/force_eject_occupant() + go_out() + /// Called when either the occupant is dead and the AUTO_EJECT_DEAD flag is present, OR the occupant is alive, has no external damage, and the AUTO_EJECT_HEALTHY flag is present. /obj/machinery/atmospherics/unary/cryo_cell/proc/auto_eject(eject_flag) on = FALSE diff --git a/code/game/machinery/cryopod.dm b/code/game/machinery/cryopod.dm index 36196ea4eca..e0d53d61505 100644 --- a/code/game/machinery/cryopod.dm +++ b/code/game/machinery/cryopod.dm @@ -768,9 +768,16 @@ return ..() + /proc/cryo_ssd(var/mob/living/carbon/person_to_cryo) if(istype(person_to_cryo.loc, /obj/machinery/cryopod)) return 0 + if(istype(person_to_cryo.loc, /obj/mecha)) + var/obj/mecha/E = person_to_cryo.loc + E.go_out() + if(istype(person_to_cryo.loc, /obj/machinery)) + var/obj/machinery/E = person_to_cryo.loc + E.force_eject_occupant() var/list/free_cryopods = list() for(var/obj/machinery/cryopod/P in GLOB.machines) if(!P.occupant && istype(get_area(P), /area/crew_quarters/sleep)) diff --git a/code/game/machinery/machinery.dm b/code/game/machinery/machinery.dm index f02e037e8c5..f1f66314dda 100644 --- a/code/game/machinery/machinery.dm +++ b/code/game/machinery/machinery.dm @@ -597,3 +597,8 @@ Class Procs: . = . % 9 AM.pixel_x = -8 + ((.%3)*8) AM.pixel_y = -8 + (round( . / 3)*8) + +/obj/machinery/proc/force_eject_occupant() + // For each subtype of /machinery, this proc handles safely removing occupants from the machine if they must be cryoed due to being SSD/AFK. + // In the event that the machinery doesn't have an overriden version of this proc to do it, log a runtime so one can be added. + log_runtime(EXCEPTION("Proc force_eject_occupant() is not overriden on a machine containing a mob."), src) \ No newline at end of file diff --git a/code/game/machinery/suit_storage_unit.dm b/code/game/machinery/suit_storage_unit.dm index da4df4f8382..98a50d0c69d 100644 --- a/code/game/machinery/suit_storage_unit.dm +++ b/code/game/machinery/suit_storage_unit.dm @@ -740,10 +740,11 @@ if(!occupant) return - if(user != occupant) - to_chat(occupant, "The machine kicks you out!") - if(user.loc != loc) - to_chat(occupant, "You leave the not-so-cozy confines of the SSU.") + if(user) + if(user != occupant) + to_chat(occupant, "The machine kicks you out!") + if(user.loc != loc) + to_chat(occupant, "You leave the not-so-cozy confines of the SSU.") occupant.forceMove(loc) occupant = null if(!state_open) @@ -751,6 +752,8 @@ update_icon() return +/obj/machinery/suit_storage_unit/force_eject_occupant() + eject_occupant() /obj/machinery/suit_storage_unit/verb/get_out() set name = "Eject Suit Storage Unit"