mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-12 10:30:28 +00:00
(svn r24134) -Add: Configurable limits for tree planting.
This commit is contained in:
parent
181de38ae3
commit
f3e295b4ec
@ -85,6 +85,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).
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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).
|
||||||
|
@ -59,6 +59,7 @@ Company::Company(uint16 name_1, bool is_ai)
|
|||||||
this->is_ai = is_ai;
|
this->is_ai = 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;
|
||||||
|
|
||||||
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);
|
||||||
@ -260,6 +261,7 @@ void UpdateLandscapingLimits()
|
|||||||
FOR_ALL_COMPANIES(c) {
|
FOR_ALL_COMPANIES(c) {
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3663,6 +3663,7 @@ STR_ERROR_OWNED_BY :{WHITE}... owne
|
|||||||
STR_ERROR_AREA_IS_OWNED_BY_ANOTHER :{WHITE}... area is owned by another company
|
STR_ERROR_AREA_IS_OWNED_BY_ANOTHER :{WHITE}... area is owned by another company
|
||||||
STR_ERROR_TERRAFORM_LIMIT_REACHED :{WHITE}... landscaping limit reached
|
STR_ERROR_TERRAFORM_LIMIT_REACHED :{WHITE}... landscaping limit reached
|
||||||
STR_ERROR_CLEARING_LIMIT_REACHED :{WHITE}... tile clearing limit reached
|
STR_ERROR_CLEARING_LIMIT_REACHED :{WHITE}... tile clearing limit reached
|
||||||
|
STR_ERROR_TREE_PLANT_LIMIT_REACHED :{WHITE}... tree planting limit reached
|
||||||
STR_ERROR_NAME_MUST_BE_UNIQUE :{WHITE}Name must be unique
|
STR_ERROR_NAME_MUST_BE_UNIQUE :{WHITE}Name must be unique
|
||||||
STR_ERROR_GENERIC_OBJECT_IN_THE_WAY :{WHITE}{1:STRING} in the way
|
STR_ERROR_GENERIC_OBJECT_IN_THE_WAY :{WHITE}{1:STRING} in the way
|
||||||
STR_ERROR_NOT_ALLOWED_WHILE_PAUSED :{WHITE}Not allowed while paused
|
STR_ERROR_NOT_ALLOWED_WHILE_PAUSED :{WHITE}Not allowed while paused
|
||||||
|
@ -2736,6 +2736,12 @@ bool AfterLoadGame()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IsSavegameVersionBefore(175)) {
|
||||||
|
/* Introduced tree planting limit. */
|
||||||
|
Company *c;
|
||||||
|
FOR_ALL_COMPANIES(c) c->tree_limit = _settings_game.construction.tree_frame_burst << 16;
|
||||||
|
}
|
||||||
|
|
||||||
/* Road stops is 'only' updating some caches */
|
/* Road stops is 'only' updating some caches */
|
||||||
AfterLoadRoadStops();
|
AfterLoadRoadStops();
|
||||||
AfterLoadLabelMaps();
|
AfterLoadLabelMaps();
|
||||||
|
@ -289,6 +289,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_END()
|
SLE_END()
|
||||||
};
|
};
|
||||||
|
@ -254,6 +254,8 @@ struct ConstructionSettings {
|
|||||||
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?
|
||||||
uint32 clear_per_64k_frames; ///< how many tiles may, over a long period, be cleared per 65536 frames?
|
uint32 clear_per_64k_frames; ///< how many tiles may, over a long period, be cleared per 65536 frames?
|
||||||
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?
|
||||||
|
uint16 tree_frame_burst; ///< how many trees may, over a short period, be planted?
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Settings related to the AI. */
|
/** Settings related to the AI. */
|
||||||
|
@ -411,6 +411,26 @@ min = 0
|
|||||||
max = 1 << 30
|
max = 1 << 30
|
||||||
interval = 1
|
interval = 1
|
||||||
|
|
||||||
|
[SDT_VAR]
|
||||||
|
base = GameSettings
|
||||||
|
var = construction.tree_per_64k_frames
|
||||||
|
type = SLE_UINT32
|
||||||
|
from = 175
|
||||||
|
def = 64 << 16
|
||||||
|
min = 0
|
||||||
|
max = 1 << 30
|
||||||
|
interval = 1
|
||||||
|
|
||||||
|
[SDT_VAR]
|
||||||
|
base = GameSettings
|
||||||
|
var = construction.tree_frame_burst
|
||||||
|
type = SLE_UINT16
|
||||||
|
from = 175
|
||||||
|
def = 4096
|
||||||
|
min = 0
|
||||||
|
max = 1 << 30
|
||||||
|
interval = 1
|
||||||
|
|
||||||
[SDT_BOOL]
|
[SDT_BOOL]
|
||||||
base = GameSettings
|
base = GameSettings
|
||||||
var = construction.autoslope
|
var = construction.autoslope
|
||||||
|
@ -340,6 +340,9 @@ CommandCost CmdPlantTree(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
|||||||
/* Check the tree type within the current climate */
|
/* Check the tree type within the current climate */
|
||||||
if (tree_to_plant != TREE_INVALID && !IsInsideBS(tree_to_plant, _tree_base_by_landscape[_settings_game.game_creation.landscape], _tree_count_by_landscape[_settings_game.game_creation.landscape])) return CMD_ERROR;
|
if (tree_to_plant != TREE_INVALID && !IsInsideBS(tree_to_plant, _tree_base_by_landscape[_settings_game.game_creation.landscape], _tree_count_by_landscape[_settings_game.game_creation.landscape])) return CMD_ERROR;
|
||||||
|
|
||||||
|
Company *c = (_game_mode != GM_EDITOR) ? Company::GetIfValid(_current_company) : NULL;
|
||||||
|
int limit = (c == NULL ? INT32_MAX : GB(c->tree_limit, 16, 16));
|
||||||
|
|
||||||
TileArea ta(tile, p2);
|
TileArea ta(tile, p2);
|
||||||
TILE_AREA_LOOP(tile, ta) {
|
TILE_AREA_LOOP(tile, ta) {
|
||||||
switch (GetTileType(tile)) {
|
switch (GetTileType(tile)) {
|
||||||
@ -350,9 +353,16 @@ CommandCost CmdPlantTree(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Test tree limit. */
|
||||||
|
if (--limit < 1) {
|
||||||
|
msg = STR_ERROR_TREE_PLANT_LIMIT_REACHED;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
AddTreeCount(tile, 1);
|
AddTreeCount(tile, 1);
|
||||||
MarkTileDirtyByTile(tile);
|
MarkTileDirtyByTile(tile);
|
||||||
|
if (c != NULL) c->tree_limit -= 1 << 16;
|
||||||
}
|
}
|
||||||
/* 2x as expensive to add more trees to an existing tile */
|
/* 2x as expensive to add more trees to an existing tile */
|
||||||
cost.AddCost(_price[PR_BUILD_TREES] * 2);
|
cost.AddCost(_price[PR_BUILD_TREES] * 2);
|
||||||
@ -383,6 +393,12 @@ CommandCost CmdPlantTree(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Test tree limit. */
|
||||||
|
if (--limit < 1) {
|
||||||
|
msg = STR_ERROR_TREE_PLANT_LIMIT_REACHED;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (IsTileType(tile, MP_CLEAR)) {
|
if (IsTileType(tile, MP_CLEAR)) {
|
||||||
/* Remove fields or rocks. Note that the ground will get barrened */
|
/* Remove fields or rocks. Note that the ground will get barrened */
|
||||||
switch (GetRawClearGround(tile)) {
|
switch (GetRawClearGround(tile)) {
|
||||||
@ -412,6 +428,7 @@ CommandCost CmdPlantTree(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
|||||||
/* Plant full grown trees in scenario editor */
|
/* Plant full grown trees in scenario editor */
|
||||||
PlantTreesOnTile(tile, treetype, 0, _game_mode == GM_EDITOR ? 3 : 0);
|
PlantTreesOnTile(tile, treetype, 0, _game_mode == GM_EDITOR ? 3 : 0);
|
||||||
MarkTileDirtyByTile(tile);
|
MarkTileDirtyByTile(tile);
|
||||||
|
if (c != NULL) c->tree_limit -= 1 << 16;
|
||||||
|
|
||||||
/* When planting rainforest-trees, set tropiczone to rainforest in editor. */
|
/* When planting rainforest-trees, set tropiczone to rainforest in editor. */
|
||||||
if (_game_mode == GM_EDITOR && IsInsideMM(treetype, TREE_RAINFOREST, TREE_CACTUS)) {
|
if (_game_mode == GM_EDITOR && IsInsideMM(treetype, TREE_RAINFOREST, TREE_CACTUS)) {
|
||||||
@ -426,6 +443,9 @@ CommandCost CmdPlantTree(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
|||||||
msg = STR_ERROR_SITE_UNSUITABLE;
|
msg = STR_ERROR_SITE_UNSUITABLE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Tree limit used up? No need to check more. */
|
||||||
|
if (limit < 0) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cost.GetCost() == 0) {
|
if (cost.GetCost() == 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user