Add setting to control if and how land purchasing is permitted

This commit is contained in:
Jonathan G Rennison
2018-11-26 18:25:17 +00:00
parent c9c3e6f574
commit e3207a77fb
6 changed files with 43 additions and 1 deletions

View File

@@ -1893,6 +1893,16 @@ STR_CONFIG_SETTING_ALLOW_GRF_OBJECTS_UNDER_BRIDGES_HELPTEXT :Allow all NewGR
STR_CONFIG_SETTING_ALLOW_STATIONS_UNDER_BRIDGES :Allow stations under bridges: {STRING2} STR_CONFIG_SETTING_ALLOW_STATIONS_UNDER_BRIDGES :Allow stations under bridges: {STRING2}
STR_CONFIG_SETTING_ALLOW_STATIONS_UNDER_BRIDGES_HELPTEXT :Allow stations to be built under bridges (excluding airports, and rail stations/waypoints where the required bridge clearance is set by the GRF).{}This may result in graphical issues. STR_CONFIG_SETTING_ALLOW_STATIONS_UNDER_BRIDGES_HELPTEXT :Allow stations to be built under bridges (excluding airports, and rail stations/waypoints where the required bridge clearance is set by the GRF).{}This may result in graphical issues.
STR_CONFIG_SETTING_PURCHASE_LAND_PERMITTED :Permit purchasing land: {STRING2}
STR_CONFIG_SETTING_PURCHASE_LAND_PERMITTED_HELPTEXT :Set whether companies are permitted to purchase tiles of land, and in what quantity
STR_PURCHASE_LAND_PERMITTED_NO :No
STR_PURCHASE_LAND_PERMITTED_SINGLE :Yes, 1 tile at a time
STR_PURCHASE_LAND_PERMITTED_AREA :Yes, large areas at a time
STR_PURCHASE_LAND_NOT_PERMITTED :Purchasing of land is not permitted
STR_PURCHASE_LAND_NOT_PERMITTED_BULK :Purchasing of large areas of land is not permitted
STR_CONFIG_SETTING_QUERY_CAPTION :{WHITE}Change setting value STR_CONFIG_SETTING_QUERY_CAPTION :{WHITE}Change setting value
STR_CONFIG_SETTING_ADJACENT_CROSSINGS :Close adjacent level crossings: {STRING2} STR_CONFIG_SETTING_ADJACENT_CROSSINGS :Close adjacent level crossings: {STRING2}

View File

