tree_cmd.c
changeset 3933 231ae3c419f4
parent 3657 eb28d97d3d18
child 3977 513433ebd092
--- a/tree_cmd.c	Thu Jun 01 22:20:40 2006 +0000
+++ b/tree_cmd.c	Fri Jun 02 13:05:41 2006 +0000
@@ -2,6 +2,7 @@
 
 #include "stdafx.h"
 #include "openttd.h"
+#include "bridge_map.h"
 #include "clear_map.h"
 #include "table/strings.h"
 #include "table/sprites.h"
@@ -68,6 +69,7 @@
 
 		if (dist <= 13 &&
 				IsTileType(cur_tile, MP_CLEAR) &&
+				!IsBridgeAbove(cur_tile) &&
 				!IsClearGround(cur_tile, CLEAR_FIELDS) &&
 				!IsClearGround(cur_tile, CLEAR_ROCKS)) {
 			PlaceTree(cur_tile, r);
@@ -92,6 +94,7 @@
 		uint32 r = Random();
 		TileIndex tile = RandomTileSeed(r);
 		if (IsTileType(tile, MP_CLEAR) &&
+				!IsBridgeAbove(tile) &&
 				!IsClearGround(tile, CLEAR_FIELDS) &&
 				!IsClearGround(tile, CLEAR_ROCKS)) {
 			PlaceTree(tile, r);
@@ -105,7 +108,9 @@
 		do {
 			uint32 r = Random();
 			TileIndex tile = RandomTileSeed(r);
-			if (IsTileType(tile, MP_CLEAR) && GetTropicZone(tile) == TROPICZONE_RAINFOREST) {
+			if (IsTileType(tile, MP_CLEAR) &&
+					!IsBridgeAbove(tile) &&
+					GetTropicZone(tile) == TROPICZONE_RAINFOREST) {
 				PlaceTree(tile, r);
 			}
 		} while (--i);
@@ -175,7 +180,8 @@
 					break;
 
 				case MP_CLEAR:
-					if (!IsTileOwner(tile, OWNER_NONE)) {
+					if (!IsTileOwner(tile, OWNER_NONE) ||
+							IsBridgeAbove(tile)) {
 						msg = STR_2804_SITE_UNSUITABLE;
 						continue;
 					}
@@ -480,7 +486,7 @@
 
 						tile += ToTileIndexDiff(_tileloop_trees_dir[Random() & 7]);
 
-						if (!IsTileType(tile, MP_CLEAR)) return;
+						if (!IsTileType(tile, MP_CLEAR) || IsBridgeAbove(tile)) return;
 
 						switch (GetClearGround(tile)) {
 							case CLEAR_GRASS:
@@ -513,6 +519,7 @@
 					case TREE_GROUND_ROUGH: MakeClear(tile, CLEAR_ROUGH, 3); break;
 					default: MakeClear(tile, CLEAR_SNOW, GetTreeDensity(tile)); break;
 				}
+				ClearBridgeMiddle(tile);
 			}
 			break;
 
@@ -535,6 +542,7 @@
 	if (_opt.landscape == LT_DESERT &&
 			(r = Random(), tile = RandomTileSeed(r), GetTropicZone(tile) == TROPICZONE_RAINFOREST) &&
 			IsTileType(tile, MP_CLEAR) &&
+			!IsBridgeAbove(tile) &&
 			(ct = GetClearGround(tile), ct == CLEAR_GRASS || ct == CLEAR_ROUGH) &&
 			(tree = GetRandomTreeType(tile, GB(r, 24, 8))) != TREE_INVALID) {
 		MakeTree(tile, tree, 0, 0, ct == CLEAR_ROUGH ? TREE_GROUND_ROUGH : TREE_GROUND_GRASS, 0);
@@ -547,6 +555,7 @@
 	r = Random();
 	tile = TILE_MASK(r);
 	if (IsTileType(tile, MP_CLEAR) &&
+			!IsBridgeAbove(tile) &&
 			(ct = GetClearGround(tile), ct == CLEAR_GRASS || ct == CLEAR_ROUGH || ct == CLEAR_SNOW) &&
 			(tree = GetRandomTreeType(tile, GB(r, 24, 8))) != TREE_INVALID) {
 		switch (ct) {