Fix #7604: prevent houses to wander too far from town center when rebuilding #8507
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
As described in #7604, a bug that existed since TTO. It is a funny little bug, and depending on how lucky you are, houses could wander off endlessly. This simple approach resolve the wandering around.
Description
When a multi-tile house is rebuild, it always used the most northern
tile to build the new house. This can very easily lead to houses
wandering off in the north-ish direction (either NW or NE).
To prevent this, pick the tile closest to town center when rebuilding
on a multi-tile house. This still means a house can be build away
from a road, but it is no longer wandering around finding another
town to call home.
If you want to see for yourself that this works, best to use the following savegame:
issue-7604.zip
It is somewhat prepared to show the worst of this all ;) Just load it in, unpause, fast forward, and once in a while send some funds to the town. If you want to test this faster, change line 624 to:
t->time_until_rebuild = 1;
And line 629 to:
if (true || GB(r, 24, 8) >= 12) {
Now you have some speedy rebuilds on your hands!
Limitations
Checklist for review
Some things are not automated, and forgotten often. This list is a reminder for the reviewers.