Use com_ticNumber for the async timer

This yields much more precise updates and stable fps.

Reported by kaan.
This commit is contained in:
dhewg 2011-12-27 21:03:47 +01:00
parent fad995722c
commit 239b165798

View file

@ -2783,16 +2783,13 @@ void idCommonLocal::SetMachineSpec( void ) {
com_videoRam.SetInteger( vidRam );
}
static unsigned int async_tick;
static unsigned int AsyncTimer(unsigned int interval, void *) {
common->Async();
Sys_TriggerEvent(TRIGGER_EVENT_ONE);
async_tick++;
// calculate the next interval to get as close to 60fps as possible
unsigned int now = SDL_GetTicks();
unsigned int tick = async_tick * 1000 / 60;
unsigned int tick = com_ticNumber * USERCMD_MSEC;
if (now >= tick)
return 1;
@ -2905,8 +2902,7 @@ void idCommonLocal::Init( int argc, char **argv ) {
Sys_Error( "Error during initialization" );
}
async_tick = (SDL_GetTicks() >> 4) + 1;
async_timer = SDL_AddTimer(16, AsyncTimer, NULL);
async_timer = SDL_AddTimer(USERCMD_MSEC, AsyncTimer, NULL);
if (!async_timer)
Sys_Error("Error while starting the async timer");