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

Feature: Wide rivers #9628

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Feature: Wide rivers #9628

wants to merge 1 commit into from

Conversation

2TallTyler
Copy link
Member

@2TallTyler 2TallTyler commented Oct 19, 2021

Motivation / Problem

Real-life rivers and watersheds are shaped like enormous trees: thin branches gathering together into a wide trunk which flows to the sea.

OpenTTD rivers often follow the same branching structure, but don't get any wider.

Description

tasty

This started as a JGRPP patch by @VacuumBreather (a.k.a. Lt. Joker).

It makes 10% of rivers longer and has them get wider as they get further from the source.

I added Doxygen, changed some code style items and added terraforming to keep rivers wide as they flow down slopes.

Limitations

I've tested map generation pretty thoroughly for odd generation or possible terraforming under existing water tiles (which is pretty glitchy) but it's possible I could have missed a corner case.

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 touches english.txt or translations? Check the guidelines
  • 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')

@2TallTyler
Copy link
Member Author

@2TallTyler 2TallTyler commented Nov 19, 2021

Fixed pointer format to follow code style, since apparently my VS2019 has been configured to auto-correct it to the wrong format for months... 😕

@nielsmh nielsmh added preview size: small labels Nov 22, 2021
@DorpsGek DorpsGek temporarily deployed to preview-pr-9628 Nov 22, 2021 Inactive
@DorpsGek DorpsGek temporarily deployed to preview-pr-9628 Feb 23, 2022 Inactive
@michicc
Copy link
Member

@michicc michicc commented Mar 8, 2022

I like this idea in principle, even if somebody™️ will declare it the end of the world.

One thing that sometimes looks a bit ugly is the way larger rivers meet the coast due to the fact that river tiles can't be on all slopes. I've seen it quite often that the final tile on the coast is just one tile wide due to the slopes. Ideally, some spot terraforming could create a proper wider slope.

Code wise it looks fine. One could remove the globals in favour of using the AyStar user data (like e.g. https://gist.github.com/michicc/91ac9d01052605150e6d31ba781ff01d), but this is definitely a bikeshed thing.

@2TallTyler
Copy link
Member Author

@2TallTyler 2TallTyler commented Mar 9, 2022

I'll see if I can figure out some slope terraforming.

@2TallTyler 2TallTyler marked this pull request as draft Mar 11, 2022
@DorpsGek DorpsGek temporarily deployed to preview-pr-9628 May 4, 2022 Inactive
@DorpsGek DorpsGek temporarily deployed to preview-pr-9628 May 4, 2022 Inactive
@2TallTyler 2TallTyler marked this pull request as ready for review May 4, 2022
@2TallTyler
Copy link
Member Author

@2TallTyler 2TallTyler commented May 4, 2022

Thanks for the gist; I've adopted it and also added slope terraforming.

Everyone: please try and break this! I've generated and inspected a lot of maps and haven't seen any graphical glitches, but earlier versions of my terraforming did undermine river tiles without deleting the water, leading to holes in the world like this:

glitch

@2TallTyler 2TallTyler marked this pull request as draft May 5, 2022
@2TallTyler
Copy link
Member Author

@2TallTyler 2TallTyler commented May 5, 2022

Marked as draft due to these bugs reported on Discord:

bug1
bug2

It appears that the sloped tile had 3/4 corners raised and was terraformed to a slope, undermining the glitched tile which had previously been a flat tile river.

This line should prevent this, but clearly it has not. In fact, I think this line isn't working properly at all, since almost every slope has a flat river tile adjacent — this is an error in my logic which has been bypassed by my code not working...

Any insights into what I'm missing? Something about water class, perhaps?

@JGRennison
Copy link
Contributor

@JGRennison JGRennison commented May 5, 2022

@2TallTyler In River_FoundEndNode you are interleaving calls to MakeRiver along the tiles found by the A-star path with calls to RiverMakeWider which modify the landscape. This is likely to result in your found river path no longer having tiles of the correct slope. Also, as written widening won't be done where the path is shared with an existing narrower river.
It may be worth looking into using multiple passes instead.

@DorpsGek DorpsGek temporarily deployed to preview-pr-9628 May 13, 2022 Inactive
@2TallTyler
Copy link
Member Author

@2TallTyler 2TallTyler commented May 13, 2022

Thanks for the insight. It took me a while to understand what you meant, but that (and a fix for the broken line of code mentioned above) seems to have solved the issue. Additional testing appreciated!

@2TallTyler 2TallTyler marked this pull request as ready for review May 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
preview size: small
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants