diff options
author | Didac Perez Parera <perez.didac@gmail.com> | 2020-12-26 16:10:21 -0800 |
---|---|---|
committer | Patric Stout <github@truebrain.nl> | 2021-01-06 21:39:34 +0100 |
commit | 64eddaeb499e7ad17275b34634ceaaff64c84728 (patch) | |
tree | c3b0ae636046eb3bc2271837602ec947cf93c820 | |
parent | c3faec4e9a220aacab6f6332e466a38665bb9842 (diff) | |
download | openttd-64eddaeb499e7ad17275b34634ceaaff64c84728.tar.xz |
Feature: Make maximum length of town bridges depend on population.
-rw-r--r-- | src/town_cmd.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index 8928ffdbf..f3dbe7ae4 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -1159,10 +1159,15 @@ static bool GrowTownWithBridge(const Town *t, const TileIndex tile, const DiagDi const int delta = TileOffsByDiagDir(bridge_dir); + /* To prevent really small towns from building disproportionately + * long bridges, make the max a function of its population. */ + int base_bridge_length = 4; + int max_bridge_length = t->cache.population / 1000 + base_bridge_length; + if (slope == SLOPE_FLAT) { /* Bridges starting on flat tiles are only allowed when crossing rivers, rails or one-way roads. */ do { - if (bridge_length++ >= 4) { + if (bridge_length++ >= base_bridge_length) { /* Allow to cross rivers, not big lakes, nor large amounts of rails or one-way roads. */ return false; } @@ -1170,8 +1175,8 @@ static bool GrowTownWithBridge(const Town *t, const TileIndex tile, const DiagDi } while (IsValidTile(bridge_tile) && ((IsWaterTile(bridge_tile) && !IsSea(bridge_tile)) || IsPlainRailTile(bridge_tile) || (IsNormalRoadTile(bridge_tile) && GetDisallowedRoadDirections(bridge_tile) != DRD_NONE))); } else { do { - if (bridge_length++ >= 11) { - /* Max 11 tile long bridges */ + if (bridge_length++ >= max_bridge_length) { + /* Ensure the bridge is not longer than the max allowed length. */ return false; } bridge_tile += delta; |