diff --git a/src/window.cpp b/src/window.cpp index f67cda90f8..aea7bf3418 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); diff --git a/src/window_gui.h b/src/window_gui.h index b03f5bbcad..c792a6b28c 100644 --- a/src/window_gui.h +++ b/src/window_gui.h @@ -691,7 +691,9 @@ public: virtual void OnGameTick() {} /** - * Called once every 100 (game) ticks. + * Called once every 100 (game) ticks, or once every 3s, whichever comes last. + * In normal game speed the frequency is 1 call every 100 ticks (can be more than 3s). + * In fast-forward the frequency is 1 call every ~3s (can be more than 100 ticks). */ virtual void OnHundredthTick() {}