summaryrefslogtreecommitdiff
path: root/src/video/video_driver.hpp
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2021-02-28 15:41:03 +0100
committerCharles Pigott <charlespigott@googlemail.com>2021-02-28 18:04:51 +0000
commitc3dc27e37e177675c8a54ef507de48b61ed6da2c (patch)
treee42eb666cf8f22c17a0a4042bc62043ecda6c3b8 /src/video/video_driver.hpp
parent73fd634209a9d54dd167a579e4bb3cced177b896 (diff)
downloadopenttd-c3dc27e37e177675c8a54ef507de48b61ed6da2c.tar.xz
Add: settings to limit your fast-forward game speed
By default this setting is set to 2500% normal game speed.
Diffstat (limited to 'src/video/video_driver.hpp')
-rw-r--r--src/video/video_driver.hpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/video/video_driver.hpp b/src/video/video_driver.hpp
index 2e478def9..938dd84bf 100644
--- a/src/video/video_driver.hpp
+++ b/src/video/video_driver.hpp
@@ -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 */