Random item spawners qdel properly on init without using sleep (#7134)

This commit is contained in:
Atermonera
2020-05-15 13:34:31 -07:00
committed by VirgoBot
parent 51c38f8555
commit c8e5abc937

View File

@@ -11,15 +11,7 @@
. = ..() . = ..()
if (!prob(spawn_nothing_percentage)) if (!prob(spawn_nothing_percentage))
spawn_item() spawn_item()
Random_SafeDestroy(0) return INITIALIZE_HINT_QDEL
// This function should, theoretically, guarantee the deletion of the random object. Not all of them destroy themselves for some reason, especially if created through non-standard means.
/obj/random/proc/Random_SafeDestroy(var/recursion_level)
set waitfor = FALSE
sleep(30)
qdel(src)
if(src && recursion_level < 5)
Random_SafeDestroy(recursion_level + 1)
// this function should return a specific item to spawn // this function should return a specific item to spawn
/obj/random/proc/item_to_spawn() /obj/random/proc/item_to_spawn()