Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OnHundredthTick() not called once per 100 ticks #7904

Open
floodious opened this issue Jan 5, 2020 · 0 comments
Open

OnHundredthTick() not called once per 100 ticks #7904

floodious opened this issue Jan 5, 2020 · 0 comments

Comments

@floodious
Copy link

@floodious floodious commented Jan 5, 2020

Versions

1.10.0-RC1

Expected result

OnHundredthTick() should be called once for every 100 ticks.

Actual result

OnHundredthTick() is called once every 3 seconds.

Steps to reproduce

Where a tick takes any time other than exactly 30 ms to process, the assumption PER_TICK == 30 is false. To simulate such a condition add sleep(1000 ms) inside GameLoop().

OpenTTD/src/window.cpp

Lines 3128 to 3132 in 5b52f25

void UpdateWindows()
{
static uint32 last_realtime_tick = _realtime_tick;
uint delta_ms = _realtime_tick - last_realtime_tick;
last_realtime_tick = _realtime_tick;

OpenTTD/src/window.cpp

Lines 3179 to 3186 in 5b52f25

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();
}
}

@floodious floodious changed the title Tick-based UpdateWindows() calls use incorrect real-time ms OnHundredthTick() not called once per 100 ticks Feb 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.