Add setting and town override for whether towns can build bridges

pull/480/head
Jonathan G Rennison 1 year ago
parent 7701d4e813
commit c80075b7cc

@ -2199,6 +2199,9 @@ STR_CONFIG_SETTING_TOWN_MAX_ROAD_SLOPE_HELPTEXT :Limit the lengt
STR_CONFIG_SETTING_TOWN_MAX_ROAD_SLOPE_VALUE :{NUM} tile{P "" s}
STR_CONFIG_SETTING_TOWN_MAX_ROAD_SLOPE_ZERO :No limit
STR_CONFIG_SETTING_ALLOW_TOWN_BRIDGES :Towns are allowed to build bridges: {STRING2}
STR_CONFIG_SETTING_ALLOW_TOWN_BRIDGES_HELPTEXT :Enabling this setting allows towns to build bridges
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
@ -4521,12 +4524,13 @@ STR_LOCAL_AUTHORITY_ACTION_TOOLTIP_NEW_BUILDINGS :{YELLOW}Fund th
STR_LOCAL_AUTHORITY_ACTION_TOOLTIP_EXCLUSIVE_TRANSPORT :{YELLOW}Buy 1 year's exclusive transport rights in town.{}Town authority will not allow passengers and cargo to use your competitors' stations.{}Cost: {CURRENCY_LONG}
STR_LOCAL_AUTHORITY_ACTION_TOOLTIP_BRIBE :{YELLOW}Bribe the local authority to increase your rating, at the risk of a severe penalty if caught.{}Cost: {CURRENCY_LONG}
###length 5
###length 6
STR_LOCAL_AUTHORITY_SETTING_OVERRIDE_ALLOW_ROADS :Allowed to build roads
STR_LOCAL_AUTHORITY_SETTING_OVERRIDE_ALLOW_LEVEL_CROSSINGS :Allowed to build level crossings
STR_LOCAL_AUTHORITY_SETTING_OVERRIDE_TUNNELS :Allowed to build tunnels
STR_LOCAL_AUTHORITY_SETTING_OVERRIDE_MAX_ROAD_SLOPE :Limit building continuous inclined roads
STR_LOCAL_AUTHORITY_SETTING_OVERRIDE_TOWN_GROWTH :Town growth speed
STR_LOCAL_AUTHORITY_SETTING_OVERRIDE_BRIDGES :Allowed to build bridges
STR_LOCAL_AUTHORITY_SETTING_OVERRIDE_DEFAULT :Default ({STRING1})
STR_LOCAL_AUTHORITY_SETTING_OVERRIDE_STR :{STRING}: {PUSH_COLOUR}{YELLOW}{STRING2}{POP_COLOUR}

@ -2233,6 +2233,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.allow_town_bridges"));
towns->Add(new SettingEntry("economy.town_build_tunnels"));
towns->Add(new SettingEntry("economy.town_max_road_slope"));
towns->Add(new SettingEntry("economy.found_town"));

