Add: settings to limit your fast-forward game speed

By default this setting is set to 2500% normal game speed.
This commit is contained in:
Patric Stout
2021-02-28 15:41:03 +01:00
committed by Charles Pigott
parent 73fd634209
commit c3dc27e37e
17 changed files with 84 additions and 69 deletions

View File

@@ -13,6 +13,7 @@
#include "../driver.h"
#include "../core/geometry_type.hpp"
#include "../core/math_func.hpp"
#include "../gfx_func.h"
#include "../settings_type.h"
#include "../zoom_type.h"
#include <chrono>
@@ -268,7 +269,12 @@ protected:
std::chrono::steady_clock::duration GetGameInterval()
{
return std::chrono::milliseconds(MILLISECONDS_PER_TICK);
/* If we are paused, run on normal speed. */
if (_pause_mode) return std::chrono::milliseconds(MILLISECONDS_PER_TICK);
/* Infinite speed, as quickly as you can. */
if (_game_speed == 0) return std::chrono::microseconds(0);
return std::chrono::microseconds(MILLISECONDS_PER_TICK * 1000 * 100 / _game_speed);
}
std::chrono::steady_clock::duration GetDrawInterval()
@@ -278,6 +284,9 @@ protected:
std::chrono::steady_clock::time_point next_game_tick;
std::chrono::steady_clock::time_point next_draw_tick;
bool fast_forward_key_pressed; ///< The fast-forward key is being pressed.
bool fast_forward_via_key; ///< The fast-forward was enabled by key press.
};
#endif /* VIDEO_VIDEO_DRIVER_HPP */