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

Closed
floodious opened this issue Jan 5, 2020 · 1 comment
Closed

OnHundredthTick() not called once per 100 ticks #7904

floodious opened this issue Jan 5, 2020 · 1 comment

Comments

@floodious
Copy link

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
glx22 added a commit to glx22/OpenTTD that referenced this issue Mar 7, 2020
@TrueBrain
Copy link
Member

Although one can say that #6780 should have renamed the function when the implementation got changed, by no means this is a bug. It might be confusing to the reader, and as such we would accept a PR to rename this function into a proper name (and in fact, we would welcome that!).

However, to be clear, we are not going to change the implementation to comply with the name :D That would be silly ;)

Anyway, as this is not a bug, I am going to close this issue. If you feel up for it, please do make a PR. Otherwise, one of the devs will come around doing that sooner or later :)

Tnx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants