Add settings to ignore date/zone/GRF when placing houses in scenario editor
See: #177
This commit is contained in:
@@ -2003,6 +2003,12 @@ STR_CONFIG_SETTING_ADVANCE_ORDER_ON_CLONE_HELPTEXT :After cloning a
|
||||
|
||||
STR_CONFIG_SETTING_SCENARIO_MULTIPLE_BUILDINGS :Allow multiple churches/stadiums: {STRING2}
|
||||
STR_CONFIG_SETTING_SCENARIO_MULTIPLE_BUILDINGS_HELPTEXT :Allow manually adding churches and stadiums when there is already one present in the town.
|
||||
STR_CONFIG_SETTING_SCENARIO_HOUSE_IGNORE_DATES :Ignore house year restrictions: {STRING2}
|
||||
STR_CONFIG_SETTING_SCENARIO_HOUSE_IGNORE_DATES_HELPTEXT :Allow manually adding houses which are not available for the current date.
|
||||
STR_CONFIG_SETTING_SCENARIO_HOUSE_IGNORE_ZONES :Ignore house zone restrictions: {STRING2}
|
||||
STR_CONFIG_SETTING_SCENARIO_HOUSE_IGNORE_ZONES_HELPTEXT :Allow manually adding houses which are not suitable for the target town zone.
|
||||
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.
|
||||
|
||||
# Config errors
|
||||
STR_CONFIG_ERROR :{WHITE}Error with the configuration file...
|
||||
|
@@ -2012,6 +2012,9 @@ static SettingsContainer &GetSettingsTree()
|
||||
SettingsPage *scenario = main->Add(new SettingsPage(STR_CONFIG_SETTING_SCENARIO_EDITOR));
|
||||
{
|
||||
scenario->Add(new SettingEntry("scenario.multiple_buildings"));
|
||||
scenario->Add(new SettingEntry("scenario.house_ignore_dates"));
|
||||
scenario->Add(new SettingEntry("scenario.house_ignore_zones"));
|
||||
scenario->Add(new SettingEntry("scenario.house_ignore_grf"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -662,6 +662,9 @@ struct DebugSettings {
|
||||
/** Scenario editor settings. */
|
||||
struct ScenarioSettings {
|
||||
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_zones; ///< allow manually adding houses regardless of zone restrictions
|
||||
bool house_ignore_grf; ///< allow manually adding houses regardless of GRF restrictions
|
||||
};
|
||||
|
||||
/** All settings together for the game. */
|
||||
|
@@ -5334,6 +5334,27 @@ def = false
|
||||
str = STR_CONFIG_SETTING_SCENARIO_MULTIPLE_BUILDINGS
|
||||
strhelp = STR_CONFIG_SETTING_SCENARIO_MULTIPLE_BUILDINGS_HELPTEXT
|
||||
|
||||
[SDTC_BOOL]
|
||||
var = scenario.house_ignore_dates
|
||||
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
|
||||
def = false
|
||||
str = STR_CONFIG_SETTING_SCENARIO_HOUSE_IGNORE_DATES
|
||||
strhelp = STR_CONFIG_SETTING_SCENARIO_HOUSE_IGNORE_DATES_HELPTEXT
|
||||
|
||||
[SDTC_BOOL]
|
||||
var = scenario.house_ignore_zones
|
||||
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
|
||||
def = false
|
||||
str = STR_CONFIG_SETTING_SCENARIO_HOUSE_IGNORE_ZONES
|
||||
strhelp = STR_CONFIG_SETTING_SCENARIO_HOUSE_IGNORE_ZONES_HELPTEXT
|
||||
|
||||
[SDTC_BOOL]
|
||||
var = scenario.house_ignore_grf
|
||||
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
|
||||
def = false
|
||||
str = STR_CONFIG_SETTING_SCENARIO_HOUSE_IGNORE_GRF
|
||||
strhelp = STR_CONFIG_SETTING_SCENARIO_HOUSE_IGNORE_GRF_HELPTEXT
|
||||
|
||||
[SDTC_VAR]
|
||||
var = gui.network_chat_box_width_pct
|
||||
type = SLE_UINT16
|
||||
|
@@ -2476,7 +2476,7 @@ static inline CommandCost CanBuildHouseHere(const TileArea &ta, TownID town, int
|
||||
* @param zone return error if houses are forbidden in this house zone
|
||||
* @return success if house is avaliable, error message otherwise
|
||||
*/
|
||||
static inline CommandCost IsHouseTypeAllowed(HouseID house, bool above_snowline, HouseZonesBits zone)
|
||||
static inline CommandCost IsHouseTypeAllowed(HouseID house, bool above_snowline, HouseZonesBits zone, bool manual)
|
||||
{
|
||||
const HouseSpec *hs = HouseSpec::Get(house);
|
||||
/* Disallow disabled and replaced houses. */
|
||||
@@ -2491,6 +2491,8 @@ static inline CommandCost IsHouseTypeAllowed(HouseID house, bool above_snowline,
|
||||
if (!(hs->building_availability & HZ_SUBARTC_BELOW)) return_cmd_error(STR_ERROR_BUILDING_NOT_ALLOWED_BELOW_SNOW_LINE);
|
||||
}
|
||||
|
||||
if (manual && _settings_client.scenario.house_ignore_zones) return CommandCost();
|
||||
|
||||
/* Check if the house zone is allowed for this type of houses. */
|
||||
if (!HasBit(hs->building_availability & HZ_ZONALL, zone)) {
|
||||
return_cmd_error(STR_ERROR_BUILDING_NOT_ALLOWED_IN_THIS_TOWN_ZONE);
|
||||
@@ -2613,8 +2615,10 @@ static CommandCost CheckCanBuildHouse(HouseID house, const Town *t, bool manual)
|
||||
return CMD_ERROR;
|
||||
}
|
||||
|
||||
if (!manual || !_settings_client.scenario.house_ignore_dates) {
|
||||
if (_cur_year > hs->max_year) return_cmd_error(STR_ERROR_BUILDING_IS_TOO_OLD);
|
||||
if (_cur_year < hs->min_year) return_cmd_error(STR_ERROR_BUILDING_IS_TOO_MODERN);
|
||||
}
|
||||
|
||||
/* Special houses that there can be only one of. */
|
||||
if (hs->building_flags & BUILDING_IS_CHURCH) {
|
||||
@@ -2698,7 +2702,7 @@ CommandCost CmdBuildHouse(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
||||
|
||||
bool manual = (_game_mode == GM_EDITOR);
|
||||
|
||||
CommandCost ret = IsHouseTypeAllowed(house, above_snowline, TryGetTownRadiusGroup(t, tile));
|
||||
CommandCost ret = IsHouseTypeAllowed(house, above_snowline, TryGetTownRadiusGroup(t, tile), manual);
|
||||
if (ret.Succeeded()) ret = IsAnotherHouseTypeAllowedInTown(t, house);
|
||||
if (ret.Succeeded()) ret = CheckCanBuildHouse(house, t, manual);
|
||||
if (ret.Succeeded()) {
|
||||
@@ -2711,8 +2715,10 @@ CommandCost CmdBuildHouse(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
||||
}
|
||||
if (ret.Failed()) return ret;
|
||||
|
||||
if (!manual || !_settings_client.scenario.house_ignore_grf) {
|
||||
/* Check if GRF allows this house */
|
||||
if (!HouseAllowsConstruction(house, tile, t, random_bits)) return_cmd_error(STR_ERROR_BUILDING_NOT_ALLOWED);
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) DoBuildHouse(t, tile, house, random_bits);
|
||||
return CommandCost();
|
||||
@@ -2745,7 +2751,7 @@ static bool BuildTownHouse(Town *t, TileIndex tile)
|
||||
|
||||
/* Generate a list of all possible houses that can be built. */
|
||||
for (uint i = 0; i < NUM_HOUSES; i++) {
|
||||
if (IsHouseTypeAllowed((HouseID)i, above_snowline, zone).Failed()) continue;
|
||||
if (IsHouseTypeAllowed((HouseID)i, above_snowline, zone, false).Failed()) continue;
|
||||
if (IsAnotherHouseTypeAllowedInTown(t, (HouseID)i).Failed()) continue;
|
||||
|
||||
uint cur_prob = HouseSpec::Get(i)->probability;
|
||||
|
@@ -1959,7 +1959,7 @@ static void PlaceProc_House(TileIndex tile)
|
||||
int best_zone = (int)HZB_BEGIN - 1;
|
||||
for (const Town *t : Town::Iterate()) {
|
||||
HouseZonesBits town_zone = TryGetTownRadiusGroup(t, tile);
|
||||
if (HasBit(house_zones, town_zone)) {
|
||||
if (HasBit(house_zones, town_zone) || (_settings_client.scenario.house_ignore_zones && town_zone != HZB_END)) {
|
||||
/* 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. */
|
||||
if (!_ctrl_pressed) {
|
||||
|
Reference in New Issue
Block a user