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

Merged
merged 1 commit into from Oct 20, 2022
Merged

Feature: Wide rivers #9628

merged 1 commit into from Oct 20, 2022

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

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 This PR is receiving preview builds size: small This Pull Request is small, and should be relative easy to process labels Nov 22, 2021
@DorpsGek DorpsGek temporarily deployed to preview-pr-9628 November 22, 2021 09:12 Inactive
@DorpsGek DorpsGek temporarily deployed to preview-pr-9628 February 23, 2022 01:27 Inactive
@michicc
Copy link
Member

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

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

@2TallTyler 2TallTyler marked this pull request as draft March 11, 2022 21:11
@DorpsGek DorpsGek temporarily deployed to preview-pr-9628 May 4, 2022 14:49 Inactive
@DorpsGek DorpsGek temporarily deployed to preview-pr-9628 May 4, 2022 22:34 Inactive
@2TallTyler 2TallTyler marked this pull request as ready for review May 4, 2022 22:34
@2TallTyler
Copy link
Member Author

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 14:56
@2TallTyler
Copy link
Member Author

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

@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 20:35 Inactive
@2TallTyler
Copy link
Member Author

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 20:37
@DorpsGek DorpsGek temporarily deployed to preview-pr-9628 May 13, 2022 20:38 Inactive
@michicc
Copy link
Member

michicc commented Oct 18, 2022

Needs a rebase.

@DorpsGek DorpsGek temporarily deployed to preview-pr-9628 October 19, 2022 13:02 Inactive
@michicc michicc merged commit 664771d into OpenTTD:master Oct 20, 2022
@2TallTyler 2TallTyler deleted the wide_rivers branch October 20, 2022 19:54
@Zispah
Copy link

Zispah commented Dec 3, 2022

You know, it would be better if an option is added instead of replacing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
preview This PR is receiving preview builds size: small This Pull Request is small, and should be relative easy to process
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants