diff --git a/src/lang/english.txt b/src/lang/english.txt index 124f8e34f6..0f1fe723ac 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -2188,6 +2188,13 @@ STR_CONFIG_SETTING_ALLOW_TOWN_ROADS_HELPTEXT :Allow towns to STR_CONFIG_SETTING_ALLOW_TOWN_LEVEL_CROSSINGS :Towns are allowed to build level crossings: {STRING2} STR_CONFIG_SETTING_ALLOW_TOWN_LEVEL_CROSSINGS_HELPTEXT :Enabling this setting allows towns to build level crossings +STR_CONFIG_SETTING_TOWN_TUNNELS :Towns are allowed to build tunnels: {STRING2} +STR_CONFIG_SETTING_TOWN_TUNNELS_HELPTEXT :Under what conditions are towns allowed to build road tunnels +###length 3 +STR_CONFIG_SETTING_TOWN_TUNNELS_FORBIDDEN :Forbidden +STR_CONFIG_SETTING_TOWN_TUNNELS_ALLOWED_OBSTRUCTION :Allowed only for small obstructions +STR_CONFIG_SETTING_TOWN_TUNNELS_ALLOWED :Allowed + STR_CONFIG_SETTING_NOISE_LEVEL :Allow town controlled noise level for airports: {STRING2} STR_CONFIG_SETTING_NOISE_LEVEL_HELPTEXT :With this setting disabled, there can be two airports in each town. With this setting enabled, the number of airports in a town is limited by the noise acceptance of the town, which depends on population and airport size and distance diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index b9bf4e8339..300387a3e9 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -2191,6 +2191,7 @@ static SettingsContainer &GetSettingsTree() towns->Add(new SettingEntry("economy.town_zone_calc_mode")); towns->Add(new SettingEntry("economy.allow_town_roads")); towns->Add(new SettingEntry("economy.allow_town_level_crossings")); + towns->Add(new SettingEntry("economy.town_build_tunnels")); towns->Add(new SettingEntry("economy.found_town")); towns->Add(new SettingEntry("economy.town_cargogen_mode")); towns->Add(new SettingEntry("economy.town_cargo_scale_factor")); diff --git a/src/settings_type.h b/src/settings_type.h index 0bf57aabcb..54b6f43af0 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -688,6 +688,7 @@ struct EconomySettings { uint sharing_fee[4]; ///< fees for infrastructure sharing for rail/road/water/air bool sharing_payment_in_debt; ///< allow fee payment for companies with more loan than money (switch off to prevent MP exploits) bool allow_town_level_crossings; ///< towns are allowed to build level crossings + TownTunnelMode town_build_tunnels; ///< if/when towns are allowed to build road tunnels int8 old_town_cargo_factor; ///< old power-of-two multiplier for town (passenger, mail) generation. May be negative. int16 town_cargo_scale_factor; ///< scaled power-of-two multiplier for town (passenger, mail) generation. May be negative. int16 industry_cargo_scale_factor; ///< scaled power-of-two multiplier for primary industry generation. May be negative. diff --git a/src/table/settings/settings.ini b/src/table/settings/settings.ini index 496b0e3240..b31ba7a74a 100644 --- a/src/table/settings/settings.ini +++ b/src/table/settings/settings.ini @@ -935,6 +935,20 @@ def = true str = STR_CONFIG_SETTING_ALLOW_TOWN_LEVEL_CROSSINGS strhelp = STR_CONFIG_SETTING_ALLOW_TOWN_LEVEL_CROSSINGS_HELPTEXT +[SDT_VAR] +var = economy.town_build_tunnels +type = SLE_UINT8 +flags = SF_GUI_DROPDOWN +def = TTM_ALLOWED +min = TTM_BEGIN +max = TTM_END - 1 +interval = 1 +str = STR_CONFIG_SETTING_TOWN_TUNNELS +strhelp = STR_CONFIG_SETTING_TOWN_TUNNELS_HELPTEXT +strval = STR_CONFIG_SETTING_TOWN_TUNNELS_FORBIDDEN +cat = SC_BASIC +patxname = ""economy.town_build_tunnels"" + [SDT_XREF] xref = ""economy.old_town_cargo_factor"" extver = SlXvFeatureTest(XSLFTO_AND, XSLFI_CHILLPP) diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index fb15c43480..0d5269f947 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -1426,6 +1426,8 @@ static bool GrowTownWithTunnel(const Town *t, const TileIndex tile, const DiagDi { assert(tunnel_dir < DIAGDIR_END); + if (_settings_game.economy.town_build_tunnels == TTM_FORBIDDEN) return false; + Slope slope = GetTileSlope(tile); /* Only consider building a tunnel if the starting tile is sloped properly. */ @@ -1439,6 +1441,8 @@ static bool GrowTownWithTunnel(const Town *t, const TileIndex tile, const DiagDi /* There are two conditions for building tunnels: Under a mountain and under an obstruction. */ if (CanRoadContinueIntoNextTile(t, tile, tunnel_dir)) { + if (_settings_game.economy.town_build_tunnels != TTM_ALLOWED) return false; + /* Only tunnel under a mountain if the slope is continuous for at least 4 tiles. We want tunneling to be a last resort for large hills. */ TileIndex slope_tile = tile; for (uint8 tiles = 0; tiles < 4; tiles++) { diff --git a/src/town_type.h b/src/town_type.h index e2fba63bbd..3593d15712 100644 --- a/src/town_type.h +++ b/src/town_type.h @@ -130,4 +130,14 @@ struct TransportedCargoStat { } }; + +/** Town allow tunnel building setting values. It needs to be 8bits, because we save and load it as such */ +enum TownTunnelMode : byte { + TTM_BEGIN = 0, ///< Used for iterations and limit testing + TTM_FORBIDDEN = 0, ///< Forbidden + TTM_OBSTRUCTION_ONLY, ///< Allowed only for tunnels under obstructions + TTM_ALLOWED, ///< Allowed in all cases (including through hills) + TTM_END, ///< Used for iterations and limit testing +}; + #endif /* TOWN_TYPE_H */