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

Incorrect town growth rate ticks to days conversion #5827

Closed
DorpsGek opened this issue Dec 12, 2013 · 0 comments · Fixed by #6763
Closed

Incorrect town growth rate ticks to days conversion #5827

DorpsGek opened this issue Dec 12, 2013 · 0 comments · Fixed by #6763
Labels
bug Something isn't working component: AI/Game script (squirrel) This issue is related to Squirrel (Scripting language) flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) good first issue Good for newcomers

Comments

@DorpsGek
Copy link
Member

dp opened the ticket and wrote:

Formula used for days to ticks conversion is wrong ((growth_rate * TOWN_GROWTH_TICKS + DAY_TICKS) / DAY_TICKS)
It produces plausible result in most cases, but only because TOWN_GROWTH_TICKS is almost equal to DAY_TICKS.

Correct one will be ((growth_rate + 1) * TOWN_GROWTH_TICKS + DAY_TICKS / 2) / DAY_TICKS)
Thus adding TOWN_GROWTH_TICKS instead of DAY_TICKS because that's how town growing works and extra DAY_TICKS / 2 for rounding.

That incorrect formula is also used in ScriptTown::GetGrowthRate and inverse(almost) formula in ScriptTown::SetGrowthRate is not quite correct too.

Reported version: 1.3.3
Operating system: All


This issue was imported from FlySpray: https://bugs.openttd.org/task/5827
@DorpsGek DorpsGek added flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) bug labels Apr 7, 2018
@TrueBrain TrueBrain added good first issue Good for newcomers bug Something isn't working and removed bug from FlySpray labels Apr 10, 2018
@andythenorth andythenorth added component: AI/Game script (squirrel) This issue is related to Squirrel (Scripting language) Goal/Game script and removed Script component: AI/Game script (squirrel) This issue is related to Squirrel (Scripting language) labels Apr 13, 2018
@frosch123 frosch123 added component: AI/Game script (squirrel) This issue is related to Squirrel (Scripting language) and removed Goal/Game script labels Apr 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working component: AI/Game script (squirrel) This issue is related to Squirrel (Scripting language) flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants