diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index 1a5fac33..ea1dad1e 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -6742,3 +6742,33 @@ void Game::copyndmresults(void) ndmresulthardestroom = hardestroom; SDL_memcpy(ndmresultcrewstats, crewstats, sizeof(ndmresultcrewstats)); } + +static inline int get_framerate(const int slowdown) +{ + switch (slowdown) + { + case 30: + return 34; + case 24: + return 41; + case 18: + return 55; + case 12: + return 83; + } + + return 34; +} + +int Game::get_timestep(void) +{ + switch (gamestate) + { + case EDITORMODE: + return 24; + case GAMEMODE: + return get_framerate(slowdown); + default: + return 34; + } +} diff --git a/desktop_version/src/Game.h b/desktop_version/src/Game.h index f0cec0fd..f53351be 100644 --- a/desktop_version/src/Game.h +++ b/desktop_version/src/Game.h @@ -292,6 +292,7 @@ public: bool colourblindmode; bool noflashingmode; int slowdown; + int get_timestep(void); bool nodeathmode; int gameoverdelay; diff --git a/desktop_version/src/main.cpp b/desktop_version/src/main.cpp index 1d98eb9d..2ed8693a 100644 --- a/desktop_version/src/main.cpp +++ b/desktop_version/src/main.cpp @@ -57,23 +57,6 @@ static volatile Uint32 accumulator = 0; static volatile Uint32 f_time = 0; static volatile Uint32 f_timePrev = 0; -static inline Uint32 get_framerate(const int slowdown) -{ - switch (slowdown) - { - case 30: - return 34; - case 24: - return 41; - case 18: - return 55; - case 12: - return 83; - } - - return 34; -} - enum FuncType { Func_null, @@ -665,19 +648,7 @@ static void inline deltaloop(void) const float rawdeltatime = static_cast(time_ - timePrev); accumulator += rawdeltatime; - Uint32 timesteplimit; - if (game.gamestate == EDITORMODE) - { - timesteplimit = 24; - } - else if (game.gamestate == GAMEMODE) - { - timesteplimit = get_framerate(game.slowdown); - } - else - { - timesteplimit = 34; - } + Uint32 timesteplimit = game.get_timestep(); while (accumulator >= timesteplimit) {