diff --git a/code/__HELPERS/qdel.dm b/code/__HELPERS/qdel.dm index 0d2bf89152..af7e7b99f0 100644 --- a/code/__HELPERS/qdel.dm +++ b/code/__HELPERS/qdel.dm @@ -1,4 +1,8 @@ -#define QDEL_IN(item, time) addtimer(CALLBACK(GLOBAL_PROC, .proc/qdel, item), time, TIMER_STOPPABLE) +// This is a bit hacky, we do it to avoid people relying on a return value for the macro +// If you need that you should use QDEL_IN_STOPPABLE instead +#define QDEL_IN(item, time) ; \ + addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(qdel), (time) > GC_FILTER_QUEUE ? WEAKREF(item) : item), time); +#define QDEL_IN_STOPPABLE(item, time) addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(qdel), (time) > GC_FILTER_QUEUE ? WEAKREF(item) : item), time, TIMER_STOPPABLE) #define QDEL_IN_CLIENT_TIME(item, time) addtimer(CALLBACK(GLOBAL_PROC, .proc/qdel, item), time, TIMER_STOPPABLE | TIMER_CLIENT_TIME) #define QDEL_NULL(item) qdel(item); item = null #define QDEL_LIST(L) if(L) { for(var/I in L) qdel(I); L.Cut(); } diff --git a/code/datums/weakrefs.dm b/code/datums/weakrefs.dm index 31e0c3501b..c243f35f34 100644 --- a/code/datums/weakrefs.dm +++ b/code/datums/weakrefs.dm @@ -17,9 +17,10 @@ reference = REF(thing) /datum/weakref/Destroy(force) + var/datum/target = resolve() + qdel(target) if(!force) return QDEL_HINT_LETMELIVE //Let BYOND autoGC thiswhen nothing is using it anymore. - var/datum/target = resolve() target?.weak_reference = null return ..() diff --git a/code/game/gamemodes/meteor/meteors.dm b/code/game/gamemodes/meteor/meteors.dm index 446573e2af..8f97e232ae 100644 --- a/code/game/gamemodes/meteor/meteors.dm +++ b/code/game/gamemodes/meteor/meteors.dm @@ -131,7 +131,7 @@ GLOBAL_LIST_INIT(meteorsC, list(/obj/effect/meteor/dust)) //for space dust event GLOB.meteor_list += src SSaugury.register_doom(src, threat) SpinAnimation() - timerid = QDEL_IN(src, lifetime) + timerid = QDEL_IN_STOPPABLE(src, lifetime) chase_target(target) /obj/effect/meteor/Bump(atom/A) diff --git a/code/game/objects/effects/temporary_visuals/temporary_visual.dm b/code/game/objects/effects/temporary_visuals/temporary_visual.dm index bf4e82f7b7..29696f5ad7 100644 --- a/code/game/objects/effects/temporary_visuals/temporary_visual.dm +++ b/code/game/objects/effects/temporary_visuals/temporary_visual.dm @@ -13,7 +13,7 @@ if(randomdir) setDir(pick(GLOB.cardinals)) - timerid = QDEL_IN(src, duration) + timerid = QDEL_IN_STOPPABLE(src, duration) /obj/effect/temp_visual/Destroy() . = ..() diff --git a/code/modules/antagonists/clockcult/clock_effects/spatial_gateway.dm b/code/modules/antagonists/clockcult/clock_effects/spatial_gateway.dm index 79ad69b76f..e5d5de2f08 100644 --- a/code/modules/antagonists/clockcult/clock_effects/spatial_gateway.dm +++ b/code/modules/antagonists/clockcult/clock_effects/spatial_gateway.dm @@ -35,7 +35,7 @@ clockwork_desc = "A gateway in reality. It can only [sender ? "send" : "receive"] objects." if(is_stable) return - timerid = QDEL_IN(src, lifetime) //We only need this if the gateway is not stable + timerid = QDEL_IN_STOPPABLE(src, lifetime) //We only need this if the gateway is not stable //set up a gateway with another gateway /obj/effect/clockwork/spatial_gateway/proc/setup_gateway(obj/effect/clockwork/spatial_gateway/gatewayB, set_duration, set_uses, two_way) @@ -108,12 +108,12 @@ visible_message("[src] is disrupted!") animate(src, alpha = 0, transform = matrix()*2, time = 10, flags = ANIMATION_END_NOW) deltimer(timerid) - timerid = QDEL_IN(src, 10) + timerid = QDEL_IN_STOPPABLE(src, 10) linked_gateway.uses = 0 linked_gateway.visible_message("[linked_gateway] is disrupted!") animate(linked_gateway, alpha = 0, transform = matrix()*2, time = 10, flags = ANIMATION_END_NOW) deltimer(linked_gateway.timerid) - linked_gateway.timerid = QDEL_IN(linked_gateway, 10) + linked_gateway.timerid = QDEL_IN_STOPPABLE(linked_gateway, 10) return TRUE return FALSE @@ -279,8 +279,8 @@ /obj/effect/clockwork/spatial_gateway/stable/proc/start_shutdown() deltimer(timerid) deltimer(linked_gateway.timerid) - timerid = QDEL_IN(src, 20) - linked_gateway.timerid = QDEL_IN(linked_gateway, 20) + timerid = QDEL_IN_STOPPABLE(src, 20) + linked_gateway.timerid = QDEL_IN_STOPPABLE(linked_gateway, 20) animate(src, alpha = 0, transform = matrix()*2, time = 20, flags = ANIMATION_END_NOW) animate(linked_gateway, alpha = 0, transform = matrix()*2, time = 20, flags = ANIMATION_END_NOW) src.visible_message("[src] begins to destabilise!") diff --git a/code/modules/antagonists/clockcult/clock_structures/taunting_trail.dm b/code/modules/antagonists/clockcult/clock_structures/taunting_trail.dm index 5305758b25..853acdbe19 100644 --- a/code/modules/antagonists/clockcult/clock_structures/taunting_trail.dm +++ b/code/modules/antagonists/clockcult/clock_structures/taunting_trail.dm @@ -16,7 +16,7 @@ /obj/structure/destructible/clockwork/taunting_trail/Initialize(mapload) . = ..() - timerid = QDEL_IN(src, 15) + timerid = QDEL_IN_STOPPABLE(src, 15) var/obj/structure/destructible/clockwork/taunting_trail/Tt = locate(/obj/structure/destructible/clockwork/taunting_trail) in loc if(Tt && Tt != src) if(!step(src, pick(GLOB.alldirs))) diff --git a/code/modules/mob/living/simple_animal/hostile/mining_mobs/curse_blob.dm b/code/modules/mob/living/simple_animal/hostile/mining_mobs/curse_blob.dm index 04b003b315..06b10a34c2 100644 --- a/code/modules/mob/living/simple_animal/hostile/mining_mobs/curse_blob.dm +++ b/code/modules/mob/living/simple_animal/hostile/mining_mobs/curse_blob.dm @@ -30,7 +30,7 @@ /mob/living/simple_animal/hostile/asteroid/curseblob/Initialize(mapload) . = ..() - timerid = QDEL_IN(src, 600) + timerid = QDEL_IN_STOPPABLE(src, 600) playsound(src, 'sound/effects/curse1.ogg', 100, 1, -1) /mob/living/simple_animal/hostile/asteroid/curseblob/Destroy() diff --git a/code/modules/mob/living/simple_animal/hostile/mining_mobs/goliath.dm b/code/modules/mob/living/simple_animal/hostile/mining_mobs/goliath.dm index 115681a7d4..f33bd6a3b7 100644 --- a/code/modules/mob/living/simple_animal/hostile/mining_mobs/goliath.dm +++ b/code/modules/mob/living/simple_animal/hostile/mining_mobs/goliath.dm @@ -211,4 +211,4 @@ /obj/effect/temp_visual/goliath_tentacle/proc/retract() icon_state = "Goliath_tentacle_retract" deltimer(timerid) - timerid = QDEL_IN(src, 7) + timerid = QDEL_IN_STOPPABLE(src, 7)