1
0
Fork 0

Fix #9712: Cap town bridge length at original 11-tile limit (#9890)

pull/9895/head
Tyler Trahan 2022-05-14 08:55:39 -06:00 committed by GitHub
parent 37d318c410
commit fa562ba041
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -1185,15 +1185,16 @@ static bool GrowTownWithBridge(const Town *t, const TileIndex tile, const DiagDi
if (!(GetTownRoadBits(TileAddByDiagDir(tile, ReverseDiagDir(bridge_dir))) & DiagDirToRoadBits(bridge_dir))) return false; if (!(GetTownRoadBits(TileAddByDiagDir(tile, ReverseDiagDir(bridge_dir))) & DiagDirToRoadBits(bridge_dir))) return false;
/* We are in the right direction */ /* We are in the right direction */
int bridge_length = 0; // This value stores the length of the possible bridge uint bridge_length = 0; // This value stores the length of the possible bridge
TileIndex bridge_tile = tile; // Used to store the other waterside TileIndex bridge_tile = tile; // Used to store the other waterside
const int delta = TileOffsByDiagDir(bridge_dir); const int delta = TileOffsByDiagDir(bridge_dir);
/* To prevent really small towns from building disproportionately /* To prevent really small towns from building disproportionately
* long bridges, make the max a function of its population. */ * long bridges, make the max a function of its population. */
int base_bridge_length = 5; const uint TOWN_BRIDGE_LENGTH_CAP = 11;
int max_bridge_length = t->cache.population / 1000 + base_bridge_length; uint base_bridge_length = 5;
uint max_bridge_length = std::min(t->cache.population / 1000 + base_bridge_length, TOWN_BRIDGE_LENGTH_CAP);
if (slope == SLOPE_FLAT) { if (slope == SLOPE_FLAT) {
/* Bridges starting on flat tiles are only allowed when crossing rivers, rails or one-way roads. */ /* Bridges starting on flat tiles are only allowed when crossing rivers, rails or one-way roads. */