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 #8462: Don't check whether to grow a town road on water #8471

Merged

Conversation

@SamuXarick
Copy link
Contributor

@SamuXarick SamuXarick commented Dec 31, 2020

Motivation / Problem

#8462
With Original or Better Roads town layout, towns are testing whether they can build a road at a tile for future use, but the command omits the DC_NO_WATER flag, which mean that on full clear water tiles, such as sea, river or canal with no owner, the command would return true.

I'm not a town growth expert, but I don't think towns are supposed to be clearing water tiles to expand on them.

Description

I think the problem is solved by using DC_NO_WATER flag on this situation.

Limitations

I have no great knowledge of town growth code, but with some tests, towns grow differently with the fix in, when they're near river tiles. But I'm not really sure of the whole impact of this change.

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')
@LordAro
Copy link
Member

@LordAro LordAro commented Jan 2, 2021

Looked at the code a bit, and I'm 90% certain that adding DC_NO_WATER to CMD_BUILD_ROAD does nothing - it only has an effect for the CLEAR_LANDSCAPE

Seems reasonable otherwise

@SamuXarick
Copy link
Contributor Author

@SamuXarick SamuXarick commented Jan 2, 2021

Looked at the code a bit, and I'm 90% certain that adding DC_NO_WATER to CMD_BUILD_ROAD does nothing - it only has an effect for the CLEAR_LANDSCAPE

Seems reasonable otherwise

LordAro, CMD_BUILD_ROAD also ends up running CMD_LANDSCAPE_CLEAR and inherits the DC flags from the source.
Without DC_NO_WATER, CMD_BUILD_ROAD calls CMD_LANDSCAPE_CLEAR and reaches ClearTile_Water which say it is possible to clear the water. If the command was run in DC_EXEC mode, you would see rivers being demolished and replaced with roads

Copy link
Member

@TrueBrain TrueBrain left a comment

"Should be fine" (famous last words, looking at @LordAro :P :P ).

DC_NO_WATER is indeed forwarded to CMD_LANDSCAPE_CLEAR, so this should have an effect.

The order of these commands is very odd, but .. not going to touch that now :)

@TrueBrain TrueBrain merged commit 8da5cff into OpenTTD:master Jan 9, 2021
7 checks passed
7 checks passed
Emscripten
Details
Commit checker
Details
Linux (clang, clang++)
Details
Linux (gcc, g++)
Details
Mac OS (x64, x86_64) Mac OS (x64, x86_64)
Details
Windows (x86) Windows (x86)
Details
Windows (x64) Windows (x64)
Details
@SamuXarick SamuXarick deleted the SamuXarick:towns-dont-check-building-road-on-water branch Jan 9, 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
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants