From c5684e56ec96f530178d7e66aebb830fe6829974 Mon Sep 17 00:00:00 2001 From: frosch Date: Wed, 25 Feb 2009 21:29:50 +0000 Subject: (svn r15583) -Fix: Do not use TILE_MASK when you do not want to wrap around them map. --- src/tree_cmd.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/tree_cmd.cpp') 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); } -- cgit v1.2.3-54-g00ecf