From fb02933f30bcc5f38a0ec936654bbab814f81e5d Mon Sep 17 00:00:00 2001 From: Fox-McCloud Date: Mon, 3 Apr 2017 19:06:20 -0400 Subject: [PATCH 1/4] For qdel and Destroy Fixes --- code/game/machinery/cloning.dm | 7 +++- code/game/objects/effects/anomalies.dm | 4 ++- code/game/objects/effects/spiders.dm | 11 ++++-- .../game/objects/items/devices/radio/radio.dm | 2 +- .../objects/items/weapons/dna_injector.dm | 7 +++- code/modules/food_and_drinks/food/snacks.dm | 17 +++------ .../mob/living/simple_animal/simple_animal.dm | 35 ++++++++++--------- code/modules/recycling/disposal.dm | 3 +- 8 files changed, 49 insertions(+), 37 deletions(-) diff --git a/code/game/machinery/cloning.dm b/code/game/machinery/cloning.dm index 5d8372607d8..c75ca58140e 100644 --- a/code/game/machinery/cloning.dm +++ b/code/game/machinery/cloning.dm @@ -104,13 +104,18 @@ /obj/item/weapon/disk/data name = "Cloning Data Disk" icon_state = "datadisk0" //Gosh I hope syndies don't mistake them for the nuke disk. - var/datum/dna2/record/buf=null + var/datum/dna2/record/buf = null var/read_only = 0 //Well,it's still a floppy disk /obj/item/weapon/disk/data/proc/Initialize() buf = new buf.dna=new +/obj/item/weapon/disk/data/Destroy() + if(buf) + QDEL_NULL(buf) + return ..() + /obj/item/weapon/disk/data/demo name = "data disk - 'God Emperor of Mankind'" read_only = 1 diff --git a/code/game/objects/effects/anomalies.dm b/code/game/objects/effects/anomalies.dm index 434fec620b8..e0a6e59da14 100644 --- a/code/game/objects/effects/anomalies.dm +++ b/code/game/objects/effects/anomalies.dm @@ -19,8 +19,10 @@ var/new_frequency = sanitize_frequency(rand(PUBLIC_LOW_FREQ, PUBLIC_HIGH_FREQ)) aSignal.set_frequency(new_frequency) poi_list |= src - + /obj/effect/anomaly/Destroy() + if(aSignal) + QDEL_NULL(aSignal) poi_list.Remove(src) return ..() diff --git a/code/game/objects/effects/spiders.dm b/code/game/objects/effects/spiders.dm index 8ed8d045de4..0a9f49cd2d0 100644 --- a/code/game/objects/effects/spiders.dm +++ b/code/game/objects/effects/spiders.dm @@ -6,6 +6,11 @@ anchored = 1 density = 0 var/health = 15 + var/master_commander = null + +/obj/structure/spider/Destroy() + master_commander = null + return ..() //similar to weeds, but only barfed out by nurses manually /obj/structure/spider/ex_act(severity) @@ -78,7 +83,6 @@ var/amount_grown = 0 var/player_spiders = 0 var/faction = list() - var/master_commander = null /obj/structure/spider/eggcluster/New() pixel_x = rand(3,-3) @@ -110,7 +114,6 @@ var/travelling_in_vent = 0 var/player_spiders = 0 var/faction = list() - var/master_commander = null var/selecting_player = 0 /obj/structure/spider/spiderling/New() @@ -118,6 +121,10 @@ pixel_y = rand(6,-6) processing_objects.Add(src) +/obj/structure/spider/spiderling/Destroy() + entry_vent = null + return ..() + /obj/structure/spider/spiderling/Bump(atom/user) if(istype(user, /obj/structure/table)) src.loc = user.loc diff --git a/code/game/objects/items/devices/radio/radio.dm b/code/game/objects/items/devices/radio/radio.dm index 429ef47970a..c4fedf48255 100644 --- a/code/game/objects/items/devices/radio/radio.dm +++ b/code/game/objects/items/devices/radio/radio.dm @@ -271,7 +271,7 @@ var/global/list/default_medbay_channels = list( /mob/living/automatedannouncer/Destroy() if(lifetime_timer) deltimer(lifetime_timer) - ..() + return ..() /mob/living/automatedannouncer/proc/autocleanup() log_runtime(EXCEPTION("An announcer somehow managed to outlive the radio! Deleting!"), src, list("Message: '[message]'")) diff --git a/code/game/objects/items/weapons/dna_injector.dm b/code/game/objects/items/weapons/dna_injector.dm index edf3c737787..86ed5f84974 100644 --- a/code/game/objects/items/weapons/dna_injector.dm +++ b/code/game/objects/items/weapons/dna_injector.dm @@ -5,7 +5,7 @@ icon_state = "dnainjector" item_state = "dnainjector" var/block = 0 - var/datum/dna2/record/buf=null + var/datum/dna2/record/buf = null throw_speed = 3 throw_range = 5 w_class = 1 @@ -26,6 +26,11 @@ buf.dna.ResetSE() SetValue(value) +/obj/item/weapon/dnainjector/Destroy() + if(buf) + QDEL_NULL(buf) + return ..() + /obj/item/weapon/dnainjector/proc/GetRealBlock(var/selblock) if(selblock==0) return block diff --git a/code/modules/food_and_drinks/food/snacks.dm b/code/modules/food_and_drinks/food/snacks.dm index d6148b429e0..3a079e99da4 100644 --- a/code/modules/food_and_drinks/food/snacks.dm +++ b/code/modules/food_and_drinks/food/snacks.dm @@ -1218,28 +1218,19 @@ var/monkey_type = "Monkey" list_reagents = list("nutriment" = 2) -/obj/item/weapon/reagent_containers/food/snacks/monkeycube/afterattack(obj/O, mob/user, proximity) - if(!proximity) - return - if(istype(O, /obj/structure/sink)) - to_chat(user, "You place [src] under a stream of water...") - user.drop_item() - forceMove(get_turf(O)) - return Expand() - ..() - /obj/item/weapon/reagent_containers/food/snacks/monkeycube/water_act(volume, temperature) if(volume >= 5) return Expand() /obj/item/weapon/reagent_containers/food/snacks/monkeycube/wash(mob/user, atom/source) - if(do_after(user, 40, target = source)) - return 1 + user.drop_item() + forceMove(get_turf(source)) + return 1 /obj/item/weapon/reagent_containers/food/snacks/monkeycube/proc/Expand() if(isnull(gcDestroyed)) visible_message("[src] expands!") - new/mob/living/carbon/human(get_turf(src),monkey_type) + new/mob/living/carbon/human(get_turf(src), monkey_type) qdel(src) /obj/item/weapon/reagent_containers/food/snacks/monkeycube/farwacube diff --git a/code/modules/mob/living/simple_animal/simple_animal.dm b/code/modules/mob/living/simple_animal/simple_animal.dm index aec9d2d0c95..7c951cebbc9 100644 --- a/code/modules/mob/living/simple_animal/simple_animal.dm +++ b/code/modules/mob/living/simple_animal/simple_animal.dm @@ -96,6 +96,7 @@ if(collar) collar.forceMove(loc) collar = null + master_commander = null simple_animal_list -= src return ..() @@ -303,7 +304,7 @@ /mob/living/simple_animal/proc/attacked_by(obj/item/I, mob/living/user) // Handled in _onclick/click.dm return - + /mob/living/simple_animal/bullet_act(var/obj/item/projectile/Proj) if(!Proj) return @@ -662,15 +663,15 @@ . = ..() /mob/living/simple_animal/can_equip(obj/item/I, slot, disable_warning = 0) - // . = ..() // Do not call parent. We do not want animals using their hand slots. - switch(slot) - if(slot_collar) - if(collar) - return 0 - if(!can_collar) - return 0 - if(!istype(I, /obj/item/clothing/accessory/petcollar)) - return 0 + // . = ..() // Do not call parent. We do not want animals using their hand slots. + switch(slot) + if(slot_collar) + if(collar) + return 0 + if(!can_collar) + return 0 + if(!istype(I, /obj/item/clothing/accessory/petcollar)) + return 0 return 1 /mob/living/simple_animal/equip_to_slot(obj/item/W, slot) @@ -692,13 +693,13 @@ name = collar.tagname real_name = collar.tagname regenerate_icons() - -/mob/living/simple_animal/unEquip(obj/item/I, force) - . = ..() - if(!. || !I) - return - - if(I == collar) + +/mob/living/simple_animal/unEquip(obj/item/I, force) + . = ..() + if(!. || !I) + return + + if(I == collar) collar = null regenerate_icons() diff --git a/code/modules/recycling/disposal.dm b/code/modules/recycling/disposal.dm index dd3856afcc4..a3f038a507a 100644 --- a/code/modules/recycling/disposal.dm +++ b/code/modules/recycling/disposal.dm @@ -500,7 +500,8 @@ var/hasmob = 0 //If it contains a mob Destroy() - qdel(gas) + if(gas) + QDEL_NULL(gas) active = 0 return ..() From 21b1c091ad95a60e458b043ff560490bc3ef11d0 Mon Sep 17 00:00:00 2001 From: Fox-McCloud Date: Mon, 3 Apr 2017 19:44:04 -0400 Subject: [PATCH 2/4] more things --- code/game/machinery/camera/camera.dm | 11 +++++++---- code/game/machinery/camera/camera_assembly.dm | 6 ++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/code/game/machinery/camera/camera.dm b/code/game/machinery/camera/camera.dm index f98c84c61ac..881305948d7 100644 --- a/code/game/machinery/camera/camera.dm +++ b/code/game/machinery/camera/camera.dm @@ -52,17 +52,20 @@ /obj/machinery/camera/Destroy() toggle_cam(null, 0) //kick anyone viewing out if(assembly) - qdel(assembly) - assembly = null + QDEL_NULL(assembly) if(istype(bug)) bug.bugged_cameras -= src.c_tag if(bug.current == src) bug.current = null bug = null - qdel(wires) - wires = null + if(wires) + QDEL_NULL(wires) cameranet.removeCamera(src) //Will handle removal from the camera network and the chunks, so we don't need to worry about that cameranet.cameras -= src + var/area/ai_monitored/A = get_area(src) + if(istype(A)) + A.motioncamera = null + area_motion = null return ..() /obj/machinery/camera/emp_act(severity) diff --git a/code/game/machinery/camera/camera_assembly.dm b/code/game/machinery/camera/camera_assembly.dm index 99e9273b682..11fcede1fe9 100644 --- a/code/game/machinery/camera/camera_assembly.dm +++ b/code/game/machinery/camera/camera_assembly.dm @@ -20,6 +20,12 @@ 4 = Screwdriver panel closed and is fully built (you cannot attach upgrades) */ +/obj/item/weapon/camera_assembly/Destroy() + for(var/thing in upgrades) + qdel(thing) + upgrades.Cut() + return ..() + /obj/item/weapon/camera_assembly/attackby(obj/item/W, mob/living/user, params) switch(state) From 9a203111529d26538e098f8bf3f9e73810dcd6d8 Mon Sep 17 00:00:00 2001 From: Fox-McCloud Date: Tue, 4 Apr 2017 00:35:42 -0400 Subject: [PATCH 3/4] better QDEL_NULL --- code/__HELPERS/qdel.dm | 2 +- code/game/machinery/camera/camera.dm | 6 ++---- code/game/machinery/cloning.dm | 3 +-- code/game/objects/effects/anomalies.dm | 3 +-- code/game/objects/items/weapons/dna_injector.dm | 3 +-- code/modules/recycling/disposal.dm | 3 +-- 6 files changed, 7 insertions(+), 13 deletions(-) diff --git a/code/__HELPERS/qdel.dm b/code/__HELPERS/qdel.dm index 14b1f9d9594..e8a11f27a66 100644 --- a/code/__HELPERS/qdel.dm +++ b/code/__HELPERS/qdel.dm @@ -1,2 +1,2 @@ #define QDEL_IN(item, time) addtimer(GLOBAL_PROC, "qdel", time, FALSE, item) -#define QDEL_NULL(item) qdel(item); item = null \ No newline at end of file +#define QDEL_NULL(item) if(item) { qdel(item); item = null } \ No newline at end of file diff --git a/code/game/machinery/camera/camera.dm b/code/game/machinery/camera/camera.dm index 881305948d7..ca312efc6a7 100644 --- a/code/game/machinery/camera/camera.dm +++ b/code/game/machinery/camera/camera.dm @@ -51,15 +51,13 @@ /obj/machinery/camera/Destroy() toggle_cam(null, 0) //kick anyone viewing out - if(assembly) - QDEL_NULL(assembly) + QDEL_NULL(assembly) if(istype(bug)) bug.bugged_cameras -= src.c_tag if(bug.current == src) bug.current = null bug = null - if(wires) - QDEL_NULL(wires) + QDEL_NULL(wires) cameranet.removeCamera(src) //Will handle removal from the camera network and the chunks, so we don't need to worry about that cameranet.cameras -= src var/area/ai_monitored/A = get_area(src) diff --git a/code/game/machinery/cloning.dm b/code/game/machinery/cloning.dm index c75ca58140e..7921defd40f 100644 --- a/code/game/machinery/cloning.dm +++ b/code/game/machinery/cloning.dm @@ -112,8 +112,7 @@ buf.dna=new /obj/item/weapon/disk/data/Destroy() - if(buf) - QDEL_NULL(buf) + QDEL_NULL(buf) return ..() /obj/item/weapon/disk/data/demo diff --git a/code/game/objects/effects/anomalies.dm b/code/game/objects/effects/anomalies.dm index e0a6e59da14..89baf450720 100644 --- a/code/game/objects/effects/anomalies.dm +++ b/code/game/objects/effects/anomalies.dm @@ -21,8 +21,7 @@ poi_list |= src /obj/effect/anomaly/Destroy() - if(aSignal) - QDEL_NULL(aSignal) + QDEL_NULL(aSignal) poi_list.Remove(src) return ..() diff --git a/code/game/objects/items/weapons/dna_injector.dm b/code/game/objects/items/weapons/dna_injector.dm index 86ed5f84974..c10872afad0 100644 --- a/code/game/objects/items/weapons/dna_injector.dm +++ b/code/game/objects/items/weapons/dna_injector.dm @@ -27,8 +27,7 @@ SetValue(value) /obj/item/weapon/dnainjector/Destroy() - if(buf) - QDEL_NULL(buf) + QDEL_NULL(buf) return ..() /obj/item/weapon/dnainjector/proc/GetRealBlock(var/selblock) diff --git a/code/modules/recycling/disposal.dm b/code/modules/recycling/disposal.dm index a3f038a507a..5d02d8a93f1 100644 --- a/code/modules/recycling/disposal.dm +++ b/code/modules/recycling/disposal.dm @@ -500,8 +500,7 @@ var/hasmob = 0 //If it contains a mob Destroy() - if(gas) - QDEL_NULL(gas) + QDEL_NULL(gas) active = 0 return ..() From 8fb17b2beea1c8b530fa5a56018a5d99532016bf Mon Sep 17 00:00:00 2001 From: Fox-McCloud Date: Tue, 4 Apr 2017 04:26:53 -0400 Subject: [PATCH 4/4] moarrr --- code/game/machinery/doors/brigdoors.dm | 6 +++++- code/game/objects/effects/decals/cleanable.dm | 3 +-- code/game/objects/items/devices/radio/headset.dm | 12 ++++-------- code/game/objects/items/devices/radio/radio.dm | 16 +++++++--------- .../research/xenobiology/xenobio_camera.dm | 10 +++++----- 5 files changed, 22 insertions(+), 25 deletions(-) diff --git a/code/game/machinery/doors/brigdoors.dm b/code/game/machinery/doors/brigdoors.dm index ecdd959f717..7ec9630a54c 100644 --- a/code/game/machinery/doors/brigdoors.dm +++ b/code/game/machinery/doors/brigdoors.dm @@ -63,6 +63,10 @@ stat |= BROKEN update_icon() +/obj/machinery/door_timer/Destroy() + QDEL_NULL(Radio) + targets.Cut() + return ..() //Main door timer loop, if it's timing and time is >0 reduce time by 1. // if it's less than 0, open door, reset timer @@ -186,7 +190,7 @@ if(..()) return interact(user) - + /obj/machinery/door_timer/interact(mob/user) // Used for the 'time left' display var/second = round(timeleft() % 60) diff --git a/code/game/objects/effects/decals/cleanable.dm b/code/game/objects/effects/decals/cleanable.dm index 48a85e7e704..cfde9ab55a4 100644 --- a/code/game/objects/effects/decals/cleanable.dm +++ b/code/game/objects/effects/decals/cleanable.dm @@ -1,9 +1,8 @@ /obj/effect/decal/cleanable var/list/random_icon_states = list() - var/targeted_by = null // Used so cleanbots can't claim a mess. var/noscoop = 0 //if it has this, don't let it be scooped up var/noclear = 0 //if it has this, don't delete it when its' scooped up - + /obj/effect/decal/cleanable/proc/can_bloodcrawl_in() return FALSE diff --git a/code/game/objects/items/devices/radio/headset.dm b/code/game/objects/items/devices/radio/headset.dm index 30e02824cd1..9fd1e40b4f7 100644 --- a/code/game/objects/items/devices/radio/headset.dm +++ b/code/game/objects/items/devices/radio/headset.dm @@ -32,12 +32,8 @@ recalculateChannels(1) /obj/item/device/radio/headset/Destroy() - if(keyslot1) - qdel(keyslot1) - if(keyslot2) - qdel(keyslot2) - keyslot1 = null - keyslot2 = null + QDEL_NULL(keyslot1) + QDEL_NULL(keyslot2) return ..() /obj/item/device/radio/headset/list_channels(var/mob/user) @@ -63,7 +59,7 @@ return RADIO_CONNECTION_FAIL return ..() - + /obj/item/device/radio/headset/is_listening() if(ishuman(loc)) var/mob/living/carbon/human/H = loc @@ -71,7 +67,7 @@ return ..() else if(isanimal(loc) || isAI(loc)) return ..() - + return FALSE /obj/item/device/radio/headset/alt diff --git a/code/game/objects/items/devices/radio/radio.dm b/code/game/objects/items/devices/radio/radio.dm index c4fedf48255..05bce7ad51c 100644 --- a/code/game/objects/items/devices/radio/radio.dm +++ b/code/game/objects/items/devices/radio/radio.dm @@ -30,7 +30,6 @@ var/global/list/default_medbay_channels = list( var/frequency = PUB_FREQ //common chat var/traitor_frequency = 0 //tune to frequency to unlock traitor supplies var/canhear_range = 3 // the range which mobs can hear this radio from - var/obj/item/device/radio/patch_link = null var/datum/wires/radio/wires = null var/b_stat = 0 var/broadcasting = 0 @@ -54,14 +53,14 @@ var/global/list/default_medbay_channels = list( var/list/internal_channels -/obj/item/device/radio var/datum/radio_frequency/radio_connection var/list/datum/radio_frequency/secure_radio_connections = new - proc/set_frequency(new_frequency) - radio_controller.remove_object(src, frequency) - frequency = new_frequency - radio_connection = radio_controller.add_object(src, frequency, RADIO_CHAT) + +/obj/item/device/radio/proc/set_frequency(new_frequency) + radio_controller.remove_object(src, frequency) + frequency = new_frequency + radio_connection = radio_controller.add_object(src, frequency, RADIO_CHAT) /obj/item/device/radio/New() @@ -74,14 +73,13 @@ var/global/list/default_medbay_channels = list( global_radios |= src /obj/item/device/radio/Destroy() - qdel(wires) - wires = null + QDEL_NULL(wires) if(radio_controller) radio_controller.remove_object(src, frequency) for(var/ch_name in channels) radio_controller.remove_object(src, radiochannels[ch_name]) - patch_link = null global_radios -= src + follow_target = null return ..() diff --git a/code/modules/research/xenobiology/xenobio_camera.dm b/code/modules/research/xenobiology/xenobio_camera.dm index 9e0e26a0252..40f20ea4dde 100644 --- a/code/modules/research/xenobiology/xenobio_camera.dm +++ b/code/modules/research/xenobiology/xenobio_camera.dm @@ -77,11 +77,11 @@ else if(istype(O, /obj/item/weapon/storage/bag)) var/obj/item/weapon/storage/P = O var/loaded = 0 - for(var/obj/G in P.contents) - if(istype(G, /obj/item/weapon/reagent_containers/food/snacks/monkeycube)) - loaded = 1 - monkeys++ - qdel(G) + for(var/obj/item/weapon/reagent_containers/food/snacks/monkeycube/MC in P.contents) + loaded = 1 + monkeys++ + P.remove_from_storage(MC) + qdel(MC) if(loaded) to_chat(user, "You fill [src] with the monkey cubes stored in [O]. [src] now has [monkeys] monkey cubes stored.") return