summaryrefslogtreecommitdiff
path: root/src/window.cpp
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2020-03-07 19:34:50 +0100
committerPatric Stout <github@truebrain.nl>2021-01-10 14:07:17 +0100
commitc0d7949d7c798285cc289bb9c76b4b155256456c (patch)
tree254d70ce418761c5b86f3844180c049a83daffa1 /src/window.cpp
parent97d554feb175179c7af70f7d61cf56886b3090bd (diff)
downloadopenttd-c0d7949d7c798285cc289bb9c76b4b155256456c.tar.xz
Fix: Don't use a timer for hundredth tick determination
Diffstat (limited to 'src/window.cpp')
-rw-r--r--src/window.cpp27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/window.cpp b/src/window.cpp
index f67cda90f..aea7bf341 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -1944,10 +1944,15 @@ void ResetWindowSystem()
static void DecreaseWindowCounters()
{
+ static byte hundredth_tick_timeout = 100;
+
if (_scroller_click_timeout != 0) _scroller_click_timeout--;
+ if (hundredth_tick_timeout != 0) hundredth_tick_timeout--;
Window *w;
FOR_ALL_WINDOWS_FROM_FRONT(w) {
+ if (!_network_dedicated && hundredth_tick_timeout == 0) w->OnHundredthTick();
+
if (_scroller_click_timeout == 0) {
/* Unclick scrollbar buttons if they are pressed. */
for (uint i = 0; i < w->nested_array_size; i++) {
@@ -1979,6 +1984,8 @@ static void DecreaseWindowCounters()
w->RaiseButtons(true);
}
}
+
+ if (hundredth_tick_timeout == 0) hundredth_tick_timeout = 100;
}
static void HandlePlacePresize()
@@ -3150,6 +3157,12 @@ void UpdateWindows()
Window *w;
+ /* Process invalidations before anything else. */
+ FOR_ALL_WINDOWS_FROM_FRONT(w) {
+ w->ProcessScheduledInvalidations();
+ w->ProcessHighlightedInvalidations();
+ }
+
static GUITimer window_timer = GUITimer(1);
if (window_timer.Elapsed(delta_ms)) {
if (_network_dedicated) window_timer.SetInterval(MILLISECONDS_PER_TICK);
@@ -3171,24 +3184,10 @@ void UpdateWindows()
if (!_pause_mode || _game_mode == GM_EDITOR || _settings_game.construction.command_pause_level > CMDPL_NO_CONSTRUCTION) MoveAllTextEffects(delta_ms);
- FOR_ALL_WINDOWS_FROM_FRONT(w) {
- w->ProcessScheduledInvalidations();
- w->ProcessHighlightedInvalidations();
- }
-
/* Skip the actual drawing on dedicated servers without screen.
* But still empty the invalidation queues above. */
if (_network_dedicated) return;
- static GUITimer hundredth_timer = GUITimer(1);
- if (hundredth_timer.Elapsed(delta_ms)) {
- hundredth_timer.SetInterval(3000); // Historical reason: 100 * MILLISECONDS_PER_TICK
-
- FOR_ALL_WINDOWS_FROM_FRONT(w) {
- w->OnHundredthTick();
- }
- }
-
if (window_timer.HasElapsed()) {
window_timer.SetInterval(MILLISECONDS_PER_TICK);