From f92cf38ab5150dc6b8b00369028ac3a87db47dd1 Mon Sep 17 00:00:00 2001 From: Tyler Trahan Date: Fri, 11 Mar 2022 09:50:43 -0700 Subject: [PATCH] Feature: Allow disabling local authority control of company actions --- src/lang/english.txt | 5 +++-- src/settings_type.h | 2 +- src/station_cmd.cpp | 2 +- src/table/settings/difficulty_settings.ini | 4 ++-- src/table/settings/economy_settings.ini | 8 ++++++++ src/town.h | 7 +++++++ src/town_cmd.cpp | 9 +++++++-- src/town_type.h | 14 ++++++++------ 8 files changed, 37 insertions(+), 14 deletions(-) diff --git a/src/lang/english.txt b/src/lang/english.txt index becf8d35c2..35348e8f4c 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -1151,10 +1151,11 @@ STR_TERRAIN_TYPE_ALPINIST :Alpinist STR_TERRAIN_TYPE_CUSTOM :Custom height STR_TERRAIN_TYPE_CUSTOM_VALUE :Custom height ({NUM}) -###length 3 -STR_CITY_APPROVAL_PERMISSIVE :Permissive +###length 4 +STR_CITY_APPROVAL_LENIENT :Lenient STR_CITY_APPROVAL_TOLERANT :Tolerant STR_CITY_APPROVAL_HOSTILE :Hostile +STR_CITY_APPROVAL_PERMISSIVE :Permissive (no effect on company actions) STR_WARNING_NO_SUITABLE_AI :{WHITE}No suitable AIs available...{}You can download several AIs via the 'Online Content' system diff --git a/src/settings_type.h b/src/settings_type.h index 71f95142f9..5debee5545 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -519,7 +519,7 @@ struct EconomySettings { bool allow_town_roads; ///< towns are allowed to build roads (always allowed when generating world / in SE) TownFounding found_town; ///< town founding. bool station_noise_level; ///< build new airports when the town noise level is still within accepted limits - uint16 town_noise_population[3]; ///< population to base decision on noise evaluation (@see town_council_tolerance) + uint16 town_noise_population[4]; ///< population to base decision on noise evaluation (@see town_council_tolerance) bool allow_town_level_crossings; ///< towns are allowed to build level crossings bool infrastructure_maintenance; ///< enable monthly maintenance fee for owner infrastructure }; diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 01fee07784..2c038c548c 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -2258,7 +2258,7 @@ CommandCost CmdBuildAirport(DoCommandFlag flags, TileIndex tile, byte airport_ty authority_refuse_message = STR_ERROR_LOCAL_AUTHORITY_REFUSES_NOISE; authority_refuse_town = nearest; } - } else { + } else if (_settings_game.difficulty.town_council_tolerance != TOWN_COUNCIL_PERMISSIVE) { Town *t = ClosestTownFromTile(tile, UINT_MAX); uint num = 0; for (const Station *st : Station::Iterate()) { diff --git a/src/table/settings/difficulty_settings.ini b/src/table/settings/difficulty_settings.ini index 18d2ea7bbb..de1b54955c 100644 --- a/src/table/settings/difficulty_settings.ini +++ b/src/table/settings/difficulty_settings.ini @@ -265,11 +265,11 @@ from = SLV_97 flags = SF_GUI_DROPDOWN def = 0 min = 0 -max = 2 +max = 3 interval = 1 str = STR_CONFIG_SETTING_CITY_APPROVAL strhelp = STR_CONFIG_SETTING_CITY_APPROVAL_HELPTEXT -strval = STR_CITY_APPROVAL_PERMISSIVE +strval = STR_CITY_APPROVAL_LENIENT post_cb = DifficultyNoiseChange [SDTG_VAR] diff --git a/src/table/settings/economy_settings.ini b/src/table/settings/economy_settings.ini index 9ffd9edb70..0101e1bf98 100644 --- a/src/table/settings/economy_settings.ini +++ b/src/table/settings/economy_settings.ini @@ -284,6 +284,14 @@ min = 800 max = 65535 cat = SC_EXPERT +[SDT_VAR] +var = economy.town_noise_population[3] +type = SLE_UINT16 +def = 400 +min = 100 +max = 65535 +cat = SC_EXPERT + [SDT_BOOL] var = economy.infrastructure_maintenance from = SLV_166 diff --git a/src/town.h b/src/town.h index 294be7b53e..76b6e9c15c 100644 --- a/src/town.h +++ b/src/town.h @@ -152,6 +152,13 @@ void ExpandTown(Town *t); void RebuildTownKdtree(); +/** Settings for town council attitudes. */ +enum TownCouncilAttitudes { + TOWN_COUNCIL_LENIENT = 0, + TOWN_COUNCIL_TOLERANT = 1, + TOWN_COUNCIL_HOSTILE = 2, + TOWN_COUNCIL_PERMISSIVE = 3, +}; /** * Action types that a company must ask permission for to a town authority. diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index 62019e77d0..a0f00eba7a 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -675,7 +675,8 @@ static CommandCost ClearTile_Town(TileIndex tile, DoCommandFlag flags) Town *t = Town::GetByTile(tile); if (Company::IsValidID(_current_company)) { - if (rating > t->ratings[_current_company] && !(flags & DC_NO_TEST_TOWN_RATING) && !_cheats.magic_bulldozer.value) { + if (rating > t->ratings[_current_company] && !(flags & DC_NO_TEST_TOWN_RATING) && + !_cheats.magic_bulldozer.value && _settings_game.difficulty.town_council_tolerance != TOWN_COUNCIL_PERMISSIVE) { SetDParam(0, t->index); return_cmd_error(STR_ERROR_LOCAL_AUTHORITY_REFUSES_TO_ALLOW_THIS); } @@ -3527,6 +3528,9 @@ static void UpdateTownUnwanted(Town *t) */ CommandCost CheckIfAuthorityAllowsNewStation(TileIndex tile, DoCommandFlag flags) { + /* The required rating is hardcoded to RATING_VERYPOOR (see below), not the authority attitude setting, so we can bail out like this. */ + if (_settings_game.difficulty.town_council_tolerance == TOWN_COUNCIL_PERMISSIVE) return CommandCost(); + if (!Company::IsValidID(_current_company) || (flags & DC_NO_TEST_TOWN_RATING)) return CommandCost(); Town *t = ClosestTownFromTile(tile, _settings_game.economy.dist_local_authority); @@ -3691,9 +3695,10 @@ CommandCost CheckforTownRating(DoCommandFlag flags, Town *t, TownRatingCheckType /* minimum rating needed to be allowed to remove stuff */ static const int needed_rating[][TOWN_RATING_CHECK_TYPE_COUNT] = { /* ROAD_REMOVE, TUNNELBRIDGE_REMOVE */ - { RATING_ROAD_NEEDED_PERMISSIVE, RATING_TUNNEL_BRIDGE_NEEDED_PERMISSIVE}, // Permissive + { RATING_ROAD_NEEDED_LENIENT, RATING_TUNNEL_BRIDGE_NEEDED_LENIENT}, // Lenient { RATING_ROAD_NEEDED_NEUTRAL, RATING_TUNNEL_BRIDGE_NEEDED_NEUTRAL}, // Neutral { RATING_ROAD_NEEDED_HOSTILE, RATING_TUNNEL_BRIDGE_NEEDED_HOSTILE}, // Hostile + { RATING_ROAD_NEEDED_PERMISSIVE, RATING_TUNNEL_BRIDGE_NEEDED_PERMISSIVE}, // Permissive }; /* check if you're allowed to remove the road/bridge/tunnel diff --git a/src/town_type.h b/src/town_type.h index 3ea1a4e983..d1dcdcfc42 100644 --- a/src/town_type.h +++ b/src/town_type.h @@ -56,16 +56,18 @@ enum Ratings { RATING_TUNNEL_BRIDGE_DOWN_STEP = -250, ///< penalty for removing town owned tunnel or bridge RATING_TUNNEL_BRIDGE_MINIMUM = 0, ///< minimum rating after removing tunnel or bridge - RATING_TUNNEL_BRIDGE_NEEDED_PERMISSIVE = 144, ///< rating needed, "Permissive" difficulty settings - RATING_TUNNEL_BRIDGE_NEEDED_NEUTRAL = 208, ///< "Neutral" - RATING_TUNNEL_BRIDGE_NEEDED_HOSTILE = 400, ///< "Hostile" + RATING_TUNNEL_BRIDGE_NEEDED_LENIENT = 144, ///< rating needed, "Lenient" difficulty settings + RATING_TUNNEL_BRIDGE_NEEDED_NEUTRAL = 208, ///< "Neutral" + RATING_TUNNEL_BRIDGE_NEEDED_HOSTILE = 400, ///< "Hostile" + RATING_TUNNEL_BRIDGE_NEEDED_PERMISSIVE = RATING_MINIMUM, ///< "Permissive" (local authority disabled) RATING_ROAD_DOWN_STEP_INNER = -50, ///< removing a roadpiece in the middle RATING_ROAD_DOWN_STEP_EDGE = -18, ///< removing a roadpiece at the edge RATING_ROAD_MINIMUM = -100, ///< minimum rating after removing town owned road - RATING_ROAD_NEEDED_PERMISSIVE = 16, ///< rating needed, "Permissive" difficulty settings - RATING_ROAD_NEEDED_NEUTRAL = 64, ///< "Neutral" - RATING_ROAD_NEEDED_HOSTILE = 112, ///< "Hostile" + RATING_ROAD_NEEDED_LENIENT = 16, ///< rating needed, "Lenient" difficulty settings + RATING_ROAD_NEEDED_NEUTRAL = 64, ///< "Neutral" + RATING_ROAD_NEEDED_HOSTILE = 112, ///< "Hostile" + RATING_ROAD_NEEDED_PERMISSIVE = RATING_MINIMUM, ///< "Permissive" (local authority disabled) RATING_HOUSE_MINIMUM = RATING_MINIMUM,