From 068eb074731af86bdff3bd0e4329441c4c548b84 Mon Sep 17 00:00:00 2001 From: Kyle Spier-Swenson Date: Thu, 2 Feb 2017 13:28:14 -0800 Subject: [PATCH] Fixes freon/ice causing lag (#23493) * Fixes freon causing lag Yes, these were stacking. so a turf would have a bunch of "handle wet" timers running on it, every 1.5 seconds, all checking the same shit. * Fixes unique timers --- code/controllers/subsystem/timer.dm | 15 ++++++++++----- code/game/turfs/open.dm | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/code/controllers/subsystem/timer.dm b/code/controllers/subsystem/timer.dm index 23ce1bf95ab..425a63f1371 100644 --- a/code/controllers/subsystem/timer.dm +++ b/code/controllers/subsystem/timer.dm @@ -307,12 +307,17 @@ proc/addtimer(datum/callback/callback, wait, flags) var/datum/timedevent/hash_timer = SStimer.hashes[hash] if(hash_timer) - if (flags & TIMER_OVERRIDE) - qdel(hash_timer) + if (hash_timer.spent) //it's pending deletion, pretend it doesn't exist. + hash_timer.hash = null + SStimer.hashes -= hash else - if (hash_timer.flags & TIMER_STOPPABLE) - . = hash_timer.id - return + + if (flags & TIMER_OVERRIDE) + qdel(hash_timer) + else + if (hash_timer.flags & TIMER_STOPPABLE) + . = hash_timer.id + return var/timeToRun = world.time + wait diff --git a/code/game/turfs/open.dm b/code/game/turfs/open.dm index 68186429059..df3b680b914 100644 --- a/code/game/turfs/open.dm +++ b/code/game/turfs/open.dm @@ -258,4 +258,4 @@ if(!wet && wet_time) wet_time = 0 if(wet) - addtimer(CALLBACK(src, .proc/HandleWet), 15) + addtimer(CALLBACK(src, .proc/HandleWet), 15, TIMER_UNIQUE)