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

Fix 0125892: Don't crash when towns upgrade road tiles during expansion #8651

Merged
merged 1 commit into from Feb 7, 2021

Conversation

mattkimber
Copy link
Contributor

@mattkimber mattkimber commented Feb 6, 2021

Motivation / Problem

0125892 introduced a fix for converting road types not updating infrastructure counters.

When a town expands in a game with multiple town-buildable road types introduced over time, it may result in a road tile being upgraded by the build road command. This causes an assert when the new code tries to get a company from the company pool using company ID 15.

Fixes #8650

Description

This fix checks that the current company ID is a valid company before attempting to get the company from the pool and update infrastructure counters.

Limitations

There do not appear to be any other attempts to get companies from the pool introduced by the mentioned commit, so this should be sufficient to fix the observed bug. I haven't done an exhaustive search for other cases, although my experience is this bug has only occurred in versions build after December 28th so it's likely that is the sole cause.

Checklist for review

Some things are not automated, and forgotten often. This list is a reminder for the reviewers.

  • The bug fix is important enough to be backported? (label: 'backport requested')
  • This PR affects the save game format? (label 'savegame upgrade')
  • This PR affects the GS/AI API? (label 'needs review: Script API')
    • ai_changelog.hpp, gs_changelog.hpp need updating.
    • The compatibility wrappers (compat_*.nut) need updating.
  • This PR affects the NewGRF API? (label 'needs review: NewGRF')

@mattkimber
Copy link
Contributor Author

This is an example save game demonstrating the issue. The town will attempt to convert a road tile in the top right corner from Sett to Town Road after a few days of running.

test_fail_case.zip

src/road_cmd.cpp Outdated Show resolved Hide resolved
@glx22 glx22 merged commit 2a6da31 into OpenTTD:master Feb 7, 2021
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

Successfully merging this pull request may close these issues.

Assertion failed at line 111 of D:\a\OpenTTD\OpenTTD\src\core/pool_type.hpp: index < this->first_unused
3 participants