From 3c14573cc1f3bb4fc4ea73291aab5a3f5ba6a83d Mon Sep 17 00:00:00 2001 From: Crazylemon Date: Mon, 21 Dec 2015 09:53:00 -0800 Subject: [PATCH 1/2] Replaces the spawn() with a time check --- code/modules/organs/organ.dm | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/code/modules/organs/organ.dm b/code/modules/organs/organ.dm index 36fa04a0c5d..a216df1fc88 100644 --- a/code/modules/organs/organ.dm +++ b/code/modules/organs/organ.dm @@ -23,7 +23,10 @@ var/list/organ_cache = list() germ_level = 0 var/datum/dna/dna var/datum/species/species - var/needs_preservation_update = 1 + + // Stuff for tracking if this is on a tile with an open freezer or not + var/last_freezer_update_time = 0 + var/freezer_update_period = 100 var/is_in_freezer = 0 /obj/item/organ/Destroy() @@ -153,7 +156,7 @@ var/list/organ_cache = list() if(is_found_within(/obj/structure/closet/crate/freezer)) return 1 if(istype(loc,/turf)) - if(needs_preservation_update) + if(time - last_freezer_update_time > freezer_update_period) // I don't want to loop through everything in the tile constantly, especially since it'll be a pile of organs // if the virologist releases gibbingtons again or something // There's probably a much less silly way of doing this, but BYOND native algorithms are stupidly naive @@ -162,9 +165,7 @@ var/list/organ_cache = list() if(F.opened) is_in_freezer = 1 // on the same tile, close enough, should keep organs much fresher on avg break - needs_preservation_update = 0 - spawn(100) // (100 / 10) once every 10 seconds - needs_preservation_update = 1 + last_freezer_update_time = time return is_in_freezer // I'd like static varibles, please // You can do your cool location temperature organ preserving effects here! From 667208afc73873f4953e292b59411a55d4aca2c2 Mon Sep 17 00:00:00 2001 From: Crazy Lemon Date: Mon, 21 Dec 2015 11:44:22 -0800 Subject: [PATCH 2/2] World.time is a thing, plain old time isn't --- code/modules/organs/organ.dm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/modules/organs/organ.dm b/code/modules/organs/organ.dm index a216df1fc88..82f35730bf8 100644 --- a/code/modules/organs/organ.dm +++ b/code/modules/organs/organ.dm @@ -156,7 +156,7 @@ var/list/organ_cache = list() if(is_found_within(/obj/structure/closet/crate/freezer)) return 1 if(istype(loc,/turf)) - if(time - last_freezer_update_time > freezer_update_period) + if(world.time - last_freezer_update_time > freezer_update_period) // I don't want to loop through everything in the tile constantly, especially since it'll be a pile of organs // if the virologist releases gibbingtons again or something // There's probably a much less silly way of doing this, but BYOND native algorithms are stupidly naive @@ -165,7 +165,7 @@ var/list/organ_cache = list() if(F.opened) is_in_freezer = 1 // on the same tile, close enough, should keep organs much fresher on avg break - last_freezer_update_time = time + last_freezer_update_time = world.time return is_in_freezer // I'd like static varibles, please // You can do your cool location temperature organ preserving effects here! @@ -373,4 +373,4 @@ I use this so that this can be made better once the organ overhaul rolls out -- O = owner if (!istype(owner)) // You're not the primary organ of ANYTHING, bucko return 0 - return src == O.internal_organs_by_name[organ_tag] \ No newline at end of file + return src == O.internal_organs_by_name[organ_tag]