mirror of https://github.com/OpenTTD/OpenTTD
Fix: Don't use a timer for hundredth tick determination
parent
97d554feb1
commit
c0d7949d7c
|
@ -1944,10 +1944,15 @@ void ResetWindowSystem()
|
||||||
|
|
||||||
static void DecreaseWindowCounters()
|
static void DecreaseWindowCounters()
|
||||||
{
|
{
|
||||||
|
static byte hundredth_tick_timeout = 100;
|
||||||
|
|
||||||
if (_scroller_click_timeout != 0) _scroller_click_timeout--;
|
if (_scroller_click_timeout != 0) _scroller_click_timeout--;
|
||||||
|
if (hundredth_tick_timeout != 0) hundredth_tick_timeout--;
|
||||||
|
|
||||||
Window *w;
|
Window *w;
|
||||||
FOR_ALL_WINDOWS_FROM_FRONT(w) {
|
FOR_ALL_WINDOWS_FROM_FRONT(w) {
|
||||||
|
if (!_network_dedicated && hundredth_tick_timeout == 0) w->OnHundredthTick();
|
||||||
|
|
||||||
if (_scroller_click_timeout == 0) {
|
if (_scroller_click_timeout == 0) {
|
||||||
/* Unclick scrollbar buttons if they are pressed. */
|
/* Unclick scrollbar buttons if they are pressed. */
|
||||||
for (uint i = 0; i < w->nested_array_size; i++) {
|
for (uint i = 0; i < w->nested_array_size; i++) {
|
||||||
|
@ -1979,6 +1984,8 @@ static void DecreaseWindowCounters()
|
||||||
w->RaiseButtons(true);
|
w->RaiseButtons(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hundredth_tick_timeout == 0) hundredth_tick_timeout = 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void HandlePlacePresize()
|
static void HandlePlacePresize()
|
||||||
|
@ -3150,6 +3157,12 @@ void UpdateWindows()
|
||||||
|
|
||||||
Window *w;
|
Window *w;
|
||||||
|
|
||||||
|
/* Process invalidations before anything else. */
|
||||||
|
FOR_ALL_WINDOWS_FROM_FRONT(w) {
|
||||||
|
w->ProcessScheduledInvalidations();
|
||||||
|
w->ProcessHighlightedInvalidations();
|
||||||
|
}
|
||||||
|
|
||||||
static GUITimer window_timer = GUITimer(1);
|
static GUITimer window_timer = GUITimer(1);
|
||||||
if (window_timer.Elapsed(delta_ms)) {
|
if (window_timer.Elapsed(delta_ms)) {
|
||||||
if (_network_dedicated) window_timer.SetInterval(MILLISECONDS_PER_TICK);
|
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);
|
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.
|
/* Skip the actual drawing on dedicated servers without screen.
|
||||||
* But still empty the invalidation queues above. */
|
* But still empty the invalidation queues above. */
|
||||||
if (_network_dedicated) return;
|
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()) {
|
if (window_timer.HasElapsed()) {
|
||||||
window_timer.SetInterval(MILLISECONDS_PER_TICK);
|
window_timer.SetInterval(MILLISECONDS_PER_TICK);
|
||||||
|
|
||||||
|
|
|
@ -691,7 +691,9 @@ public:
|
||||||
virtual void OnGameTick() {}
|
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() {}
|
virtual void OnHundredthTick() {}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue