Add anywhere mode to ignore house zone scenario editor setting

See: #177
This commit is contained in:
Jonathan G Rennison
2020-08-03 19:37:50 +01:00
parent 348530b052
commit ce6cdc551f
4 changed files with 21 additions and 4 deletions

View File

@@ -2010,6 +2010,10 @@ STR_CONFIG_SETTING_SCENARIO_HOUSE_IGNORE_ZONES_HELPTEXT :Allow manually
STR_CONFIG_SETTING_SCENARIO_HOUSE_IGNORE_GRF :Ignore house GRF restrictions: {STRING2} STR_CONFIG_SETTING_SCENARIO_HOUSE_IGNORE_GRF :Ignore house GRF restrictions: {STRING2}
STR_CONFIG_SETTING_SCENARIO_HOUSE_IGNORE_GRF_HELPTEXT :Allow manually adding houses even if this is not permitted by the house GRF. STR_CONFIG_SETTING_SCENARIO_HOUSE_IGNORE_GRF_HELPTEXT :Allow manually adding houses even if this is not permitted by the house GRF.
STR_CONFIG_SETTING_SCENARIO_HOUSE_IGNORE_ZONES_OFF :Off
STR_CONFIG_SETTING_SCENARIO_HOUSE_IGNORE_ZONES_WITHIN_TOWN :Within town
STR_CONFIG_SETTING_SCENARIO_HOUSE_IGNORE_ZONES_ANYWHERE :Anywhere
# Config errors # Config errors
STR_CONFIG_ERROR :{WHITE}Error with the configuration file... STR_CONFIG_ERROR :{WHITE}Error with the configuration file...
STR_CONFIG_ERROR_ARRAY :{WHITE}... error in array '{RAW_STRING}' STR_CONFIG_ERROR_ARRAY :{WHITE}... error in array '{RAW_STRING}'

View File

@@ -663,7 +663,7 @@ struct DebugSettings {
struct ScenarioSettings { struct ScenarioSettings {
bool multiple_buildings; ///< allow manually adding more than one church/stadium bool multiple_buildings; ///< allow manually adding more than one church/stadium
bool house_ignore_dates; ///< allow manually adding houses regardless of date restrictions bool house_ignore_dates; ///< allow manually adding houses regardless of date restrictions
bool house_ignore_zones; ///< allow manually adding houses regardless of zone restrictions uint8 house_ignore_zones; ///< allow manually adding houses regardless of zone restrictions
bool house_ignore_grf; ///< allow manually adding houses regardless of GRF restrictions bool house_ignore_grf; ///< allow manually adding houses regardless of GRF restrictions
}; };

View File

@@ -5341,12 +5341,18 @@ def = false
str = STR_CONFIG_SETTING_SCENARIO_HOUSE_IGNORE_DATES str = STR_CONFIG_SETTING_SCENARIO_HOUSE_IGNORE_DATES
strhelp = STR_CONFIG_SETTING_SCENARIO_HOUSE_IGNORE_DATES_HELPTEXT strhelp = STR_CONFIG_SETTING_SCENARIO_HOUSE_IGNORE_DATES_HELPTEXT
[SDTC_BOOL] [SDTC_VAR]
var = scenario.house_ignore_zones var = scenario.house_ignore_zones
type = SLE_UINT8
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
def = false guiflags = SGF_MULTISTRING
def = 0
min = 0
max = 2
interval = 1
str = STR_CONFIG_SETTING_SCENARIO_HOUSE_IGNORE_ZONES str = STR_CONFIG_SETTING_SCENARIO_HOUSE_IGNORE_ZONES
strhelp = STR_CONFIG_SETTING_SCENARIO_HOUSE_IGNORE_ZONES_HELPTEXT strhelp = STR_CONFIG_SETTING_SCENARIO_HOUSE_IGNORE_ZONES_HELPTEXT
strval = STR_CONFIG_SETTING_SCENARIO_HOUSE_IGNORE_ZONES_OFF
[SDTC_BOOL] [SDTC_BOOL]
var = scenario.house_ignore_grf var = scenario.house_ignore_grf

View File

@@ -1959,7 +1959,7 @@ static void PlaceProc_House(TileIndex tile)
int best_zone = (int)HZB_BEGIN - 1; int best_zone = (int)HZB_BEGIN - 1;
for (const Town *t : Town::Iterate()) { for (const Town *t : Town::Iterate()) {
HouseZonesBits town_zone = TryGetTownRadiusGroup(t, tile); HouseZonesBits town_zone = TryGetTownRadiusGroup(t, tile);
if (HasBit(house_zones, town_zone) || (_settings_client.scenario.house_ignore_zones && town_zone != HZB_END)) { if (HasBit(house_zones, town_zone) || (_settings_client.scenario.house_ignore_zones == 1 && town_zone != HZB_END) || _settings_client.scenario.house_ignore_zones == 2) {
/* If CTRL is NOT pressed keep only single town on the list, the best one. /* If CTRL is NOT pressed keep only single town on the list, the best one.
* Otherwise add all towns to the list so they can be shown to the player. */ * Otherwise add all towns to the list so they can be shown to the player. */
if (!_ctrl_pressed) { if (!_ctrl_pressed) {
@@ -1979,6 +1979,13 @@ static void PlaceProc_House(TileIndex tile)
return; return;
} }
if (towns.size() > 16 && _settings_client.scenario.house_ignore_zones == 2) {
std::sort(towns.begin(), towns.end(), [&](const TownID a, const TownID b) {
return DistanceSquare(tile, Town::Get(a)->xy) < DistanceSquare(tile, Town::Get(a)->xy);
});
towns.resize(16);
}
CommandContainer cmd = { CommandContainer cmd = {
tile, tile,
_cur_house, // p1 - house type and town index (town not yet set) _cur_house, // p1 - house type and town index (town not yet set)