1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-22 01:29:43 +01:00

Use variable timestep for SDL_Delay

This fixes a bug where fast-forward wouldn't work in 30-FPS-only mode.

This is because the 30-FPS-only code has a hardcoded check for the
number 34, as in 34 milliseconds must pass before the next frame can
advance. This is why slowdown still worked, because slowdown means
you're waiting longer than 34 ms anyways, but fast-forward tries to wait
for only 1 ms, which wouldn't work if the 34 limit was still enforced.

So instead, swap out the 34 with game.get_timestep() and this will be
fixed.

Fixes #1185.
This commit is contained in:
Misa 2024-07-13 13:01:20 -07:00 committed by Misa Elizabeth Kai
parent 487e0c6b2d
commit 6930bde91b

View file

@ -866,9 +866,10 @@ int main(int argc, char *argv[])
f_time = SDL_GetTicks64();
const Uint64 f_timetaken = f_time - f_timePrev;
if (!game.over30mode && f_timetaken < 34)
const int timestep = game.get_timestep();
if (!game.over30mode && f_timetaken < (Uint64) timestep)
{
const volatile Uint64 f_delay = 34 - f_timetaken;
const volatile Uint64 f_delay = timestep - f_timetaken;
SDL_Delay((Uint32) f_delay);
f_time = SDL_GetTicks64();
}