Skip to content

Commit

Permalink
- Slight cleanup to I_GetInputFrac().
Browse files Browse the repository at this point in the history
  • Loading branch information
mjr4077au committed May 30, 2022
1 parent 7282e0d commit 3d8bc32
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions source/common/utility/i_time.cpp
Expand Up @@ -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()
Expand Down

0 comments on commit 3d8bc32

Please sign in to comment.