static void TileLoopClearDesert(TileIndex tile) { /* Current desert level - 0 if it is not desert */ uint current = 0; if (IsClearGround(tile, CLEAR_DESERT)) current = GetClearDensity(tile); /* Expected desert level - 0 if it shouldn't be desert */ uint expected = 0; if (GetTropicZone(tile) == TROPICZONE_DESERT) { expected = 3; } else if (NeighbourIsDesert(tile)) { expected = 1; } if (current == expected) return; if (expected == 0) { SetClearGroundDensity(tile, CLEAR_GRASS, 3); } else { /* Transition from clear to desert is not smooth (after clearing desert tile) */ SetClearGroundDensity(tile, CLEAR_DESERT, expected); } MarkTileDirtyByTile(tile); }
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); }
static void TileLoop_Clear(TileIndex tile) { /* If the tile is at any edge flood it to prevent maps without water. */ if (_settings_game.construction.freeform_edges && DistanceFromEdge(tile) == 1) { int z; if (IsTileFlat(tile, &z) && z == 0) { DoFloodTile(tile); MarkTileDirtyByTile(tile); return; } } AmbientSoundEffect(tile); switch (_settings_game.game_creation.landscape) { case LT_TROPIC: TileLoopClearDesert(tile); break; case LT_ARCTIC: TileLoopClearAlps(tile); break; } switch (GetClearGround(tile)) { case CLEAR_GRASS: if (GetClearDensity(tile) == 3) return; if (_game_mode != GM_EDITOR) { if (GetClearCounter(tile) < 7) { AddClearCounter(tile, 1); return; } else { SetClearCounter(tile, 0); AddClearDensity(tile, 1); } } else { SetClearGroundDensity(tile, GB(Random(), 0, 8) > 21 ? CLEAR_GRASS : CLEAR_ROUGH, 3); } break; case CLEAR_FIELDS: UpdateFences(tile); if (_game_mode == GM_EDITOR) return; if (GetClearCounter(tile) < 7) { AddClearCounter(tile, 1); return; } else { SetClearCounter(tile, 0); } if (GetIndustryIndexOfField(tile) == INVALID_INDUSTRY && GetFieldType(tile) >= 7) { /* This farmfield is no longer farmfield, so make it grass again */ MakeClear(tile, CLEAR_GRASS, 2); } else { uint field_type = GetFieldType(tile); field_type = (field_type < 8) ? field_type + 1 : 0; SetFieldType(tile, field_type); } break; default: return; } MarkTileDirtyByTile(tile); }