@@ -226,6 +226,7 @@ CommandCost CmdBuildObject(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
TileArea ta(tile, size_x, size_y); TileArea ta(tile, size_x, size_y);
if (type == OBJECT_OWNED_LAND) { if (type == OBJECT_OWNED_LAND) {
if (_settings_game.construction.purchase_land_permitted == 0) return_cmd_error(STR_PURCHASE_LAND_NOT_PERMITTED);
/* Owned land is special as it can be placed on any slope. */ /* Owned land is special as it can be placed on any slope. */
cost.AddCost(DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR)); cost.AddCost(DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR));
} else { } else {
@@ -375,6 +376,8 @@ CommandCost CmdBuildObject(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
CommandCost CmdPurchaseLandArea(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) CommandCost CmdPurchaseLandArea(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
{ {
if (p1 >= MapSize()) return CMD_ERROR; if (p1 >= MapSize()) return CMD_ERROR;
if (_settings_game.construction.purchase_land_permitted == 0) return_cmd_error(STR_PURCHASE_LAND_NOT_PERMITTED);
if (_settings_game.construction.purchase_land_permitted != 2) return_cmd_error(STR_PURCHASE_LAND_NOT_PERMITTED_BULK);
Money money = GetAvailableMoneyForCommand(); Money money = GetAvailableMoneyForCommand();
CommandCost cost(EXPENSES_CONSTRUCTION); CommandCost cost(EXPENSES_CONSTRUCTION);

View File

@@ -1746,6 +1746,7 @@ static SettingsContainer &GetSettingsTree()
limitations->Add(new SettingEntry("construction.rail_custom_bridge_heads")); limitations->Add(new SettingEntry("construction.rail_custom_bridge_heads"));
limitations->Add(new SettingEntry("construction.allow_grf_objects_under_bridges")); limitations->Add(new SettingEntry("construction.allow_grf_objects_under_bridges"));
limitations->Add(new SettingEntry("construction.allow_stations_under_bridges")); limitations->Add(new SettingEntry("construction.allow_stations_under_bridges"));
limitations->Add(new SettingEntry("construction.purchase_land_permitted"));
} }
SettingsPage *disasters = main->Add(new SettingsPage(STR_CONFIG_SETTING_ACCIDENTS)); SettingsPage *disasters = main->Add(new SettingsPage(STR_CONFIG_SETTING_ACCIDENTS));

View File

@@ -378,6 +378,7 @@ struct ConstructionSettings {
uint8 rail_custom_bridge_heads; ///< allow construction of rail custom bridge heads uint8 rail_custom_bridge_heads; ///< allow construction of rail custom bridge heads
bool allow_grf_objects_under_bridges; ///< allow all NewGRF objects under bridges bool allow_grf_objects_under_bridges; ///< allow all NewGRF objects under bridges
bool allow_stations_under_bridges; ///< allow all station tiles under bridges bool allow_stations_under_bridges; ///< allow all station tiles under bridges
byte purchase_land_permitted; ///< whether and how purchasing land is permitted
uint32 terraform_per_64k_frames; ///< how many tile heights may, over a long period, be terraformed per 65536 frames? uint32 terraform_per_64k_frames; ///< how many tile heights may, over a long period, be terraformed per 65536 frames?
uint16 terraform_frame_burst; ///< how many tile heights may, over a short period, be terraformed? uint16 terraform_frame_burst; ///< how many tile heights may, over a short period, be terraformed?

View File

@@ -1524,6 +1524,20 @@ str = STR_CONFIG_SETTING_ALLOW_STATIONS_UNDER_BRIDGES
strhelp = STR_CONFIG_SETTING_ALLOW_STATIONS_UNDER_BRIDGES_HELPTEXT strhelp = STR_CONFIG_SETTING_ALLOW_STATIONS_UNDER_BRIDGES_HELPTEXT
patxname = ""allow_stations_under_bridges.construction.allow_stations_under_bridges"" patxname = ""allow_stations_under_bridges.construction.allow_stations_under_bridges""
[SDT_VAR]
base = GameSettings
var = construction.purchase_land_permitted
type = SLE_UINT8
guiflags = SGF_MULTISTRING
def = 1
min = 0
max = 2
interval = 1
str = STR_CONFIG_SETTING_PURCHASE_LAND_PERMITTED
strhelp = STR_CONFIG_SETTING_PURCHASE_LAND_PERMITTED_HELPTEXT
strval = STR_PURCHASE_LAND_PERMITTED_NO
patxname = ""purchase_land_permitted.construction.purchase_land_permitted""
[SDT_BOOL] [SDT_BOOL]
base = GameSettings base = GameSettings
var = station.adjacent_stations var = station.adjacent_stations

View File

@@ -179,6 +179,7 @@ struct TerraformToolbarWindow : Window {
/* Don't show the place object button when there are no objects to place. */ /* Don't show the place object button when there are no objects to place. */
NWidgetStacked *show_object = this->GetWidget<NWidgetStacked>(WID_TT_SHOW_PLACE_OBJECT); NWidgetStacked *show_object = this->GetWidget<NWidgetStacked>(WID_TT_SHOW_PLACE_OBJECT);
show_object->SetDisplayedPlane(ObjectClass::GetUIClassCount() != 0 ? 0 : SZSP_NONE); show_object->SetDisplayedPlane(ObjectClass::GetUIClassCount() != 0 ? 0 : SZSP_NONE);
SetWidgetDisabledState(WID_TT_BUY_LAND, _settings_game.construction.purchase_land_permitted == 0);
} }
virtual void OnClick(Point pt, int widget, int click_count) virtual void OnClick(Point pt, int widget, int click_count)
@@ -253,7 +254,19 @@ struct TerraformToolbarWindow : Window {
break; break;
case WID_TT_BUY_LAND: // Buy land button case WID_TT_BUY_LAND: // Buy land button
VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_BUY_LAND); switch (_settings_game.construction.purchase_land_permitted) {
case 0:
case 1:
DoCommandP(tile, OBJECT_OWNED_LAND, 0, CMD_BUILD_OBJECT | CMD_MSG(STR_ERROR_CAN_T_PURCHASE_THIS_LAND), CcPlaySound_SPLAT_RAIL);
break;
case 2:
VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_BUY_LAND);
break;
default:
NOT_REACHED();
}
break; break;
case WID_TT_MEASUREMENT_TOOL: case WID_TT_MEASUREMENT_TOOL: