/** * Creates a number of tree groups. * The number of trees in each group depends on how many trees are actually placed around the given tile. * * @param num_groups Number of tree groups to place. */ static void PlaceTreeGroups(uint num_groups) { do { TileIndex center_tile = RandomTile(); for (uint i = 0; i < DEFAULT_TREE_STEPS; i++) { uint32 r = Random(); int x = GB(r, 0, 5) - 16; int y = GB(r, 8, 5) - 16; uint dist = abs(x) + abs(y); TileIndex cur_tile = TileAddWrap(center_tile, x, y); IncreaseGeneratingWorldProgress(GWP_TREE); if (cur_tile != INVALID_TILE && dist <= 13 && CanPlantTreesOnTile(cur_tile, true)) { PlaceTree(cur_tile, r); } } } while (--num_groups); }
void GenerateClearTile() { uint i, gi; TileIndex tile; /* add rough tiles */ i = ScaleByMapSize(GB(Random(), 0, 10) + 0x400); gi = ScaleByMapSize(GB(Random(), 0, 7) + 0x80); SetGeneratingWorldProgress(GWP_ROUGH_ROCKY, gi + i); do { IncreaseGeneratingWorldProgress(GWP_ROUGH_ROCKY); tile = RandomTile(); if (IsTileType(tile, MP_CLEAR) && !IsClearGround(tile, CLEAR_DESERT)) SetClearGroundDensity(tile, CLEAR_ROUGH, 3); } while (--i); /* add rocky tiles */ i = gi; do { uint32 r = Random(); tile = RandomTileSeed(r); IncreaseGeneratingWorldProgress(GWP_ROUGH_ROCKY); if (IsTileType(tile, MP_CLEAR) && !IsClearGround(tile, CLEAR_DESERT)) { uint j = GB(r, 16, 4) + 5; for (;;) { TileIndex tile_new; SetClearGroundDensity(tile, CLEAR_ROCKS, 3); do { if (--j == 0) goto get_out; tile_new = tile + TileOffsByDiagDir((DiagDirection)GB(Random(), 0, 2)); } while (!IsTileType(tile_new, MP_CLEAR) || IsClearGround(tile_new, CLEAR_DESERT)); tile = tile_new; } get_out:; } } while (--i); }