Add: Check that towns can build roads before generating map. #12503
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation / Problem
Some NewGRFs set introduction dates and flags for road types in such a way that towns cannot build them, or cannot build them until a specific date.
In these circumstances during map generation the game will briefly 'hang' as it tries to repeatly place towns that can never be built, before finally giving up. The delay is larger depending map size and number of towns to build.
Eventually the map generation aborts, and the user is greeted with the message "Map generation aborted... ... no suitable town locations" which does not explain the problem at all.
Description
Instead, before generating the terrain, check if any town-buildable road types are available. If none can be built, immediately abort landscape generation, and show an error message (similar to the warning for vehicles not being available yet.)
This error message explains better what the issue is, and how it can be resolved, including a date if that is required.
Limitations
Checklist for review
Some things are not automated, and forgotten often. This list is a reminder for the reviewers.