From b91c3adca5cd1e9ca98ee2b195c31be0af000a28 Mon Sep 17 00:00:00 2001 From: CHOMPStation2StaffMirrorBot <94713762+CHOMPStation2StaffMirrorBot@users.noreply.github.com> Date: Sun, 26 Jan 2025 17:23:17 -0700 Subject: [PATCH] [MIRROR] some destroy cleanup (#9953) Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com> --- code/game/objects/effects/chem/chemsmoke.dm | 30 ++++++++++--------- code/game/objects/effects/effect_system.dm | 21 ++++++++----- .../items/weapons/grenades/flashbang.dm | 2 +- .../items/weapons/material/chainsaw.dm | 2 -- .../projectiles/guns/magnetic/magnetic.dm | 2 +- code/modules/projectiles/projectile/blob.dm | 5 ---- code/modules/projectiles/projectile/energy.dm | 2 +- 7 files changed, 33 insertions(+), 31 deletions(-) diff --git a/code/game/objects/effects/chem/chemsmoke.dm b/code/game/objects/effects/chem/chemsmoke.dm index 50d227e41e..0c12b0d5f2 100644 --- a/code/game/objects/effects/chem/chemsmoke.dm +++ b/code/game/objects/effects/chem/chemsmoke.dm @@ -7,10 +7,9 @@ time_to_live = 300 pass_flags = PASSTABLE | PASSGRILLE | PASSGLASS //PASSGLASS is fine here, it's just so the visual effect can "flow" around glass -/obj/effect/effect/smoke/chem/New() - ..() +/obj/effect/effect/smoke/chem/Initialize() + . = ..() create_reagents(500) - return /obj/effect/effect/smoke/chem/Destroy() walk(src, 0) // Because we might have called walk_to, we must stop the walk loop or BYOND keeps an internal reference to us forever. @@ -47,6 +46,14 @@ chemholder = new/obj() chemholder.create_reagents(500) +/datum/effect/effect/system/smoke_spread/chem/Destroy() + QDEL_NULL(chemholder) + if(targetTurfs) + targetTurfs.Cut() + if(wallList) + wallList.Cut() + . = ..() + //Sets up the chem smoke effect // Calculates the max range smoke can travel, then gets all turfs in that view range. // Culls the selected turfs to a (roughly) circle shape, then calls smokeFlow() to make @@ -174,11 +181,8 @@ walk_to(smoke, T) if(initial(smoke.opacity)) smoke.set_opacity(1) //switching opacity on after the smoke has spawned, and then - spawn() - sleep(150+rand(0,20)) // turning it off before it is deleted results in cleaner - smoke.set_opacity(0) // lighting and view range updates - fadeOut(smoke) - qdel(smoke) + var/lifespan = 150 + rand(0, 20) + addtimer(CALLBACK(src, PROC_REF(fadeOut)), lifespan) /datum/effect/effect/system/smoke_spread/chem/spores/spawnSmoke(var/turf/T, var/icon/I, var/dist = 1) var/obj/effect/effect/smoke/chem/spores = new /obj/effect/effect/smoke/chem(location) @@ -186,16 +190,14 @@ ..(T, I, dist, spores) /datum/effect/effect/system/smoke_spread/chem/proc/fadeOut(var/atom/A, var/frames = 16) // Fades out the smoke smoothly using it's alpha variable. + A.set_opacity(0) // lighting and view range updates if(A.alpha == 0) //Handle already transparent case + qdel(A) return if(frames == 0) frames = 1 //We will just assume that by 0 frames, the coder meant "during one frame". - var/step = A.alpha / frames - for(var/i = 0, i < frames, i++) - A.alpha -= step - sleep(world.tick_lag) - return - + animate(A, alpha = 0, time = frames) + addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(qdel), A), frames, TIMER_UNIQUE) /datum/effect/effect/system/smoke_spread/chem/proc/smokeFlow() // Smoke pathfinder. Uses a flood fill method based on zones to quickly check what turfs the smoke (airflow) can actually reach. diff --git a/code/game/objects/effects/effect_system.dm b/code/game/objects/effects/effect_system.dm index f84329b507..094a9c464a 100644 --- a/code/game/objects/effects/effect_system.dm +++ b/code/game/objects/effects/effect_system.dm @@ -38,6 +38,7 @@ would spawn and follow the beaker, even if it is carried or thrown. /datum/effect/effect/system/proc/start() /datum/effect/effect/system/Destroy() + location = null holder = null return ..() @@ -178,12 +179,10 @@ steam.start() -- spawns the effect pixel_x = -32 pixel_y = -32 -/obj/effect/effect/smoke/New() - ..() +/obj/effect/effect/smoke/Initialize() + . = ..() if(time_to_live) - spawn (time_to_live) - if(!QDELETED(src)) - qdel(src) + addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(qdel), src), time_to_live, TIMER_DELETE_ME) /obj/effect/effect/smoke/Crossed(mob/living/carbon/M as mob ) if(M.is_incorporeal()) @@ -215,9 +214,9 @@ steam.start() -- spawns the effect icon = 'icons/effects/effects.dmi' icon_state = "sparks" -/obj/effect/effect/smoke/illumination/New(var/newloc, var/lifetime=10, var/range=null, var/power=null, var/color=null) +/obj/effect/effect/smoke/illumination/Initialize(mapload, var/lifetime=10, var/range=null, var/power=null, var/color=null) time_to_live=lifetime - ..() + . = ..() set_light(range, power, color) ///////////////////////////////////////////// @@ -433,6 +432,10 @@ steam.start() -- spawns the effect var/processing = 1 var/on = 1 +/datum/effect/effect/system/ion_trail_follow/Destroy() + oldposition = null + . = ..() + /datum/effect/effect/system/ion_trail_follow/set_up(atom/atom) attach(atom) oldposition = get_turf(atom) @@ -489,6 +492,10 @@ steam.start() -- spawns the effect var/processing = 1 var/on = 1 +/datum/effect/effect/system/steam_trail_follow/Destroy() + oldposition = null + . = ..() + /datum/effect/effect/system/steam_trail_follow/set_up(atom/atom) attach(atom) oldposition = get_turf(atom) diff --git a/code/game/objects/items/weapons/grenades/flashbang.dm b/code/game/objects/items/weapons/grenades/flashbang.dm index e42acff982..f7f2a37963 100644 --- a/code/game/objects/items/weapons/grenades/flashbang.dm +++ b/code/game/objects/items/weapons/grenades/flashbang.dm @@ -23,7 +23,7 @@ B.adjust_integrity(-damage) new/obj/effect/effect/sparks(src.loc) - new/obj/effect/effect/smoke/illumination(src.loc, 5, range=30, power=30, color="#FFFFFF") + new/obj/effect/effect/smoke/illumination(loc, 5, 30, 30, "#FFFFFF") qdel(src) diff --git a/code/game/objects/items/weapons/material/chainsaw.dm b/code/game/objects/items/weapons/material/chainsaw.dm index f595a757fd..c00b526151 100644 --- a/code/game/objects/items/weapons/material/chainsaw.dm +++ b/code/game/objects/items/weapons/material/chainsaw.dm @@ -22,8 +22,6 @@ /obj/item/chainsaw/Destroy() STOP_PROCESSING(SSobj, src) - if(reagents) - qdel(reagents) ..() /obj/item/chainsaw/proc/turnOn(mob/user as mob) diff --git a/code/modules/projectiles/guns/magnetic/magnetic.dm b/code/modules/projectiles/guns/magnetic/magnetic.dm index 54a8d6a162..abc39aa301 100644 --- a/code/modules/projectiles/guns/magnetic/magnetic.dm +++ b/code/modules/projectiles/guns/magnetic/magnetic.dm @@ -310,7 +310,7 @@ for(var/mob/living/carbon/M in hear(max_range, get_turf(src))) blitzed(get_turf(src), M, max_range, banglet) new/obj/effect/effect/sparks(src.loc) - new/obj/effect/effect/smoke/illumination(src.loc, 5, range=30, power=30, color="#FFFFFF") + new/obj/effect/effect/smoke/illumination(loc, 5, 30, 30, "#FFFFFF") spawn(2) qdel(src) if("blitzu") diff --git a/code/modules/projectiles/projectile/blob.dm b/code/modules/projectiles/projectile/blob.dm index 42e3e5158b..5d93d47fa3 100644 --- a/code/modules/projectiles/projectile/blob.dm +++ b/code/modules/projectiles/projectile/blob.dm @@ -20,11 +20,6 @@ ready_chemicals() ..() -/obj/item/projectile/energy/blob/Destroy() - qdel(reagents) - reagents = null - ..() - /obj/item/projectile/energy/blob/on_impact(var/atom/A) if(splatter) var/turf/location = get_turf(src) diff --git a/code/modules/projectiles/projectile/energy.dm b/code/modules/projectiles/projectile/energy.dm index 31a335a857..7a2801a707 100644 --- a/code/modules/projectiles/projectile/energy.dm +++ b/code/modules/projectiles/projectile/energy.dm @@ -70,7 +70,7 @@ ..() //initial flash //residual illumination - new /obj/effect/effect/smoke/illumination(src.loc, rand(190,240) SECONDS, range=8, power=3, color=light_colour) //same lighting power as flare + new /obj/effect/effect/smoke/illumination(loc, rand(190,240) SECONDS, 8, 3, light_colour) //same lighting power as flare /obj/item/projectile/energy/electrode name = "electrode"