From 01d816fa2e794b16525be6ebb6e1d55d369033c9 Mon Sep 17 00:00:00 2001 From: MrStonedOne Date: Tue, 22 May 2018 20:27:39 -0700 Subject: [PATCH] Fixes some edge cases in sstimer that could cause a timer to run before it was expecting to. Because sstimer tracks timers internally in the terms of what "byond tick" they are suppose to run at; float wait values are now rounded *up* to the next Byond Tick rather then have byond round the resulting list index *down* at access time. 0 wait timers are now rounded *up* to `world.tick_lag` to avoid incompabilities with editing the current tick's bucket while it was being processed. --- code/controllers/subsystem/timer.dm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/controllers/subsystem/timer.dm b/code/controllers/subsystem/timer.dm index fbe681d0d44..52b118d5dc0 100644 --- a/code/controllers/subsystem/timer.dm +++ b/code/controllers/subsystem/timer.dm @@ -452,13 +452,13 @@ SUBSYSTEM_DEF(timer) CRASH("addtimer called without a callback") if (wait < 0) - stack_trace("addtimer called with a negative wait. Converting to 0") + stack_trace("addtimer called with a negative wait. Converting to [world.tick_lag]") //alot of things add short timers on themselves in their destroy, we ignore those cases if (wait >= 1 && callback && callback.object && callback.object != GLOBAL_PROC && QDELETED(callback.object)) stack_trace("addtimer called with a callback assigned to a qdeleted object") - wait = max(wait, 0) + wait = max(CEILING(wait, world.tick_lag), world.tick_lag) if(wait >= INFINITY) CRASH("Attempted to create timer with INFINITY delay")