mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-10 17:52:36 +00:00
[MIRROR] Fix client timers having invalid <1ds waits [MDB IGNORE] (#15982)
* Fix client timers having invalid <1ds waits (#69356) About The Pull Request Timers clamped their waits to >world.tick_lag and rounded it to multiples of the same, but this is invalid for clienttime timers. Clienttime timers have a resolution of one decisecond instead, so we now clamp and round it to that instead. (The stacktrace for negative waits is technically invalid but I didn't care enough to touch it.) Thanks to LemonInTheDark and MrStonedOne for their help in tracking this issue down. Why It's Good For The Game These are effectively zero-wait timers, which can mess up the iteration of the clienttime timer queue by being inserted into the past or current tick's list and causing the head/index to desync, potentially leaving spent timers in the queue or firing them again. * Fix client timers having invalid <1ds waits Co-authored-by: Penelope Haze <110272328+out-of-phaze@users.noreply.github.com>
This commit is contained in:
@@ -577,7 +577,10 @@ SUBSYSTEM_DEF(timer)
|
||||
stack_trace("addtimer called with a callback assigned to a qdeleted object. In the future such timers will not \
|
||||
be supported and may refuse to run or run with a 0 wait")
|
||||
|
||||
wait = max(CEILING(wait, world.tick_lag), world.tick_lag)
|
||||
if (flags & TIMER_CLIENT_TIME) // REALTIMEOFDAY has a resolution of 1 decisecond
|
||||
wait = max(CEILING(wait, 1), 1) // so if we use tick_lag timers may be inserted in the "past"
|
||||
else
|
||||
wait = max(CEILING(wait, world.tick_lag), world.tick_lag)
|
||||
|
||||
if(wait >= INFINITY)
|
||||
CRASH("Attempted to create timer with INFINITY delay")
|
||||
|
||||
Reference in New Issue
Block a user