Sophira / LiveSplit.RealTimeMinusBonuses

A LiveSplit Component that subtracts IGT time bonuses from an RTA run.
Other
2 stars 0 forks source link

Pause time calculation has (extremely minor) rounding errors #8

Open Sophira opened 7 years ago

Sophira commented 7 years ago

This is an extremely minor bug, but it's something that I want to fix at some point because I'm a bit of a perfectionist.

When calculating the amount of time to pause for, the component makes efforts to be as accurate as possible; it uses LiveSplit's timing mechanisms to pause the timer with accuracy down to the millisecond, and when the pause time expires, the component will adjust the Game Time to take into account the fact that LiveSplit's update refresh rate is not millisecond-accurate.

This allows us to pause accurately for times down to the millisecond. However, the component does not take into account rounding errors when calculating the number of milliseconds to pause for. This means that if the component needs to pause for, say, 500 frames at 60Hz (8.3333333... seconds), then it will only pause for 8333 milliseconds, discarding the remaining 0.00033333... seconds. In a run with 50 splits, and assuming that they all pause for this amount of time, the final recorded time will be out by exactly 1 frame (0.01666666... seconds).

This is obviously not something that most people will notice, and I don't plan on spending a large amount of time on this problem, but I do want to fix it at some point by allowing the component to remember how much time was discarded and, once the total 'discarded' time reaches a millisecond or more, adding that millisecond to the next pause time.