summaryrefslogtreecommitdiff
path: root/src/video/video_driver.hpp
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2021-02-20 11:54:33 +0100
committerPatric Stout <github@truebrain.nl>2021-02-20 17:08:44 +0100
commit0e76d965f1d90af6318586ab5f5b7c6a87989c02 (patch)
tree8b27947809768d7be2b74661f80f7d53d79fe9e3 /src/video/video_driver.hpp
parent7996fadb91b6ff9a8ca17791d03677ddb438fc07 (diff)
downloadopenttd-0e76d965f1d90af6318586ab5f5b7c6a87989c02.tar.xz
Codechange: deduplicate tick-handlers of all video drivers
They were all identical, so better put this in a single place hoping it is less likely to break.
Diffstat (limited to 'src/video/video_driver.hpp')
-rw-r--r--src/video/video_driver.hpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/video/video_driver.hpp b/src/video/video_driver.hpp
index 768b2fe6c..c52b36029 100644
--- a/src/video/video_driver.hpp
+++ b/src/video/video_driver.hpp
@@ -189,6 +189,17 @@ protected:
*/
virtual void CheckPaletteAnim() {}
+ /**
+ * Run the game for a single tick, processing boththe game-tick and draw-tick.
+ * @returns True if the driver should redraw the screen.
+ */
+ bool Tick();
+
+ /**
+ * Sleep till the next tick is about to happen.
+ */
+ void SleepTillNextTick();
+
std::chrono::steady_clock::duration GetGameInterval()
{
return std::chrono::milliseconds(MILLISECONDS_PER_TICK);
@@ -198,6 +209,10 @@ protected:
{
return std::chrono::microseconds(1000000 / _settings_client.gui.refresh_rate);
}
+
+ std::chrono::steady_clock::time_point last_realtime_tick;
+ std::chrono::steady_clock::time_point next_game_tick;
+ std::chrono::steady_clock::time_point next_draw_tick;
};
#endif /* VIDEO_VIDEO_DRIVER_HPP */