Originally Posted By: Wims
It's more related to the fact that $ticks and $ctime are not related. You can calculate time passing with $ticks to an accuracy of $ticks's accuracy, and that would work fine. Here you are doing just that but you stick the result to $ctime without 'sync'.

$ticks are not actually "timer ticks" - timer ticks are (on my system) every 15-16ms. $ticks is a ms timer which is updated by 15 or 16ms every time a timer tick occurs.

When you get $ctime clicking over, then the $tick value could be anywhere from 0 to 16ms old. So if you add (say) 8 to the tick value, then that will be more likely to be accurate. But more importantly, this also ensures you don't get $ctimems like:
  • 45678.985
  • 45678.000
  • 45679.016
but instead:
  • 45678.977
  • 45678.992
  • 45679.008
You can then save ($tick + 8) % 1000 as an offset and do $ctime + ((($tick - offset) % 1000) / 1000) to get the $ctimems.

Last edited by Protopia; 02/09/17 08:56 PM.