Hello Tedium,
Tedium {l Wrote}:When you finish a level without restarting (first attempt after selecting that level), that will result in a better time than when you've restarted it.
Try it on tutorial level 1, "A walk in the park". Walk to the right once you've selected that level. Your record will be 0.98 s, but it'll be round 1.02 if you've restarted.
I think I've found the source of the bug, it's line 1079 of Player.cpp:
- {l Code}: {l Select All Code}
xVel=0; //??? fixed a strange bug in game replay
After some debugging I found out that after resetting the xVel of the player will be 0 (which is as expected).
But for some reason it stays 0 for about ~2-3 updates, meaning two frames of 1/40 will result in 0.05 extra time.
This could explain the difference in time, (0.975 = 39 ticks, 1.025 = 41 ticks)
Removing this line solves the problem, but that line fixes a bug where the player would start walking forward after restarting while the inter-level replay was busy.
It might have something to do with the input handling, not getting the right key in two/three update cycles.
I hope that it's related to the restart middle in the update loop problem and that it will be solved when that's solved:
http://forum.freegamedev.net/viewtopic.php?f=48&t=2804#p27599