summaryrefslogtreecommitdiff
path: root/src/tree_cmd.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2009-02-25 21:29:50 +0000
committerfrosch <frosch@openttd.org>2009-02-25 21:29:50 +0000
commitc5684e56ec96f530178d7e66aebb830fe6829974 (patch)
treeb564a00f660cd32d8c8f6fbeca4fd2642c760312 /src/tree_cmd.cpp
parentc7e324bb400d3d9fa5d1db5c0330861f366949af (diff)
downloadopenttd-c5684e56ec96f530178d7e66aebb830fe6829974.tar.xz
(svn r15583) -Fix: Do not use TILE_MASK when you do not want to wrap around them map.
Diffstat (limited to 'src/tree_cmd.cpp')
-rw-r--r--src/tree_cmd.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/tree_cmd.cpp b/src/tree_cmd.cpp
index 763eeb3c7..3eb3ae158 100644
--- a/src/tree_cmd.cpp
+++ b/src/tree_cmd.cpp
@@ -174,9 +174,9 @@ static void DoPlaceMoreTrees(TileIndex tile)
int x = GB(r, 0, 5) - 16;
int y = GB(r, 8, 5) - 16;
uint dist = abs(x) + abs(y);
- TileIndex cur_tile = TILE_MASK(tile + TileDiffXY(x, y));
+ TileIndex cur_tile = TileAddWrap(tile, x, y);
- if (dist <= 13 && CanPlantTreesOnTile(cur_tile, true)) {
+ if (cur_tile != INVALID_TILE && dist <= 13 && CanPlantTreesOnTile(cur_tile, true)) {
PlaceTree(cur_tile, r);
}
}
@@ -212,7 +212,8 @@ static void PlaceTreeAtSameHeight(TileIndex tile, uint height)
uint32 r = Random();
int x = GB(r, 0, 5) - 16;
int y = GB(r, 8, 5) - 16;
- TileIndex cur_tile = TILE_MASK(tile + TileDiffXY(x, y));
+ TileIndex cur_tile = TileAddWrap(tile, x, y);
+ if (cur_tile == INVALID_TILE) continue;
/* Keep in range of the existing tree */
if (abs(x) + abs(y) > 16) continue;
@@ -735,7 +736,7 @@ void OnTick_Trees()
/* place a tree at a random spot */
r = Random();
- tile = TILE_MASK(r);
+ tile = RandomTileSeed(r);
if (CanPlantTreesOnTile(tile, false) && (tree = GetRandomTreeType(tile, GB(r, 24, 8))) != TREE_INVALID) {
PlantTreesOnTile(tile, tree, 0, 0);
}