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

[NRT] Building a tramtype over a roadtype with the NO_HOUSES flag set causes the flag to be ignored #9071

Open
Andrew350 opened this issue Apr 20, 2021 · 8 comments
Labels
bug Something isn't working component: NewGRF This issue is related to NewGRFs good first issue Good for newcomers

Comments

@Andrew350
Copy link

Version of OpenTTD

1.11.0, but probably all since NotRoadTypes was introduced

Expected result

If a roadtype disallows houses, a tramtype built over it should not override that.

Actual result

Godean Transport, 2065-07-12
The highway shown here has the NO_HOUSES flag set, yet houses still build next to the electrified tramway crossing it. The non-electrified tramway also has the NO_HOUSES flag set which is why houses are not building there, but that shouldn't be necessary since houses should not build alongside a tramway on its own anyway.

Steps to reproduce

tramtype_test.zip
This zip contains a small save and a modified NewGRF demonstrating the behavior, as shown above.

The Highway roadtype has the NO_HOUSES flag set, as does the non-electrified tramway, while the electrified tramway does not have the flag set.

@LordAro
Copy link
Member

LordAro commented May 3, 2021

I think the issue here is that the (default?) electrified tram lines don't have the NO_HOUSES flag set, which is what is happening here - town thinks it's fine to build houses along a tramline, the bordering road is not considered after that

@LordAro
Copy link
Member

LordAro commented May 3, 2021

Ah, I am (perhaps?) mistaken - the issue is that it's checking tram types at all - the town growth algorithm only tries to build houses next to roads, but then RoadTypesAllowHouseHere checks tramtypes as well. Take out the following line, and that fixes the issue.

if (tram_rt != INVALID_ROADTYPE && !HasBit(GetRoadTypeInfo(tram_rt)->flags, ROTF_NO_HOUSES)) return true;

Of course, it does mean that NO_HOUSES has no effect for tramtypes...

@PeterN
Copy link
Member

PeterN commented May 3, 2021

Should the default trams be changed to NO_HOUSES? Perhaps the logic should be to go by what the road type says, unless there is no road, then go by what the tram type says.

@LordAro
Copy link
Member

LordAro commented May 3, 2021

Thinking about it (more), we don't want NO_HOUSES on default trams, as that would mean (currently) that road + tram would become devoid of houses. Is the (actual (actual)) issue that this is also checking trams when there's no valid roadtype (i.e. tram on its own) ?

@PeterN
Copy link
Member

PeterN commented May 3, 2021

That's why I said go by what the road type says if it exists, so that a default road and a tram type with no houses on it would still get houses. Words.

@LordAro
Copy link
Member

LordAro commented Jul 21, 2021

Taken another look at this. There are 2 options -

  1. NO_HOUSES on a road/tramtype prevents any house from being built in a 3x3 area surrounding it
  2. NO_HOUSES only prevents houses if there are no other valid surrounding roads (this is, more or less, the current behaviour)
  3. Combination of the above, where tramtype are only taken into account if there is no road on the same tile.

NewGRF specs are a little ambiguous on it: https://newgrf-specs.tt-wiki.net/wiki/Action0/Roadtypes#Road_type_flags_.2810.29

A demonstration of the first method is below

image

Further thoughts/opinions appreciated.

@simonmeulenbeek
Copy link

IMO the most logical / correct way would be to only build houses if neither of the tramtype or roadtype has NO_HOUSES.

So leave the flags on the trams and roads as is, but change the code so it checks for both, and only build houses if both of the types allow it.

@ldpl
Copy link
Contributor

ldpl commented Oct 15, 2021

Wasn't the whole point of this highway thing to stop town growth from advancing along it? How did it turn into a neighbouring road check and these ugly and illogical exclusion zones? While town growth can still branch off the highway (#8506) or jump to other town and grow there?

@2TallTyler 2TallTyler added good first issue Good for newcomers component: NewGRF This issue is related to NewGRFs bug Something isn't working labels Oct 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working component: NewGRF This issue is related to NewGRFs good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

6 participants