From 25d1a5e7a238ae3e5935b3090c3cd41b889e7cb4 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Wed, 13 Oct 2021 20:23:32 +0200 Subject: [PATCH] [MIRROR] Fixes a few hard deletes and runtimes I either caused, or ran into when trying to fix hard deletes [MDB IGNORE] (#8713) * Fixes a few hard deletes and runtimes I either caused, or ran into when trying to fix hard deletes (#61953) Please don't try and send chat messages if you have nothing to say Fixes a spurious runtime. Fixes a runtime caused by my lack of understanding of huds. remove_hud_from is intended for hud watchers, remove_from_hud is intended for hud items. Doesn't really make sense most of the time, and just runtimes out the ass Fixes a runtime in shapeshifting, restore should not run if the object is not restoring, or if it's deleting. it should run if it's not restoring, and it's not deleted. 4head Fun fact, if there's two turret control boards they'll override each other. Use weakrefs. Oh also removes a var called cp, nothing good will come of that Today in: Good lord the stacking machine is an afront to god, we discover that the labor claims console was attempting to act as a console, which of course fails when it comes time to clear it's improperly named var. Disgusting Attempts to fix potential wound ref hangs in surgeries? maybe? Fixes a runtime in luminescent stuff I created in my big harddel crusade. owner is a mob, not a species Fixes a runtime related to headspikes deleting themselves twice. Pain Fixes hard deletes sourced from the prophet trauma. Good fucking lord this is awful Offhand item is somehow hard deleting. I have no idea how. Here's hoping signals fixes it, because if it doesn't I'm stumped. It's not a common scenario, but it does happen in spurts that suggest repeated usage * Fixes a few hard deletes and runtimes I either caused, or ran into when trying to fix hard deletes * Update turret_id_system.dm * Update turret_id_system.dm Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com> Co-authored-by: Gandalf --- code/datums/brain_damage/brain_trauma.dm | 2 +- code/datums/brain_damage/special.dm | 7 ++++++ code/datums/components/twohanded.dm | 9 +++++++- code/datums/hud.dm | 1 - .../machinery/porta_turret/portable_turret.dm | 22 +++++++++---------- code/game/objects/structures/headpike.dm | 3 ++- code/modules/mining/laborcamp/laborstacker.dm | 12 ++++++++-- .../carbon/human/species_types/jellypeople.dm | 13 +++++++++-- code/modules/spells/spell_types/shapeshift.dm | 2 +- code/modules/surgery/surgery.dm | 1 + .../modules/turretid/code/turret_id_system.dm | 8 +++---- 11 files changed, 54 insertions(+), 26 deletions(-) diff --git a/code/datums/brain_damage/brain_trauma.dm b/code/datums/brain_damage/brain_trauma.dm index 0cafd103955..75aa5953fc8 100644 --- a/code/datums/brain_damage/brain_trauma.dm +++ b/code/datums/brain_damage/brain_trauma.dm @@ -41,7 +41,7 @@ //Called when removed from a mob /datum/brain_trauma/proc/on_lose(silent) - if(!silent) + if(!silent && lose_text) to_chat(owner, lose_text) UnregisterSignal(owner, COMSIG_MOB_SAY) UnregisterSignal(owner, COMSIG_MOVABLE_HEAR) diff --git a/code/datums/brain_damage/special.dm b/code/datums/brain_damage/special.dm index 6fc7e60fc4f..87d73232b3a 100644 --- a/code/datums/brain_damage/special.dm +++ b/code/datums/brain_damage/special.dm @@ -108,6 +108,13 @@ . = ..() QDEL_IN(src, 300) +/obj/effect/hallucination/simple/bluespace_stream/Destroy() + if(!QDELETED(linked_to)) + qdel(linked_to) + linked_to = null + seer = null + return ..() + //ATTACK HAND IGNORING PARENT RETURN VALUE /obj/effect/hallucination/simple/bluespace_stream/attack_hand(mob/user, list/modifiers) if(user != seer || !linked_to) diff --git a/code/datums/components/twohanded.dm b/code/datums/components/twohanded.dm index c2d129af634..d1f78b56114 100644 --- a/code/datums/components/twohanded.dm +++ b/code/datums/components/twohanded.dm @@ -108,8 +108,14 @@ if(wielded) unwield(user) if(source == offhand_item && !QDELETED(source)) + offhand_item = null qdel(source) +/// Triggered on destroy of the component's offhand +/datum/component/two_handed/proc/on_destroy(datum/source) + SIGNAL_HANDLER + offhand_item = null + /// Triggered on attack self of the item containing the component /datum/component/two_handed/proc/on_attack_self(datum/source, mob/user) SIGNAL_HANDLER @@ -181,6 +187,7 @@ offhand_item.desc = "Your second grip on [parent_item]." offhand_item.wielded = TRUE RegisterSignal(offhand_item, COMSIG_ITEM_DROPPED, .proc/on_drop) + RegisterSignal(offhand_item, COMSIG_PARENT_QDELETING, .proc/on_destroy) user.put_in_inactive_hand(offhand_item) /** @@ -245,7 +252,7 @@ // Remove the object in the offhand if(offhand_item) - UnregisterSignal(offhand_item, COMSIG_ITEM_DROPPED) + UnregisterSignal(offhand_item, list(COMSIG_ITEM_DROPPED, COMSIG_PARENT_QDELETING)) qdel(offhand_item) // Clear any old refrence to an item that should be gone now offhand_item = null diff --git a/code/datums/hud.dm b/code/datums/hud.dm index 930a244d73b..0a8218e4f82 100644 --- a/code/datums/hud.dm +++ b/code/datums/hud.dm @@ -100,7 +100,6 @@ GLOBAL_LIST_INIT(huds, list( /datum/atom_hud/proc/unregister_mob(datum/source, force) SIGNAL_HANDLER remove_hud_from(source, TRUE) - remove_from_hud(source) /datum/atom_hud/proc/hide_single_atomhud_from(hud_user,hidden_atom) if(hudusers[hud_user]) diff --git a/code/game/machinery/porta_turret/portable_turret.dm b/code/game/machinery/porta_turret/portable_turret.dm index 28b94c675c3..75dfc414a6d 100644 --- a/code/game/machinery/porta_turret/portable_turret.dm +++ b/code/game/machinery/porta_turret/portable_turret.dm @@ -93,8 +93,6 @@ DEFINE_BITFIELD(turret_flags, list( var/list/faction = list("turret") /// The spark system, used for generating... sparks? var/datum/effect_system/spark_spread/spark_system - /// Linked turret control panel of the turret - var/obj/machinery/turretid/cp = null /// The turret will try to shoot from a turf in that direction when in a wall var/wall_turret_direction /// If the turret is manually controlled @@ -204,9 +202,6 @@ DEFINE_BITFIELD(turret_flags, list( //deletes its own cover with it QDEL_NULL(cover) base = null - if(cp) - cp.turrets -= src - cp = null QDEL_NULL(stored_gun) QDEL_NULL(spark_system) remove_control() @@ -877,7 +872,7 @@ DEFINE_BITFIELD(turret_flags, list( var/ailock = FALSE /// Variable dictating if linked turrets will shoot cyborgs var/shoot_cyborgs = FALSE - /// List of all linked turrets + /// List of weakrefs to all turrets var/list/turrets = list() /obj/machinery/turretid/Initialize(mapload, ndir = 0, built = 0) @@ -907,9 +902,8 @@ DEFINE_BITFIELD(turret_flags, list( control_area = get_area(src) for(var/obj/machinery/porta_turret/T in control_area) - turrets |= T - T.cp = src - + turrets |= WEAKREF(T) + /obj/machinery/turretid/examine(mob/user) . += ..() if(issilicon(user) && !(machine_stat & BROKEN)) @@ -925,7 +919,7 @@ DEFINE_BITFIELD(turret_flags, list( return var/obj/item/multitool/M = I if(M.buffer && istype(M.buffer, /obj/machinery/porta_turret)) - turrets |= M.buffer + turrets |= WEAKREF(M.buffer) to_chat(user, span_notice("You link \the [M.buffer] with \the [src].")) return @@ -1014,8 +1008,12 @@ DEFINE_BITFIELD(turret_flags, list( updateTurrets() /obj/machinery/turretid/proc/updateTurrets() - for (var/obj/machinery/porta_turret/aTurret in turrets) - aTurret.setState(enabled, lethal, shoot_cyborgs) + for (var/datum/weakref/turret_ref in turrets) + var/obj/machinery/porta_turret/turret = turret_ref.resolve() + if(!turret) + turrets -= turret_ref + continue + turret.setState(enabled, lethal, shoot_cyborgs) update_appearance() /obj/machinery/turretid/update_icon_state() diff --git a/code/game/objects/structures/headpike.dm b/code/game/objects/structures/headpike.dm index f31ee2445c3..b504a4e3bc7 100644 --- a/code/game/objects/structures/headpike.dm +++ b/code/game/objects/structures/headpike.dm @@ -54,7 +54,8 @@ victim = null if(A == spear) spear = null - deconstruct(TRUE) + if(!QDELETED(src)) + deconstruct(TRUE) return ..() /obj/structure/headpike/deconstruct(disassembled) diff --git a/code/modules/mining/laborcamp/laborstacker.dm b/code/modules/mining/laborcamp/laborstacker.dm index 08ef42fa89d..dce21b25a90 100644 --- a/code/modules/mining/laborcamp/laborstacker.dm +++ b/code/modules/mining/laborcamp/laborstacker.dm @@ -36,7 +36,7 @@ GLOBAL_LIST(labor_sheet_values) /obj/machinery/mineral/labor_claim_console/Destroy() QDEL_NULL(Radio) if(stacking_machine) - stacking_machine.console = null + stacking_machine.labor_console = null stacking_machine = null return ..() @@ -125,7 +125,7 @@ GLOBAL_LIST(labor_sheet_values) /obj/machinery/mineral/labor_claim_console/proc/locate_stacking_machine() stacking_machine = locate(/obj/machinery/mineral/stacking_machine, get_step(src, machinedir)) if(stacking_machine) - stacking_machine.console = src + stacking_machine.labor_console = src /obj/machinery/mineral/labor_claim_console/emag_act(mob/user) if(!(obj_flags & EMAGGED)) @@ -138,6 +138,14 @@ GLOBAL_LIST(labor_sheet_values) force_connect = TRUE var/points = 0 //The unclaimed value of ore stacked. damage_deflection = 21 + var/obj/machinery/mineral/labor_claim_console/labor_console //This is abhorent. I know. + +/obj/machinery/mineral/stacking_machine/laborstacker/Destroy() + if(labor_console) + labor_console.stacking_machine = null + labor_console = null + return ..() + /obj/machinery/mineral/stacking_machine/laborstacker/process_sheet(obj/item/stack/sheet/inp) points += inp.point_value * inp.amount ..() diff --git a/code/modules/mob/living/carbon/human/species_types/jellypeople.dm b/code/modules/mob/living/carbon/human/species_types/jellypeople.dm index 5afda551774..52534a77582 100644 --- a/code/modules/mob/living/carbon/human/species_types/jellypeople.dm +++ b/code/modules/mob/living/carbon/human/species_types/jellypeople.dm @@ -563,8 +563,17 @@ /datum/action/innate/use_extract/ApplyIcon(atom/movable/screen/movable/action_button/current_button, force) ..(current_button, TRUE) - var/datum/species/jelly/luminescent/species = owner - if(species?.current_extract) + + if(!ishuman(owner)) + return + + var/mob/living/carbon/human/gazer = owner + var/datum/species/jelly/luminescent/species = gazer?.dna?.species + + if(!istype(species, /datum/species/jelly/luminescent)) + return + + if(species.current_extract) current_button.add_overlay(mutable_appearance(species.current_extract.icon, species.current_extract.icon_state)) /datum/action/innate/use_extract/Activate() diff --git a/code/modules/spells/spell_types/shapeshift.dm b/code/modules/spells/spell_types/shapeshift.dm index 77e76e9661c..9a24d957d64 100644 --- a/code/modules/spells/spell_types/shapeshift.dm +++ b/code/modules/spells/spell_types/shapeshift.dm @@ -173,7 +173,7 @@ /obj/shapeshift_holder/Moved() . = ..() - if(!restoring || QDELETED(src)) + if(!restoring && !QDELETED(src)) restore() /obj/shapeshift_holder/handle_atom_del(atom/A) diff --git a/code/modules/surgery/surgery.dm b/code/modules/surgery/surgery.dm index 9b29997da13..1462a436274 100644 --- a/code/modules/surgery/surgery.dm +++ b/code/modules/surgery/surgery.dm @@ -38,6 +38,7 @@ /datum/surgery/Destroy() if(operated_wound) operated_wound.attached_surgery = null + operated_wound = null if(target) target.surgeries -= src target = null diff --git a/modular_skyrat/modules/turretid/code/turret_id_system.dm b/modular_skyrat/modules/turretid/code/turret_id_system.dm index 246fa7b6760..2c84f1de43c 100644 --- a/modular_skyrat/modules/turretid/code/turret_id_system.dm +++ b/modular_skyrat/modules/turretid/code/turret_id_system.dm @@ -11,12 +11,11 @@ GLOBAL_LIST_EMPTY(turret_id_refs) GLOB.turret_id_refs[system_id][src] = TRUE /obj/machinery/porta_turret/Destroy() - . = ..() if(system_id && GLOB.turret_id_refs[system_id]) GLOB.turret_id_refs[system_id] -= src if(!length(GLOB.turret_id_refs[system_id])) GLOB.turret_id_refs -= system_id - + return ..() /obj/machinery/turretid var/system_id //The ID system for turrets, will get any turrets with the same ID and put them in controlled turrets @@ -25,6 +24,5 @@ GLOBAL_LIST_EMPTY(turret_id_refs) if(system_id && GLOB.turret_id_refs[system_id]) for(var/i in GLOB.turret_id_refs[system_id]) var/obj/machinery/porta_turret/T = i - turrets |= T - T.cp = src - + turrets |= WEAKREF(T) +