Fix #10218: Sloped river tiles need water both up and downstream #10235
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
When widening rivers, we use a CircularTileSearch to attempt to terraform and make river tiles within the river's radius. This determines the desired slope automatically based on whether the target tile is part of a continuous row of sloped river tiles. This was missing a check to ensure the river is actually sloping down to the sea, so the row of sloped tiles could end up propagating inland, as seen in #10218.
I don't know what's going on with coast tiles being drawn in #10218, but this also avoids that happening. 馃檪
Description
Ensure that sloped tiles always have water both upstream and downstream from themselves.
New ocean tiles created by river terraforming will flood after river generation is complete, but on non-ocean tiles we can take a shortcut to create river tiles up and/or downstream, if they don't already exist.
Closes #10218.
A second commit moves a
cur_slope
update so it doesn't get run if no terraforming is needed, and gets rid of aRandomRange(1)
(which always returns 0) that must be vestigial code from the patch's development which somehow snuck past review.Limitations
It's still possible for a long river paralleling a coast to have a wide row of sloped tiles down to the sea. But this looks much less wrong than #10218 and is more of a design choice than a bug. 馃槈 I'm hesitant to write a lot of code to solve this and potentially introduce other edge cases where multiple rivers flow into the ocean near each other.
Checklist for review
Some things are not automated, and forgotten often. This list is a reminder for the reviewers.