summaryrefslogtreecommitdiff
path: root/src/window.cpp
diff options
context:
space:
mode:
authorPeter Nelson <peter1138@openttd.org>2018-05-04 21:29:22 +0100
committerPeterN <peter@fuzzle.org>2019-01-11 11:56:21 +0000
commit2a8fa5fef9021bff67a13899832bf6f0a18e6ea1 (patch)
treec712f1973d6c74938e968f752a069b499dde7266 /src/window.cpp
parent916e911806083a2fe06a79f6f10e275015079149 (diff)
downloadopenttd-2a8fa5fef9021bff67a13899832bf6f0a18e6ea1.tar.xz
Change: Split up Window::OnTick into OnGameTick and OnRealtimeTick. Adjust timers to work with milliseconds instead of ticks.
Diffstat (limited to 'src/window.cpp')
-rw-r--r--src/window.cpp25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/window.cpp b/src/window.cpp
index 22084c200..7457bdcbf 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -3075,13 +3075,32 @@ void InputLoop()
}
/**
+ * Dispatch OnRealtimeTick event over all windows
+ */
+void CallWindowRealtimeTickEvent(uint delta_ms)
+{
+ Window *w;
+ FOR_ALL_WINDOWS_FROM_FRONT(w) {
+ w->OnRealtimeTick(delta_ms);
+ }
+}
+
+/**
* Update the continuously changing contents of the windows, such as the viewports
*/
void UpdateWindows()
{
+ static uint32 last_realtime_tick = _realtime_tick;
+ uint delta_ms = _realtime_tick - last_realtime_tick;
+ last_realtime_tick = _realtime_tick;
+
+ if (delta_ms == 0) return;
+
PerformanceMeasurer framerate(PFE_DRAWING);
PerformanceAccumulator::Reset(PFE_DRAWWORLD);
+ CallWindowRealtimeTickEvent(delta_ms);
+
Window *w;
static int highlight_timer = 1;
@@ -3263,13 +3282,13 @@ void InvalidateWindowClassesData(WindowClass cls, int data, bool gui_scope)
}
/**
- * Dispatch WE_TICK event over all windows
+ * Dispatch OnTick event over all windows
*/
-void CallWindowTickEvent()
+void CallWindowGameTickEvent()
{
Window *w;
FOR_ALL_WINDOWS_FROM_FRONT(w) {
- w->OnTick();
+ w->OnGameTick();
}
}