diff options
author | michi_cc <michi_cc@openttd.org> | 2012-04-17 19:43:52 +0000 |
---|---|---|
committer | michi_cc <michi_cc@openttd.org> | 2012-04-17 19:43:52 +0000 |
commit | f3e295b4ec077f3f0ee9b82e12cb9c8eb5ceffc4 (patch) | |
tree | 23420ff202548b6af0e0b1d620b7a237ba10995e /src | |
parent | 181de38ae3b682e7d913862b9fe6124cd02fdccb (diff) | |
download | openttd-f3e295b4ec077f3f0ee9b82e12cb9c8eb5ceffc4.tar.xz |
(svn r24134) -Add: Configurable limits for tree planting.
Diffstat (limited to 'src')
-rw-r--r-- | src/company_base.h | 1 | ||||
-rw-r--r-- | src/company_cmd.cpp | 2 | ||||
-rw-r--r-- | src/lang/english.txt | 1 | ||||
-rw-r--r-- | src/saveload/afterload.cpp | 6 | ||||
-rw-r--r-- | src/saveload/company_sl.cpp | 1 | ||||
-rw-r--r-- | src/settings_type.h | 2 | ||||
-rw-r--r-- | src/table/settings.ini | 20 | ||||
-rw-r--r-- | src/tree_cmd.cpp | 20 |
8 files changed, 53 insertions, 0 deletions
diff --git a/src/company_base.h b/src/company_base.h index 0f9e8ae10..4cd5a498a 100644 --- a/src/company_base.h +++ b/src/company_base.h @@ -85,6 +85,7 @@ struct CompanyProperties { 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 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). diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp index 2850ad912..1ea293833 100644 --- a/src/company_cmd.cpp +++ b/src/company_cmd.cpp @@ -59,6 +59,7 @@ Company::Company(uint16 name_1, bool is_ai) this->is_ai = is_ai; this->terraform_limit = _settings_game.construction.terraform_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; InvalidateWindowData(WC_PERFORMANCE_DETAIL, 0, INVALID_COMPANY); @@ -260,6 +261,7 @@ void UpdateLandscapingLimits() 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->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); } } diff --git a/src/lang/english.txt b/src/lang/english.txt index 1e444db84..0cdfeb011 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -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_TERRAFORM_LIMIT_REACHED :{WHITE}... landscaping 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_GENERIC_OBJECT_IN_THE_WAY :{WHITE}{1:STRING} in the way STR_ERROR_NOT_ALLOWED_WHILE_PAUSED :{WHITE}Not allowed while paused diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index b800fe087..f83979bd4 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -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 */ AfterLoadRoadStops(); AfterLoadLabelMaps(); diff --git a/src/saveload/company_sl.cpp b/src/saveload/company_sl.cpp index e9cd02d95..34309bf9a 100644 --- a/src/saveload/company_sl.cpp +++ b/src/saveload/company_sl.cpp @@ -289,6 +289,7 @@ static const SaveLoad _company_desc[] = { 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, tree_limit, SLE_UINT32, 175, SL_MAX_VERSION), SLE_END() }; diff --git a/src/settings_type.h b/src/settings_type.h index c3825bdcf..72191d22a 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -254,6 +254,8 @@ struct ConstructionSettings { 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? 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. */ diff --git a/src/table/settings.ini b/src/table/settings.ini index efa70b7f0..5906042ee 100644 --- a/src/table/settings.ini +++ b/src/table/settings.ini @@ -411,6 +411,26 @@ min = 0 max = 1 << 30 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] base = GameSettings var = construction.autoslope diff --git a/src/tree_cmd.cpp b/src/tree_cmd.cpp index 51ad3dd4f..527cc165a 100644 --- a/src/tree_cmd.cpp +++ b/src/tree_cmd.cpp @@ -340,6 +340,9 @@ CommandCost CmdPlantTree(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 /* 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; + 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); TILE_AREA_LOOP(tile, ta) { switch (GetTileType(tile)) { @@ -350,9 +353,16 @@ CommandCost CmdPlantTree(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 continue; } + /* Test tree limit. */ + if (--limit < 1) { + msg = STR_ERROR_TREE_PLANT_LIMIT_REACHED; + break; + } + if (flags & DC_EXEC) { AddTreeCount(tile, 1); MarkTileDirtyByTile(tile); + if (c != NULL) c->tree_limit -= 1 << 16; } /* 2x as expensive to add more trees to an existing tile */ cost.AddCost(_price[PR_BUILD_TREES] * 2); @@ -383,6 +393,12 @@ CommandCost CmdPlantTree(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 continue; } + /* Test tree limit. */ + if (--limit < 1) { + msg = STR_ERROR_TREE_PLANT_LIMIT_REACHED; + break; + } + if (IsTileType(tile, MP_CLEAR)) { /* Remove fields or rocks. Note that the ground will get barrened */ switch (GetRawClearGround(tile)) { @@ -412,6 +428,7 @@ CommandCost CmdPlantTree(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 /* Plant full grown trees in scenario editor */ PlantTreesOnTile(tile, treetype, 0, _game_mode == GM_EDITOR ? 3 : 0); MarkTileDirtyByTile(tile); + if (c != NULL) c->tree_limit -= 1 << 16; /* When planting rainforest-trees, set tropiczone to rainforest in editor. */ 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; break; } + + /* Tree limit used up? No need to check more. */ + if (limit < 0) break; } if (cost.GetCost() == 0) { |