Interpolate from time of previous tic

Previously interpolated from last 35th of a second, which
may be offset from game time due to connection lag.

Consider this the proper fix to 54148a0dd0 too.
This commit is contained in:
James R 2022-01-12 03:36:02 -08:00 committed by Eidolon
parent e6dff8eedc
commit 1b49a96eed
5 changed files with 30 additions and 13 deletions

View file

@ -5206,8 +5206,10 @@ static void SV_Maketic(void)
maketic++; maketic++;
} }
void TryRunTics(tic_t realtics) boolean TryRunTics(tic_t realtics)
{ {
boolean ticking;
// the machine has lagged but it is not so bad // the machine has lagged but it is not so bad
if (realtics > TICRATE/7) // FIXME: consistency failure!! if (realtics > TICRATE/7) // FIXME: consistency failure!!
{ {
@ -5251,10 +5253,14 @@ void TryRunTics(tic_t realtics)
} }
#endif #endif
if (player_joining) ticking = neededtic > gametic;
return;
if (neededtic > gametic) if (player_joining)
{
return false;
}
if (ticking)
{ {
if (advancedemo) if (advancedemo)
{ {
@ -5290,6 +5296,8 @@ void TryRunTics(tic_t realtics)
break; break;
} }
} }
return ticking;
} }
/* /*

View file

@ -430,7 +430,7 @@ boolean Playing(void);
void D_QuitNetGame(void); void D_QuitNetGame(void);
//? How many ticks to run? //? How many ticks to run?
void TryRunTics(tic_t realtic); boolean TryRunTics(tic_t realtic);
// extra data for lmps // extra data for lmps
// these functions scare me. they contain magic. // these functions scare me. they contain magic.

View file

@ -697,6 +697,7 @@ void D_SRB2Loop(void)
{ {
tic_t oldentertics = 0, entertic = 0, realtics = 0, rendertimeout = INFTICS; tic_t oldentertics = 0, entertic = 0, realtics = 0, rendertimeout = INFTICS;
static lumpnum_t gstartuplumpnum; static lumpnum_t gstartuplumpnum;
boolean ticked;
if (dedicated) if (dedicated)
server = true; server = true;
@ -783,11 +784,20 @@ void D_SRB2Loop(void)
realtics = 1; realtics = 1;
// process tics (but maybe not if realtic == 0) // process tics (but maybe not if realtic == 0)
TryRunTics(realtics); ticked = TryRunTics(realtics);
if (cv_frameinterpolation.value == 1) 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 is a bit awkard to evaluate, since the system time interface is whole tic-based
renderdeltatics = realtics * FRACUNIT; renderdeltatics = realtics * FRACUNIT;
if (entertimefrac > rendertimefrac) if (entertimefrac > rendertimefrac)

View file

@ -46,9 +46,9 @@ UINT32 I_GetFreeMem(UINT32 *total);
*/ */
tic_t I_GetTime(void); 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. /** \brief Returns precise time value for performance measurement.
*/ */

View file

@ -2160,11 +2160,10 @@ tic_t I_GetTime(void)
return (tic_t) floor(elapsed_tics); return (tic_t) floor(elapsed_tics);
} }
fixed_t I_GetTimeFrac(void) float I_GetTimeFrac(void)
{ {
UpdateElapsedTics(); UpdateElapsedTics();
return elapsed_tics;
return FLOAT_TO_FIXED((float) (elapsed_tics - floor(elapsed_tics)));
} }
precise_t I_GetPreciseTime(void) precise_t I_GetPreciseTime(void)