[airstrike] bug in timing code
eero.tamminen at netsonic.fi
Wed Aug 31 16:10:38 EDT 2005
On Wednesday 31 August 2005 12:09, Erik Auerswald wrote:
> Using the name FRAMERATE for the time of one frame is a litte bit
> confusing, I suggest using the name FRAMETIME.
Framerate = frames per second, so the define name is correct.
> there is a bug in engine/schedule.c, function rate_limit(): The
> transformation from delay in units of 10ms to gameframes is not correct.
> The same wrong formula is used in engine/sprite.c, function
> sprite_alarm(). The correct formula is delay*10/time_for_one_frame.
/* convert milliseconds to frames */
- *timer = now + delay * FRAMERATE / 10;
+ *timer = now + (delay * 10) / FRAMETIME;
The original code is also here correct.
- timer = now + number of frames to achieve the delay
- delay = x * 1/10 secs
I.e. delay/10 gives you the seconds and multiplying that with FPS
gives you the number of frames in that number of seconds.
(Division is at the end in the code just because we're dealing with
The term 'milliseconds' in all the comments should be changed to 1/10 secs
> The attached patch corrects these errors and renames FRAMERATE to
FRAMETIME would indicate time that it takes to do one frame, i.e. 1/30,
but I'd rather use integers.
> I did not apply it to svn because all timing values in the
> code are tailored to this incorrect behaviour, therefore the delay
> values need to be multiplied by 9 to keep the current timing. I did not
> (yet) search for all the places where delays are specified...
There would have been a lot of them... Happily they don't need to be
More information about the airstrike