diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 6bf1983e3..c40a80a20 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -5259,8 +5259,10 @@ static void SV_Maketic(void) maketic++; } -void TryRunTics(tic_t realtics) +boolean TryRunTics(tic_t realtics) { + boolean ticking; + // the machine has lagged but it is not so bad if (realtics > TICRATE/7) // FIXME: consistency failure!! { @@ -5304,7 +5306,9 @@ void TryRunTics(tic_t realtics) } #endif - if (neededtic > gametic) + ticking = neededtic > gametic; + + if (ticking) { if (realtics) hu_stopped = false; @@ -5314,10 +5318,10 @@ void TryRunTics(tic_t realtics) { if (realtics) hu_stopped = true; - return; + return false; } - if (neededtic > gametic) + if (ticking) { if (advancedemo) { @@ -5354,6 +5358,8 @@ void TryRunTics(tic_t realtics) if (realtics) hu_stopped = true; } + + return ticking; } diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 88712f01c..7cd8acce5 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -488,7 +488,7 @@ boolean Playing(void); void D_QuitNetGame(void); //? How many ticks to run? -void TryRunTics(tic_t realtic); +boolean TryRunTics(tic_t realtic); // extra data for lmps // these functions scare me. they contain magic. diff --git a/src/d_main.c b/src/d_main.c index 4776f4e77..a0cf64e58 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -687,6 +687,7 @@ tic_t rendergametic; void D_SRB2Loop(void) { tic_t oldentertics = 0, entertic = 0, realtics = 0, rendertimeout = INFTICS; + boolean ticked; if (dedicated) server = true; @@ -774,11 +775,20 @@ void D_SRB2Loop(void) realtics = 1; // process tics (but maybe not if realtic == 0) - TryRunTics(realtics); + ticked = TryRunTics(realtics); - if (cv_frameinterpolation.value == 1 && !(paused || P_AutoPause() || hu_stopped)) + if (cv_frameinterpolation.value == 1 && !(paused || P_AutoPause())) { - fixed_t entertimefrac = I_GetTimeFrac(); + static float tictime; + float entertime = I_GetTimeFrac(); + + fixed_t entertimefrac; + + if (ticked) + tictime = entertime; + + entertimefrac = FLOAT_TO_FIXED(entertime - tictime); + // renderdeltatics is a bit awkard to evaluate, since the system time interface is whole tic-based renderdeltatics = realtics * FRACUNIT; if (entertimefrac > rendertimefrac) diff --git a/src/i_system.h b/src/i_system.h index 789117eaa..4a8bf0c27 100644 --- a/src/i_system.h +++ b/src/i_system.h @@ -46,9 +46,9 @@ UINT32 I_GetFreeMem(UINT32 *total); */ tic_t I_GetTime(void); -/** \brief Get the current time as a fraction of a tic since the last tic. +/** \brief Get the current time in tics including fractions. */ -fixed_t I_GetTimeFrac(void); +float I_GetTimeFrac(void); /** \brief Returns precise time value for performance measurement. */ diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index bb2e4ea21..32d3980ff 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -1568,11 +1568,10 @@ tic_t I_GetTime(void) return (tic_t)f; } -fixed_t I_GetTimeFrac(void) +float I_GetTimeFrac(void) { UpdateElapsedTics(); - - return FLOAT_TO_FIXED((float) (elapsed_tics - floor(elapsed_tics))); + return elapsed_tics; } precise_t I_GetPreciseTime(void)