summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-04-16 21:46:06 +0000
committerrubidium <rubidium@openttd.org>2010-04-16 21:46:06 +0000
commit39d421ff9c7ede33b0dbdbf224e44982928a0a7c (patch)
tree3efb639c776beb1bcc373a88b55542de321732c4
parent2141ca23687b538ad5c537fc468b61bfc3b01bc2 (diff)
downloadopenttd-39d421ff9c7ede33b0dbdbf224e44982928a0a7c.tar.xz
(svn r19644) -Fix [FS#3728]: don't allow building cacti outside of the desert or rain forest trees outside of the rain forest area. This to prevent people from thinking planting rain forest trees makes the rain forest bigger and thus adds more place to build a lumber mill.
-rw-r--r--src/lang/english.txt1
-rw-r--r--src/tree_cmd.cpp21
2 files changed, 18 insertions, 4 deletions
diff --git a/src/lang/english.txt b/src/lang/english.txt
index 37e752036..fe1848229 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -3529,6 +3529,7 @@ STR_ERROR_CAN_T_BUILD_AQUEDUCT_HERE :{WHITE}Can't bu
# Tree related errors
STR_ERROR_TREE_ALREADY_HERE :{WHITE}... tree already here
+STR_ERROR_TREE_WRONG_TERRAIN_FOR_TREE_TYPE :{WHITE}... wrong terrain for tree type
STR_ERROR_CAN_T_PLANT_TREE_HERE :{WHITE}Can't plant tree here...
# Bridge related errors
diff --git a/src/tree_cmd.cpp b/src/tree_cmd.cpp
index 3a96ddc3a..1a3fe87f5 100644
--- a/src/tree_cmd.cpp
+++ b/src/tree_cmd.cpp
@@ -375,12 +375,25 @@ CommandCost CmdPlantTree(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
continue;
}
/* FALL THROUGH */
- case MP_CLEAR:
+ case MP_CLEAR: {
if (IsBridgeAbove(tile)) {
msg = STR_ERROR_SITE_UNSUITABLE;
continue;
}
+ TreeType treetype = (TreeType)tree_to_plant;
+ /* Be a bit picky about which trees go where. */
+ if (_settings_game.game_creation.landscape == LT_TROPIC && treetype != TREE_INVALID && (
+ /* No cacti outside the desert */
+ (treetype == TREE_CACTUS && GetTropicZone(tile) != TROPICZONE_DESERT) ||
+ /* No rain forest trees outside the rain forest, except in the editor mode where it makes those tiles rain forest tile */
+ (IsInsideMM(treetype, TREE_RAINFOREST, TREE_CACTUS) && GetTropicZone(tile) != TROPICZONE_RAINFOREST && _game_mode != GM_EDITOR) ||
+ /* And no subtropical trees in the desert/rain forest */
+ (IsInsideMM(treetype, TREE_SUB_TROPICAL, TREE_TOYLAND) && GetTropicZone(tile) != TROPICZONE_NORMAL))) {
+ msg = STR_ERROR_TREE_WRONG_TERRAIN_FOR_TREE_TYPE;
+ continue;
+ }
+
if (IsTileType(tile, MP_CLEAR)) {
/* Remove fields or rocks. Note that the ground will get barrened */
switch (GetRawClearGround(tile)) {
@@ -402,7 +415,6 @@ CommandCost CmdPlantTree(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
}
if (flags & DC_EXEC) {
- TreeType treetype = (TreeType)tree_to_plant;
if (treetype == TREE_INVALID) {
treetype = GetRandomTreeType(tile, GB(Random(), 24, 8));
if (treetype == TREE_INVALID) treetype = TREE_CACTUS;
@@ -413,11 +425,12 @@ CommandCost CmdPlantTree(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
MarkTileDirtyByTile(tile);
/* 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)) {
SetTropicZone(tile, TROPICZONE_RAINFOREST);
+ }
}
cost.AddCost(_price[PR_BUILD_TREES]);
- break;
+ } break;
default:
msg = STR_ERROR_SITE_UNSUITABLE;