diff --git a/code/datums/datum.dm b/code/datums/datum.dm index 481a62b058f..8fbd5fa1476 100644 --- a/code/datums/datum.dm +++ b/code/datums/datum.dm @@ -91,6 +91,7 @@ */ /datum/proc/Destroy(force=FALSE, ...) SHOULD_CALL_PARENT(TRUE) + SHOULD_NOT_SLEEP(TRUE) tag = null datum_flags &= ~DF_USE_TAG //In case something tries to REF us weak_reference = null //ensure prompt GCing of weakref. diff --git a/code/game/objects/structures/kitchen_spike.dm b/code/game/objects/structures/kitchen_spike.dm index 68408bc91d2..646b0e86f28 100644 --- a/code/game/objects/structures/kitchen_spike.dm +++ b/code/game/objects/structures/kitchen_spike.dm @@ -128,13 +128,13 @@ M.adjustBruteLoss(30) src.visible_message(span_danger("[M] falls free of [src]!")) unbuckle_mob(M,force=1) - M.emote("scream") + INVOKE_ASYNC(M, /mob/proc/emote, "scream") M.AdjustParalyzed(20) /obj/structure/kitchenspike/Destroy() if(has_buckled_mobs()) - for(var/mob/living/L in buckled_mobs) - release_mob(L) + for(var/mob/living/spiked_lad as anything in buckled_mobs) + release_mob(spiked_lad) return ..() /obj/structure/kitchenspike/deconstruct(disassembled = TRUE) diff --git a/code/game/objects/structures/training_machine.dm b/code/game/objects/structures/training_machine.dm index a3fe707a517..837c11f18a7 100644 --- a/code/game/objects/structures/training_machine.dm +++ b/code/game/objects/structures/training_machine.dm @@ -164,7 +164,7 @@ UnregisterSignal(attached_item, COMSIG_PARENT_QDELETING) qdel(attached_item) else if (user) - user.put_in_hands(attached_item) + INVOKE_ASYNC(user, /mob/proc/put_in_hands, attached_item) else attached_item.forceMove(drop_location()) if (throwing && !QDELETED(attached_item)) //Fun little thing where we throw out the old attached item when emagged diff --git a/code/modules/admin/verbs/adminhelp.dm b/code/modules/admin/verbs/adminhelp.dm index afb7b00a26c..a76ab1997f1 100644 --- a/code/modules/admin/verbs/adminhelp.dm +++ b/code/modules/admin/verbs/adminhelp.dm @@ -134,7 +134,8 @@ GLOBAL_DATUM_INIT(ahelp_tickets, /datum/admin_help_tickets, new) if(C.current_ticket) var/datum/admin_help/T = C.current_ticket T.AddInteraction("Client disconnected.") - SSblackbox.LogAhelp(T, "Disconnected", "Client disconnected", C.ckey) + //Gotta async this cause clients only logout on destroy, and sleeping in destroy is disgusting + INVOKE_ASYNC(SSblackbox, /datum/controller/subsystem/blackbox/proc/LogAhelp, T, "Disconnected", "Client disconnected", C.ckey) T.initiator = null //Get a ticket given a ckey diff --git a/code/modules/admin/verbs/anonymousnames.dm b/code/modules/admin/verbs/anonymousnames.dm index c9a87e1399d..7ce001fb7f9 100644 --- a/code/modules/admin/verbs/anonymousnames.dm +++ b/code/modules/admin/verbs/anonymousnames.dm @@ -113,7 +113,7 @@ GLOBAL_DATUM(current_anonymous_theme, /datum/anonymous_theme) continue var/old_name = player.real_name //before restoration if(issilicon(player)) - player.apply_pref_name("[isAI(player) ? /datum/preference/name/ai : /datum/preference/name/cyborg]", player.client) + INVOKE_ASYNC(player, /mob/proc/apply_pref_name, "[isAI(player) ? /datum/preference/name/ai : /datum/preference/name/cyborg]", player.client) else player.client.prefs.apply_prefs_to(player) // This is not sound logic, as the prefs may have changed since then. player.fully_replace_character_name(old_name, player.real_name) //this changes IDs and PDAs and whatnot diff --git a/code/modules/antagonists/wizard/equipment/soulstone.dm b/code/modules/antagonists/wizard/equipment/soulstone.dm index 584ce66d5ec..8e32dadffd7 100644 --- a/code/modules/antagonists/wizard/equipment/soulstone.dm +++ b/code/modules/antagonists/wizard/equipment/soulstone.dm @@ -117,8 +117,8 @@ . += span_cult("This shard is spent; it is now just a creepy rock.") /obj/item/soulstone/Destroy() //Stops the shade from being qdel'd immediately and their ghost being sent back to the arrival shuttle. - for(var/mob/living/simple_animal/shade/A in src) - A.death() + for(var/mob/living/simple_animal/shade/shade in src) + INVOKE_ASYNC(shade, /mob/living/proc/death) return ..() /obj/item/soulstone/proc/hot_potato(mob/living/user) diff --git a/code/modules/holodeck/computer.dm b/code/modules/holodeck/computer.dm index 06066f7092b..7e457775a90 100644 --- a/code/modules/holodeck/computer.dm +++ b/code/modules/holodeck/computer.dm @@ -206,21 +206,7 @@ and clear when youre done! if you dont i will use :newspaper2: on you update_use_power(active + IDLE_POWER_USE) program = map_id - //clear the items from the previous program - for(var/holo_atom in spawned) - derez(holo_atom) - - for(var/obj/effect/holodeck_effect/holo_effect as anything in effects) - effects -= holo_effect - holo_effect.deactivate(src) - - //makes sure that any time a holoturf is inside a baseturf list (e.g. if someone put a wall over it) its set to the OFFLINE turf - //so that you cant bring turfs from previous programs into other ones (like putting the plasma burn turf into lounge for example) - for(var/turf/closed/holo_turf in linked) - for(var/baseturf in holo_turf.baseturfs) - if(ispath(baseturf, /turf/open/floor/holofloor)) - holo_turf.baseturfs -= baseturf - holo_turf.baseturfs += /turf/open/floor/holofloor/plating + clear_projection() template = SSmapping.holodeck_templates[map_id] template.load(bottom_left) //this is what actually loads the holodeck simulation into the map @@ -238,6 +224,34 @@ and clear when youre done! if you dont i will use :newspaper2: on you nerf(!(obj_flags & EMAGGED)) finish_spawn() +///To be used on destroy, mainly to prevent sleeping inside well, destroy. Missing a lot of the things contained in load_program +/obj/machinery/computer/holodeck/proc/reset_to_default() + if (program == offline_program) + return + + program = offline_program + clear_projection() + + template = SSmapping.holodeck_templates[offline_program] + INVOKE_ASYNC(template, /datum/map_template/proc/load, bottom_left) //this is what actually loads the holodeck simulation into the map + +/obj/machinery/computer/holodeck/proc/clear_projection() + //clear the items from the previous program + for(var/holo_atom in spawned) + derez(holo_atom) + + for(var/obj/effect/holodeck_effect/holo_effect as anything in effects) + effects -= holo_effect + holo_effect.deactivate(src) + + //makes sure that any time a holoturf is inside a baseturf list (e.g. if someone put a wall over it) its set to the OFFLINE turf + //so that you cant bring turfs from previous programs into other ones (like putting the plasma burn turf into lounge for example) + for(var/turf/closed/holo_turf in linked) + for(var/baseturf in holo_turf.baseturfs) + if(ispath(baseturf, /turf/open/floor/holofloor)) + holo_turf.baseturfs -= baseturf + holo_turf.baseturfs += /turf/open/floor/holofloor/plating + ///finalizes objects in the spawned list /obj/machinery/computer/holodeck/proc/finish_spawn() for(var/atom/holo_atom as anything in spawned) @@ -393,7 +407,7 @@ and clear when youre done! if you dont i will use :newspaper2: on you return ..() /obj/machinery/computer/holodeck/Destroy() - emergency_shutdown() + reset_to_default() if(linked) linked.linked = null linked.power_usage = list(AREA_USAGE_LEN) diff --git a/code/modules/mapping/space_management/space_reservation.dm b/code/modules/mapping/space_management/space_reservation.dm index e05ea740037..4d4c6b34daa 100644 --- a/code/modules/mapping/space_management/space_reservation.dm +++ b/code/modules/mapping/space_management/space_reservation.dm @@ -18,7 +18,7 @@ for(var/i in reserved_turfs) reserved_turfs -= i SSmapping.used_turfs -= i - SSmapping.reserve_turfs(v) + INVOKE_ASYNC(SSmapping, /datum/controller/subsystem/mapping/proc/reserve_turfs, v) /datum/turf_reservation/proc/Reserve(width, height, zlevel) if(width > world.maxx || height > world.maxy || width < 1 || height < 1) diff --git a/code/modules/modular_computers/computers/item/computer.dm b/code/modules/modular_computers/computers/item/computer.dm index 7c9f59d0506..a84318607d2 100644 --- a/code/modules/modular_computers/computers/item/computer.dm +++ b/code/modules/modular_computers/computers/item/computer.dm @@ -64,7 +64,7 @@ update_appearance() /obj/item/modular_computer/Destroy() - kill_program(forced = TRUE) + wipe_program(forced = TRUE) STOP_PROCESSING(SSobj, src) for(var/port in all_components) var/obj/item/computer_hardware/component = all_components[port] @@ -410,14 +410,20 @@ data["PC_showexitprogram"] = active_program ? 1 : 0 // Hides "Exit Program" button on mainscreen return data +///Wipes the computer's current program. Doesn't handle any of the niceties around doing this +/obj/item/modular_computer/proc/wipe_program(forced) + if(!active_program) + return + active_program.kill_program(forced) + active_program = null + // Relays kill program request to currently active program. Use this to quit current program. /obj/item/modular_computer/proc/kill_program(forced = FALSE) - if(active_program) - active_program.kill_program(forced) - active_program = null + wipe_program(forced) var/mob/user = usr if(user && istype(user)) - ui_interact(user) // Re-open the UI on this computer. It should show the main screen now. + //Here to prevent programs sleeping in destroy + INVOKE_ASYNC(src, /datum/proc/ui_interact, user) // Re-open the UI on this computer. It should show the main screen now. update_appearance() // Returns 0 for No Signal, 1 for Low Signal and 2 for Good Signal. 3 is for wired connection (always-on) diff --git a/code/modules/power/apc.dm b/code/modules/power/apc.dm index 2bba663989c..75ff49520c2 100644 --- a/code/modules/power/apc.dm +++ b/code/modules/power/apc.dm @@ -1202,7 +1202,7 @@ to_chat(occupier, span_danger("Primary core damaged, unable to return core processes.")) if(forced) occupier.forceMove(drop_location()) - occupier.death() + INVOKE_ASYNC(occupier, /mob/living/proc/death) occupier.gib() if(!occupier.nuking) //Pinpointers go back to tracking the nuke disk, as long as the AI (somehow) isn't mid-nuking. diff --git a/code/modules/vehicles/mecha/working/clarke.dm b/code/modules/vehicles/mecha/working/clarke.dm index 5408b6bbab8..a949bec8ad6 100644 --- a/code/modules/vehicles/mecha/working/clarke.dm +++ b/code/modules/vehicles/mecha/working/clarke.dm @@ -25,7 +25,7 @@ ME.attach(src) /obj/vehicle/sealed/mecha/working/clarke/Destroy() - box.dump_box_contents() + INVOKE_ASYNC(box, /obj/structure/ore_box/proc/dump_box_contents) return ..() /obj/vehicle/sealed/mecha/working/clarke/moved_inside(mob/living/carbon/human/H)