Add company rate limit for land area purchasing
This commit is contained in:
@@ -86,6 +86,7 @@ struct CompanyProperties {
|
|||||||
uint32 terraform_limit; ///< Amount of tileheights we can (still) terraform (times 65536).
|
uint32 terraform_limit; ///< Amount of tileheights we can (still) terraform (times 65536).
|
||||||
uint32 clear_limit; ///< Amount of tiles we can (still) clear (times 65536).
|
uint32 clear_limit; ///< Amount of tiles we can (still) clear (times 65536).
|
||||||
uint32 tree_limit; ///< Amount of trees we can (still) plant (times 65536).
|
uint32 tree_limit; ///< Amount of trees we can (still) plant (times 65536).
|
||||||
|
uint32 purchase_land_limit; ///< Amount of tiles we can (still) purchase (times 65536).
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If \c true, the company is (also) controlled by the computer (a NoAI program).
|
* If \c true, the company is (also) controlled by the computer (a NoAI program).
|
||||||
@@ -104,7 +105,7 @@ struct CompanyProperties {
|
|||||||
face(0), money(0), money_fraction(0), current_loan(0), colour(0), block_preview(0),
|
face(0), money(0), money_fraction(0), current_loan(0), colour(0), block_preview(0),
|
||||||
location_of_HQ(0), last_build_coordinate(0), share_owners(), inaugurated_year(0),
|
location_of_HQ(0), last_build_coordinate(0), share_owners(), inaugurated_year(0),
|
||||||
months_of_bankruptcy(0), bankrupt_asked(0), bankrupt_timeout(0), bankrupt_value(0),
|
months_of_bankruptcy(0), bankrupt_asked(0), bankrupt_timeout(0), bankrupt_value(0),
|
||||||
terraform_limit(0), clear_limit(0), tree_limit(0), is_ai(false) {}
|
terraform_limit(0), clear_limit(0), tree_limit(0), purchase_land_limit(0), is_ai(false) {}
|
||||||
|
|
||||||
~CompanyProperties()
|
~CompanyProperties()
|
||||||
{
|
{
|
||||||
|
@@ -67,6 +67,7 @@ Company::Company(uint16 name_1, bool is_ai)
|
|||||||
this->terraform_limit = _settings_game.construction.terraform_frame_burst << 16;
|
this->terraform_limit = _settings_game.construction.terraform_frame_burst << 16;
|
||||||
this->clear_limit = _settings_game.construction.clear_frame_burst << 16;
|
this->clear_limit = _settings_game.construction.clear_frame_burst << 16;
|
||||||
this->tree_limit = _settings_game.construction.tree_frame_burst << 16;
|
this->tree_limit = _settings_game.construction.tree_frame_burst << 16;
|
||||||
|
this->purchase_land_limit = _settings_game.construction.purchase_land_frame_burst << 16;
|
||||||
|
|
||||||
for (uint j = 0; j < 4; j++) this->share_owners[j] = COMPANY_SPECTATOR;
|
for (uint j = 0; j < 4; j++) this->share_owners[j] = COMPANY_SPECTATOR;
|
||||||
InvalidateWindowData(WC_PERFORMANCE_DETAIL, 0, INVALID_COMPANY);
|
InvalidateWindowData(WC_PERFORMANCE_DETAIL, 0, INVALID_COMPANY);
|
||||||
@@ -273,6 +274,7 @@ void UpdateLandscapingLimits()
|
|||||||
c->terraform_limit = min(c->terraform_limit + _settings_game.construction.terraform_per_64k_frames, (uint32)_settings_game.construction.terraform_frame_burst << 16);
|
c->terraform_limit = min(c->terraform_limit + _settings_game.construction.terraform_per_64k_frames, (uint32)_settings_game.construction.terraform_frame_burst << 16);
|
||||||
c->clear_limit = min(c->clear_limit + _settings_game.construction.clear_per_64k_frames, (uint32)_settings_game.construction.clear_frame_burst << 16);
|
c->clear_limit = min(c->clear_limit + _settings_game.construction.clear_per_64k_frames, (uint32)_settings_game.construction.clear_frame_burst << 16);
|
||||||
c->tree_limit = min(c->tree_limit + _settings_game.construction.tree_per_64k_frames, (uint32)_settings_game.construction.tree_frame_burst << 16);
|
c->tree_limit = min(c->tree_limit + _settings_game.construction.tree_per_64k_frames, (uint32)_settings_game.construction.tree_frame_burst << 16);
|
||||||
|
c->purchase_land_limit = min(c->purchase_land_limit + _settings_game.construction.purchase_land_per_64k_frames, (uint32)_settings_game.construction.purchase_land_frame_burst << 16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -5284,6 +5284,7 @@ STR_ERROR_OBJECT_IN_THE_WAY :{WHITE}Object i
|
|||||||
STR_ERROR_COMPANY_HEADQUARTERS_IN :{WHITE}... company headquarters in the way
|
STR_ERROR_COMPANY_HEADQUARTERS_IN :{WHITE}... company headquarters in the way
|
||||||
STR_ERROR_CAN_T_PURCHASE_THIS_LAND :{WHITE}Can't purchase this land area...
|
STR_ERROR_CAN_T_PURCHASE_THIS_LAND :{WHITE}Can't purchase this land area...
|
||||||
STR_ERROR_YOU_ALREADY_OWN_IT :{WHITE}... you already own it!
|
STR_ERROR_YOU_ALREADY_OWN_IT :{WHITE}... you already own it!
|
||||||
|
STR_ERROR_PURCHASE_LAND_LIMIT_REACHED :{WHITE}... land area purchasing limit reached
|
||||||
|
|
||||||
# Group related errors
|
# Group related errors
|
||||||
STR_ERROR_GROUP_CAN_T_CREATE :{WHITE}Can't create group...
|
STR_ERROR_GROUP_CAN_T_CREATE :{WHITE}Can't create group...
|
||||||
|
@@ -305,6 +305,7 @@ CommandCost CmdBuildObject(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
|||||||
}
|
}
|
||||||
|
|
||||||
int hq_score = 0;
|
int hq_score = 0;
|
||||||
|
Company *c = nullptr;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case OBJECT_TRANSMITTER:
|
case OBJECT_TRANSMITTER:
|
||||||
case OBJECT_LIGHTHOUSE:
|
case OBJECT_LIGHTHOUSE:
|
||||||
@@ -317,6 +318,10 @@ CommandCost CmdBuildObject(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
|||||||
IsObjectType(tile, OBJECT_OWNED_LAND)) {
|
IsObjectType(tile, OBJECT_OWNED_LAND)) {
|
||||||
return_cmd_error(STR_ERROR_YOU_ALREADY_OWN_IT);
|
return_cmd_error(STR_ERROR_YOU_ALREADY_OWN_IT);
|
||||||
}
|
}
|
||||||
|
c = Company::GetIfValid(_current_company);
|
||||||
|
if (c != NULL && (int)GB(c->purchase_land_limit, 16, 16) < 1) {
|
||||||
|
return_cmd_error(STR_ERROR_PURCHASE_LAND_LIMIT_REACHED);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OBJECT_HQ: {
|
case OBJECT_HQ: {
|
||||||
@@ -349,6 +354,8 @@ CommandCost CmdBuildObject(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
|||||||
|
|
||||||
/* Make sure the HQ starts at the right size. */
|
/* Make sure the HQ starts at the right size. */
|
||||||
if (type == OBJECT_HQ) UpdateCompanyHQ(tile, hq_score);
|
if (type == OBJECT_HQ) UpdateCompanyHQ(tile, hq_score);
|
||||||
|
|
||||||
|
if (type == OBJECT_OWNED_LAND && c != NULL) c->purchase_land_limit -= 1 << 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
cost.AddCost(ObjectSpec::Get(type)->GetBuildCost() * size_x * size_y);
|
cost.AddCost(ObjectSpec::Get(type)->GetBuildCost() * size_x * size_y);
|
||||||
|
@@ -3555,6 +3555,12 @@ bool AfterLoadGame()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (SlXvIsFeatureMissing(XSLFI_BUY_LAND_RATE_LIMIT)) {
|
||||||
|
/* Introduced land purchasing limit. */
|
||||||
|
Company *c;
|
||||||
|
FOR_ALL_COMPANIES(c) c->purchase_land_limit = _settings_game.construction.purchase_land_frame_burst << 16;
|
||||||
|
}
|
||||||
|
|
||||||
/* Road stops is 'only' updating some caches */
|
/* Road stops is 'only' updating some caches */
|
||||||
AfterLoadRoadStops();
|
AfterLoadRoadStops();
|
||||||
AfterLoadLabelMaps();
|
AfterLoadLabelMaps();
|
||||||
|
@@ -295,6 +295,7 @@ static const SaveLoad _company_desc[] = {
|
|||||||
SLE_CONDVAR(CompanyProperties, terraform_limit, SLE_UINT32, 156, SL_MAX_VERSION),
|
SLE_CONDVAR(CompanyProperties, terraform_limit, SLE_UINT32, 156, SL_MAX_VERSION),
|
||||||
SLE_CONDVAR(CompanyProperties, clear_limit, SLE_UINT32, 156, SL_MAX_VERSION),
|
SLE_CONDVAR(CompanyProperties, clear_limit, SLE_UINT32, 156, SL_MAX_VERSION),
|
||||||
SLE_CONDVAR(CompanyProperties, tree_limit, SLE_UINT32, 175, SL_MAX_VERSION),
|
SLE_CONDVAR(CompanyProperties, tree_limit, SLE_UINT32, 175, SL_MAX_VERSION),
|
||||||
|
SLE_CONDVAR_X(CompanyProperties, purchase_land_limit, SLE_UINT32, 0, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_BUY_LAND_RATE_LIMIT)),
|
||||||
|
|
||||||
SLE_END()
|
SLE_END()
|
||||||
};
|
};
|
||||||
|
@@ -88,6 +88,7 @@ const SlxiSubChunkInfo _sl_xv_sub_chunk_infos[] = {
|
|||||||
{ XSLFI_WHOLE_MAP_CHUNK, XSCF_NULL, 2, 2, "whole_map_chunk", NULL, NULL, "WMAP" },
|
{ XSLFI_WHOLE_MAP_CHUNK, XSCF_NULL, 2, 2, "whole_map_chunk", NULL, NULL, "WMAP" },
|
||||||
{ XSLFI_ST_LAST_VEH_TYPE, XSCF_NULL, 1, 1, "station_last_veh_type", NULL, NULL, NULL },
|
{ XSLFI_ST_LAST_VEH_TYPE, XSCF_NULL, 1, 1, "station_last_veh_type", NULL, NULL, NULL },
|
||||||
{ XSLFI_SELL_AT_DEPOT_ORDER, XSCF_NULL, 1, 1, "sell_at_depot_order", NULL, NULL, NULL },
|
{ XSLFI_SELL_AT_DEPOT_ORDER, XSCF_NULL, 1, 1, "sell_at_depot_order", NULL, NULL, NULL },
|
||||||
|
{ XSLFI_BUY_LAND_RATE_LIMIT, XSCF_NULL, 1, 1, "buy_land_rate_limit", NULL, NULL, NULL },
|
||||||
{ XSLFI_NULL, XSCF_NULL, 0, 0, NULL, NULL, NULL, NULL },// This is the end marker
|
{ XSLFI_NULL, XSCF_NULL, 0, 0, NULL, NULL, NULL, NULL },// This is the end marker
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -62,6 +62,7 @@ enum SlXvFeatureIndex {
|
|||||||
XSLFI_WHOLE_MAP_CHUNK, ///< Whole map chunk
|
XSLFI_WHOLE_MAP_CHUNK, ///< Whole map chunk
|
||||||
XSLFI_ST_LAST_VEH_TYPE, ///< Per-cargo station last vehicle type
|
XSLFI_ST_LAST_VEH_TYPE, ///< Per-cargo station last vehicle type
|
||||||
XSLFI_SELL_AT_DEPOT_ORDER, ///< Sell vehicle on arrival at depot orders
|
XSLFI_SELL_AT_DEPOT_ORDER, ///< Sell vehicle on arrival at depot orders
|
||||||
|
XSLFI_BUY_LAND_RATE_LIMIT, ///< Buy land rate limit
|
||||||
|
|
||||||
XSLFI_RIFF_HEADER_60_BIT, ///< Size field in RIFF chunk header is 60 bit
|
XSLFI_RIFF_HEADER_60_BIT, ///< Size field in RIFF chunk header is 60 bit
|
||||||
XSLFI_HEIGHT_8_BIT, ///< Map tile height is 8 bit instead of 4 bit, but savegame version may be before this became true in trunk
|
XSLFI_HEIGHT_8_BIT, ///< Map tile height is 8 bit instead of 4 bit, but savegame version may be before this became true in trunk
|
||||||
|
@@ -385,6 +385,8 @@ struct ConstructionSettings {
|
|||||||
uint16 clear_frame_burst; ///< how many tiles may, over a short period, be cleared?
|
uint16 clear_frame_burst; ///< how many tiles may, over a short period, be cleared?
|
||||||
uint32 tree_per_64k_frames; ///< how many trees may, over a long period, be planted per 65536 frames?
|
uint32 tree_per_64k_frames; ///< how many trees may, over a long period, be planted per 65536 frames?
|
||||||
uint16 tree_frame_burst; ///< how many trees may, over a short period, be planted?
|
uint16 tree_frame_burst; ///< how many trees may, over a short period, be planted?
|
||||||
|
uint32 purchase_land_per_64k_frames; ///< how many tiles may, over a long period, be purchased per 65536 frames?
|
||||||
|
uint16 purchase_land_frame_burst; ///< how many tiles may, over a short period, be purchased?
|
||||||
uint8 tree_growth_rate; ///< tree growth rate
|
uint8 tree_growth_rate; ///< tree growth rate
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -553,6 +553,30 @@ max = 1 << 30
|
|||||||
interval = 1
|
interval = 1
|
||||||
cat = SC_EXPERT
|
cat = SC_EXPERT
|
||||||
|
|
||||||
|
[SDT_VAR]
|
||||||
|
base = GameSettings
|
||||||
|
var = construction.purchase_land_per_64k_frames
|
||||||
|
type = SLE_UINT32
|
||||||
|
from = 0
|
||||||
|
def = 16 << 16
|
||||||
|
min = 0
|
||||||
|
max = 1 << 30
|
||||||
|
interval = 1
|
||||||
|
cat = SC_EXPERT
|
||||||
|
patxname = ""buy_land_rate_limit.construction.purchase_land_per_64k_frames""
|
||||||
|
|
||||||
|
[SDT_VAR]
|
||||||
|
base = GameSettings
|
||||||
|
var = construction.purchase_land_frame_burst
|
||||||
|
type = SLE_UINT16
|
||||||
|
from = 0
|
||||||
|
def = 1024
|
||||||
|
min = 0
|
||||||
|
max = 1 << 30
|
||||||
|
interval = 1
|
||||||
|
cat = SC_EXPERT
|
||||||
|
patxname = ""buy_land_rate_limit.construction.purchase_land_frame_burst""
|
||||||
|
|
||||||
[SDT_BOOL]
|
[SDT_BOOL]
|
||||||
base = GameSettings
|
base = GameSettings
|
||||||
var = construction.autoslope
|
var = construction.autoslope
|
||||||
|
Reference in New Issue
Block a user