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

Towns testing whether a road is allowed on a river tile return true #8462

Closed
SamuXarick opened this issue Dec 29, 2020 · 0 comments
Closed

Towns testing whether a road is allowed on a river tile return true #8462

SamuXarick opened this issue Dec 29, 2020 · 0 comments

Comments

@SamuXarick
Copy link
Contributor

@SamuXarick SamuXarick commented Dec 29, 2020

OpenTTD/src/town_cmd.cpp

Lines 908 to 918 in 0125892

/* Check if there already is a road at this point? */
if (GetTownRoadBits(tile) == ROAD_NONE) {
/* No, try if we are able to build a road piece there.
* If that fails clear the land, and if that fails exit.
* This is to make sure that we can build a road here later. */
RoadType rt = GetTownRoadType(t);
if (DoCommand(tile, ((dir == DIAGDIR_NW || dir == DIAGDIR_SE) ? ROAD_Y : ROAD_X) | (rt << 4), 0, DC_AUTO, CMD_BUILD_ROAD).Failed() &&
DoCommand(tile, 0, 0, DC_AUTO, CMD_LANDSCAPE_CLEAR).Failed()) {
return false;
}
}

I'm not an expert on the matter of town growth, but when I was testing stuff with rivers, I accidentally found something weird happening with the town road checks. It tests if it is able to build a road at a river tile, but the command does not fail when it reaches ClearTile_Water. Doesn't even get the chance to run the 2nd command.

I tried adding a DC_NO_WATER to those commands, and compared town generation with and without the flag, and I notice the towns are built differently, but I couldn't tell any glaring differences in them regarding their logic. Maybe an expert would know better.

This only happens with Better Roads or Original layout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant