- Slight cleanup to I_GetInputFrac().

This commit is contained in:
Mitchell Richters 2022-05-30 20:46:01 +10:00
parent 7282e0d8bf
commit 3d8bc3294f

View file

@ -202,30 +202,22 @@ double I_GetInputFrac(bool const synchronised, double const ticrate)
{
if (!synchronised)
{
const double max = 1000. / ticrate;
const double now = I_msTimeF();
const double elapsedInputTicks = std::min(now - lastinputtime, max);
const double result = (now - lastinputtime) * ticrate * (1. / 1000.);
lastinputtime = now;
if (elapsedInputTicks < max)
if (result < 1)
{
// Calculate an amplification to apply to the result before returning,
// factoring in the game's ticrate and the value of the result.
// This rectifies a deviation of 100+ ms or more depending on the length
// of the operation to be within 1-2 ms of synchronised input
// from 60 fps to at least 1000 fps at ticrates of 30 and 40 Hz.
const double result = elapsedInputTicks * ticrate * (1. / 1000.);
return result * (1. + 0.35 * (1. - ticrate * (1. / 50.)) * (1. - result));
}
else
{
return 1;
}
}
else
{
return 1;
}
return 1;
}
void I_ResetInputTime()