[DiscordArchive] what is the reason for making Update return timePassed?
[DiscordArchive] what is the reason for making Update return timePassed?
Archived author: Northstrider • Posted: 2024-06-11T18:07:59.290000+00:00
Original source
so instead of timer = next_tick_timer we gotta do timer += next_tick_timer
Archived author: Tea • Posted: 2024-06-11T18:08:01.283000+00:00
Original source
(that is, dont while())
Archived author: Northstrider • Posted: 2024-06-11T18:08:10.852000+00:00
Original source
so timer.HasPassed() will be triggered in two ticks when checked
Archived author: Northstrider • Posted: 2024-06-11T18:09:24.067000+00:00
Original source
but then there is this include in object.h topic again. we need to forward that stuff. alternatively this would be a first great spot to build a util module that can be imported
Archived author: Tea • Posted: 2024-06-11T18:10:06.294000+00:00
Original source
anyway the proposed SimpleIntervalTimer "does the right thing" here
Archived author: Takenbacon • Posted: 2024-06-11T18:13:04.833000+00:00
Original source
and it's another reason why it's important to pass the actual diff time rather than interval
Archived author: Takenbacon • Posted: 2024-06-11T18:13:41.033000+00:00
Original source
i vaguely recall an issue with wintergrasp timers because of that, they will drift over time because of something similar
Archived author: Tea • Posted: 2024-06-11T18:21:57.074000+00:00
Original source
unfortunately your implementation is not good either (i would say its actually way worse)
Archived author: Takenbacon • Posted: 2024-06-11T18:24:03.548000+00:00
Original source
I probably made a mistake, I haven't got around to testing it lol
Archived author: Tea • Posted: 2024-06-11T18:25:12.315000+00:00
Original source
for simplicity lets say you have a timer ticking every 2 seconds and you are using it to feed another timer like weather update code
if you now get a lag spike where the diff is 5 seconds then this will happen after the spike
1st tick subtracts 2s off m_timer (3s remains) but returns 5s - you advance weather internal timer by 5s
2nd world tick happens at normal rate, removing 2s off m_timer again (1s remains) and returns 3s - you advance weather internal timer by 3s
you ended up advancing internal weather timer by 8s instead