@ -695,6 +695,7 @@ struct EconomySettings {
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
uint8 town_max_road_slope; ///< maximum number of consecutive sloped road tiles which towns are allowed to build
bool allow_town_bridges; ///< towns are allowed to build bridges
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.

@ -993,6 +993,14 @@ strval = STR_CONFIG_SETTING_TOWN_MAX_ROAD_SLOPE_VALUE
cat = SC_BASIC
patxname = ""economy.town_max_road_slope""
[SDT_BOOL]
var = economy.allow_town_bridges
def = true
str = STR_CONFIG_SETTING_ALLOW_TOWN_BRIDGES
strhelp = STR_CONFIG_SETTING_ALLOW_TOWN_BRIDGES_HELPTEXT
cat = SC_BASIC
patxname = ""economy.allow_town_bridges""
[SDT_XREF]
xref = ""economy.old_town_cargo_factor""
extver = SlXvFeatureTest(XSLFTO_AND, XSLFI_CHILLPP)

@ -66,6 +66,7 @@ enum TownSettingOverrideFlags {
TSOF_OVERRIDE_BUILD_TUNNELS = 2,
TSOF_OVERRIDE_BUILD_INCLINED_ROADS = 3,
TSOF_OVERRIDE_GROWTH = 4,
TSOF_OVERRIDE_BUILD_BRIDGES = 5,
};
/** Town data structure. */
@ -203,6 +204,11 @@ struct Town : TownPool::PoolItem<&_town_pool> {
return HasBit(this->override_flags, TSOF_OVERRIDE_BUILD_LEVEL_CROSSINGS) ? HasBit(this->override_values, TSOF_OVERRIDE_BUILD_LEVEL_CROSSINGS) : _settings_game.economy.allow_town_level_crossings;
}
inline bool GetAllowBuildBridges() const
{
return HasBit(this->override_flags, TSOF_OVERRIDE_BUILD_BRIDGES) ? HasBit(this->override_values, TSOF_OVERRIDE_BUILD_BRIDGES) : _settings_game.economy.allow_town_bridges;
}
inline TownTunnelMode GetBuildTunnelMode() const
{
return HasBit(this->override_flags, TSOF_OVERRIDE_BUILD_TUNNELS) ? this->build_tunnels : _settings_game.economy.town_build_tunnels;

@ -1352,6 +1352,8 @@ static bool GrowTownWithBridge(const Town *t, const TileIndex tile, const DiagDi
{
assert(bridge_dir < DIAGDIR_END);
if (!t->GetAllowBuildBridges()) return false;
const Slope slope = GetTileSlope(tile);
/* Make sure the direction is compatible with the slope.
@ -3828,6 +3830,7 @@ CommandCost CmdOverrideTownSetting(TileIndex tile, DoCommandFlag flags, uint32 p
break;
case TSOF_OVERRIDE_BUILD_ROADS:
case TSOF_OVERRIDE_BUILD_LEVEL_CROSSINGS:
case TSOF_OVERRIDE_BUILD_BRIDGES:
if (is_override && value != 0 && value != 1) return CMD_ERROR;
break;
case TSOF_OVERRIDE_BUILD_TUNNELS:
@ -3848,6 +3851,7 @@ CommandCost CmdOverrideTownSetting(TileIndex tile, DoCommandFlag flags, uint32 p
break;
case TSOF_OVERRIDE_BUILD_ROADS:
case TSOF_OVERRIDE_BUILD_LEVEL_CROSSINGS:
case TSOF_OVERRIDE_BUILD_BRIDGES:
SB(t->override_values, setting, 1, value & 1);
break;
case TSOF_OVERRIDE_BUILD_TUNNELS:

@ -113,7 +113,7 @@ private:
!(_local_company != COMPANY_SPECTATOR && _settings_game.difficulty.override_town_settings_in_multiplayer);
}
static const uint SETTING_OVERRIDE_COUNT = 5;
static const uint SETTING_OVERRIDE_COUNT = 6;
public:
TownAuthorityWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc), sel_index(-1), displayed_actions_on_previous_painting(0)
@ -219,6 +219,7 @@ public:
switch (idx) {
case TSOF_OVERRIDE_BUILD_ROADS:
case TSOF_OVERRIDE_BUILD_LEVEL_CROSSINGS:
case TSOF_OVERRIDE_BUILD_BRIDGES:
SetDParam(0, HasBit(this->town->override_values, idx) ? STR_CONFIG_SETTING_ON : STR_CONFIG_SETTING_OFF);
break;
case TSOF_OVERRIDE_BUILD_TUNNELS:
@ -261,6 +262,9 @@ public:
case TSOF_OVERRIDE_GROWTH:
SetDParam(1, STR_CONFIG_SETTING_TOWN_GROWTH_HELPTEXT);
break;
case TSOF_OVERRIDE_BUILD_BRIDGES:
SetDParam(1, STR_CONFIG_SETTING_ALLOW_TOWN_BRIDGES_HELPTEXT);
break;
}
text = STR_LOCAL_AUTHORITY_SETTING_OVERRIDE_TEXT;
SetDParam(0, STR_LOCAL_AUTHORITY_SETTING_OVERRIDE_ALLOW_ROADS + this->sel_index - 0x100);
@ -324,6 +328,10 @@ public:
case TSOF_OVERRIDE_GROWTH:
SetDParam(1, overriden ? STR_CONFIG_SETTING_TOWN_GROWTH_NONE : STR_COLOUR_DEFAULT);
break;
case TSOF_OVERRIDE_BUILD_BRIDGES:
SetDParam(2, this->town->GetAllowBuildBridges() ? STR_CONFIG_SETTING_ON : STR_CONFIG_SETTING_OFF);
break;
}
DrawString(ir.left, ir.right, y,
STR_LOCAL_AUTHORITY_SETTING_OVERRIDE_STR, tc);
@ -411,7 +419,8 @@ public:
uint8 idx = this->sel_index - 0x100;
switch (idx) {
case TSOF_OVERRIDE_BUILD_ROADS:
case TSOF_OVERRIDE_BUILD_LEVEL_CROSSINGS: {
case TSOF_OVERRIDE_BUILD_LEVEL_CROSSINGS:
case TSOF_OVERRIDE_BUILD_BRIDGES: {
int value = HasBit(this->town->override_flags, idx) ? (HasBit(this->town->override_values, idx) ? 2 : 1) : 0;
const StringID names[] = {
STR_COLOUR_DEFAULT,

Loading…
Cancel
Save