From b565e29cc67f055bf31d403158cb43c1b69f90a3 Mon Sep 17 00:00:00 2001 From: Luc <89928798+lewcc@users.noreply.github.com> Date: Thu, 4 Aug 2022 02:50:17 -0700 Subject: [PATCH] Fixes radiation hud (#18703) --- code/controllers/subsystem/radiation.dm | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/code/controllers/subsystem/radiation.dm b/code/controllers/subsystem/radiation.dm index da526e9d869..785aa22ef4e 100644 --- a/code/controllers/subsystem/radiation.dm +++ b/code/controllers/subsystem/radiation.dm @@ -8,6 +8,8 @@ PROCESSING_SUBSYSTEM_DEF(radiation) // turf_rad_cache is the state in the current loop, and may not be 100% representative // until processing is complete. // prev_rad_cache is the fully evaluated radiation state cache from the previous tick. + var/last_rad_cache_update = 0 + var/rad_cache_update_interval = 5 SECONDS var/list/turf_rad_cache = list() var/list/prev_rad_cache = list() @@ -25,7 +27,9 @@ PROCESSING_SUBSYSTEM_DEF(radiation) master.investigate_log(msg, "radiation") /datum/controller/subsystem/processing/radiation/fire(resumed) - refresh_rad_cache() + if(world.time > last_rad_cache_update + rad_cache_update_interval) + refresh_rad_cache() + last_rad_cache_update = world.time . = ..() /datum/controller/subsystem/processing/radiation/proc/get_turf_radiation(turf/place) @@ -37,12 +41,13 @@ PROCESSING_SUBSYSTEM_DEF(radiation) /datum/controller/subsystem/processing/radiation/proc/update_rad_cache(datum/component/radioactive/thing) var/atom/owner = thing.parent var/turf/place = get_turf(owner) - if (turf_rad_cache[place]) + if(turf_rad_cache[place]) turf_rad_cache[place] += thing.strength else turf_rad_cache[place] = thing.strength /datum/controller/subsystem/processing/radiation/proc/refresh_rad_cache() - prev_rad_cache = turf_rad_cache.Copy() + prev_rad_cache.Cut() + prev_rad_cache = turf_rad_cache turf_rad_cache = list()