diff --git a/src/clear_cmd.cpp b/src/clear_cmd.cpp index d99c905362..a47cda5181 100644 --- a/src/clear_cmd.cpp +++ b/src/clear_cmd.cpp @@ -38,11 +38,11 @@ static CommandCost ClearTile_Clear(TileIndex tile, DoCommandFlags flags) ClearGround ground = GetClearGround(tile); uint8_t density = GetClearDensity(tile); if (IsSnowTile(tile)) { - price.AddCost(_price[clear_price_table[ground]]); + price.AddCost(_price[clear_price_table[to_underlying(ground)]]); /* Add a little more for removing snow. */ price.AddCost(std::abs(_price[Price::ClearRough] - _price[Price::ClearGrass])); - } else if (ground != CLEAR_GRASS || density != 0) { - price.AddCost(_price[clear_price_table[ground]]); + } else if (ground != ClearGround::Grass || density != 0) { + price.AddCost(_price[clear_price_table[to_underlying(ground)]]); } if (flags.Test(DoCommandFlag::Execute)) DoClearSquare(tile); @@ -118,7 +118,7 @@ static void DrawTile_Clear(TileInfo *ti) if (IsSnowTile(ti->tile)) { uint8_t density = GetClearDensity(ti->tile); DrawGroundSprite(_clear_land_sprites_snow_desert[density] + SlopeToSpriteOffset(ti->tileh), PAL_NONE); - if (GetClearGround(ti->tile) == CLEAR_ROCKS) { + if (GetClearGround(ti->tile) == ClearGround::Rocks) { /* There 4 levels of snowy overlay rocks, each with 19 sprites. */ ++density; DrawGroundSprite(SPR_OVERLAY_ROCKS_BASE + (density * 19) + SlopeToSpriteOffset(ti->tileh), PAL_NONE); @@ -129,15 +129,15 @@ static void DrawTile_Clear(TileInfo *ti) } switch (GetClearGround(ti->tile)) { - case CLEAR_GRASS: + case ClearGround::Grass: DrawClearLandTile(ti, GetClearDensity(ti->tile)); break; - case CLEAR_ROUGH: + case ClearGround::Rough: DrawHillyLandTile(ti); break; - case CLEAR_ROCKS: + case ClearGround::Rocks: if (GetTropicZone(ti->tile) == TROPICZONE_DESERT) { DrawGroundSprite(_clear_land_sprites_snow_desert[GetClearDensity(ti->tile)] + SlopeToSpriteOffset(ti->tileh), PAL_NONE); DrawGroundSprite(SPR_OVERLAY_ROCKS_BASE + SlopeToSpriteOffset(ti->tileh), PAL_NONE); @@ -146,12 +146,12 @@ static void DrawTile_Clear(TileInfo *ti) } break; - case CLEAR_FIELDS: + case ClearGround::Fields: DrawGroundSprite(_clear_land_sprites_farmland[GetFieldType(ti->tile)] + SlopeToSpriteOffset(ti->tileh), PAL_NONE); DrawClearLandFence(ti); break; - case CLEAR_DESERT: + case ClearGround::Desert: DrawGroundSprite(_clear_land_sprites_snow_desert[GetClearDensity(ti->tile)] + SlopeToSpriteOffset(ti->tileh), PAL_NONE); break; } @@ -173,13 +173,13 @@ static Foundation GetFoundation_Clear(TileIndex, Slope) static void UpdateFences(TileIndex tile) { - assert(IsTileType(tile, TileType::Clear) && IsClearGround(tile, CLEAR_FIELDS)); + assert(IsTileType(tile, TileType::Clear) && IsClearGround(tile, ClearGround::Fields)); bool dirty = false; for (DiagDirection dir = DIAGDIR_BEGIN; dir < DIAGDIR_END; dir++) { if (GetFence(tile, dir) != 0) continue; TileIndex neighbour = tile + TileOffsByDiagDir(dir); - if (IsTileType(neighbour, TileType::Clear) && IsClearGround(neighbour, CLEAR_FIELDS)) continue; + if (IsTileType(neighbour, TileType::Clear) && IsClearGround(neighbour, ClearGround::Fields)) continue; SetFence(tile, dir, 3); dirty = true; } @@ -241,7 +241,7 @@ static void TileLoopClearDesert(TileIndex tile) /* Current desert level - 0 if it is not desert */ uint current = 0; - if (ground == CLEAR_DESERT || ground == CLEAR_ROCKS) current = GetClearDensity(tile); + if (ground == ClearGround::Desert || ground == ClearGround::Rocks) current = GetClearDensity(tile); /* Expected desert level - 0 if it shouldn't be desert */ uint expected = 0; @@ -251,13 +251,13 @@ static void TileLoopClearDesert(TileIndex tile) if (current == expected) return; - if (ground == CLEAR_ROCKS) { - SetClearGroundDensity(tile, CLEAR_ROCKS, expected); + if (ground == ClearGround::Rocks) { + SetClearGroundDensity(tile, ClearGround::Rocks, expected); } else if (expected == 0) { - SetClearGroundDensity(tile, CLEAR_GRASS, 3); + SetClearGroundDensity(tile, ClearGround::Grass, 3); } else { /* Transition from clear to desert is not smooth (after clearing desert tile) */ - SetClearGroundDensity(tile, CLEAR_DESERT, expected); + SetClearGroundDensity(tile, ClearGround::Desert, expected); } MarkTileDirtyByTile(tile); @@ -276,7 +276,7 @@ static void TileLoop_Clear(TileIndex tile) if (IsSnowTile(tile)) return; switch (GetClearGround(tile)) { - case CLEAR_GRASS: + case ClearGround::Grass: if (GetClearDensity(tile) == 3) return; if (_game_mode != GM_EDITOR) { @@ -288,11 +288,11 @@ static void TileLoop_Clear(TileIndex tile) AddClearDensity(tile, 1); } } else { - SetClearGroundDensity(tile, GB(Random(), 0, 8) > 21 ? CLEAR_GRASS : CLEAR_ROUGH, 3); + SetClearGroundDensity(tile, GB(Random(), 0, 8) > 21 ? ClearGround::Grass : ClearGround::Rough, 3); } break; - case CLEAR_FIELDS: + case ClearGround::Fields: UpdateFences(tile); if (_game_mode == GM_EDITOR) return; @@ -306,7 +306,7 @@ static void TileLoop_Clear(TileIndex tile) if (GetIndustryIndexOfField(tile) == IndustryID::Invalid() && GetFieldType(tile) >= 7) { /* This farmfield is no longer farmfield, so make it grass again */ - MakeClear(tile, CLEAR_GRASS, 2); + MakeClear(tile, ClearGround::Grass, 2); } else { uint field_type = GetFieldType(tile); field_type = (field_type < 8) ? field_type + 1 : 0; @@ -334,7 +334,7 @@ void GenerateClearTile() do { IncreaseGeneratingWorldProgress(GWP_ROUGH_ROCKY); tile = RandomTile(); - if (IsTileType(tile, TileType::Clear) && !IsClearGround(tile, CLEAR_DESERT)) SetClearGroundDensity(tile, CLEAR_ROUGH, 3); + if (IsTileType(tile, TileType::Clear) && !IsClearGround(tile, ClearGround::Desert)) SetClearGroundDensity(tile, ClearGround::Rough, 3); } while (--i); /* add rocky tiles */ @@ -349,7 +349,7 @@ void GenerateClearTile() for (;;) { TileIndex tile_new; - SetClearGroundDensity(tile, CLEAR_ROCKS, 3); + SetClearGroundDensity(tile, ClearGround::Rocks, 3); MarkTileDirtyByTile(tile); do { if (--j == 0) goto get_out; @@ -379,10 +379,10 @@ static void GetTileDesc_Clear(TileIndex tile, TileDesc &td) {STR_LAI_CLEAR_DESCRIPTION_DESERT, STR_EMPTY}, }; - if (!IsSnowTile(tile) && IsClearGround(tile, CLEAR_GRASS) && GetClearDensity(tile) == 0) { + if (!IsSnowTile(tile) && IsClearGround(tile, ClearGround::Grass) && GetClearDensity(tile) == 0) { td.str = STR_LAI_CLEAR_DESCRIPTION_BARE_LAND; } else { - const auto &[name, snowy_name] = clear_land_str[GetClearGround(tile)]; + const auto &[name, snowy_name] = clear_land_str[to_underlying(GetClearGround(tile))]; td.str = IsSnowTile(tile) ? snowy_name : name; } td.owner[0] = GetTileOwner(tile); diff --git a/src/clear_map.h b/src/clear_map.h index 6aacf67821..5bc6d1df86 100644 --- a/src/clear_map.h +++ b/src/clear_map.h @@ -16,12 +16,12 @@ /** * Ground types. Valid densities in comments after the enum. */ -enum ClearGround : uint8_t { - CLEAR_GRASS = 0, ///< 0-3 - CLEAR_ROUGH = 1, ///< 3 - CLEAR_ROCKS = 2, ///< 3 - CLEAR_FIELDS = 3, ///< 3 - CLEAR_DESERT = 5, ///< 1,3 +enum class ClearGround : uint8_t { + Grass = 0, ///< Plain grass with dirt transition (0-3) + Rough = 1, ///< Rough mounds (3) + Rocks = 2, ///< Rocks with snow transition (0-3) + Fields = 3, ///< Farm fields (3) + Desert = 5, ///< Desert with transition (1,3) }; @@ -145,19 +145,19 @@ inline void SetClearCounter(Tile t, uint c) inline void SetClearGroundDensity(Tile t, ClearGround type, uint density) { assert(IsTileType(t, TileType::Clear)); // XXX incomplete - t.m5() = 0 << 5 | type << 2 | density; + t.m5() = 0 << 5 | to_underlying(type) << 2 | density; } /** * Get the field type (production stage) of the field * @param t the field to get the type of - * @pre GetClearGround(t) == CLEAR_FIELDS + * @pre GetClearGround(t) == ClearGround::Fields * @return the field type */ inline uint GetFieldType(Tile t) { - assert(GetClearGround(t) == CLEAR_FIELDS); + assert(GetClearGround(t) == ClearGround::Fields); return GB(t.m3(), 0, 4); } @@ -165,23 +165,23 @@ inline uint GetFieldType(Tile t) * Set the field type (production stage) of the field * @param t the field to get the type of * @param f the field type - * @pre GetClearGround(t) == CLEAR_FIELDS + * @pre GetClearGround(t) == ClearGround::Fields */ inline void SetFieldType(Tile t, uint f) { - assert(GetClearGround(t) == CLEAR_FIELDS); // XXX incomplete + assert(GetClearGround(t) == ClearGround::Fields); // XXX incomplete SB(t.m3(), 0, 4, f); } /** * Get the industry (farm) that made the field * @param t the field to get creating industry of - * @pre GetClearGround(t) == CLEAR_FIELDS + * @pre GetClearGround(t) == ClearGround::Fields * @return the industry that made the field */ inline IndustryID GetIndustryIndexOfField(Tile t) { - assert(GetClearGround(t) == CLEAR_FIELDS); + assert(GetClearGround(t) == ClearGround::Fields); return(IndustryID) t.m2(); } @@ -189,11 +189,11 @@ inline IndustryID GetIndustryIndexOfField(Tile t) * Set the industry (farm) that made the field * @param t the field to get creating industry of * @param i the industry that made the field - * @pre GetClearGround(t) == CLEAR_FIELDS + * @pre GetClearGround(t) == ClearGround::Fields */ inline void SetIndustryIndexOfField(Tile t, IndustryID i) { - assert(GetClearGround(t) == CLEAR_FIELDS); + assert(GetClearGround(t) == ClearGround::Fields); t.m2() = i.base(); } @@ -202,12 +202,12 @@ inline void SetIndustryIndexOfField(Tile t, IndustryID i) * Is there a fence at the given border? * @param t the tile to check for fences * @param side the border to check - * @pre IsClearGround(t, CLEAR_FIELDS) + * @pre IsClearGround(t, ClearGround::Fields) * @return 0 if there is no fence, otherwise the fence type */ inline uint GetFence(Tile t, DiagDirection side) { - assert(IsClearGround(t, CLEAR_FIELDS)); + assert(IsClearGround(t, ClearGround::Fields)); switch (side) { default: NOT_REACHED(); case DIAGDIR_SE: return GB(t.m4(), 2, 3); @@ -222,11 +222,11 @@ inline uint GetFence(Tile t, DiagDirection side) * @param t the tile to check for fences * @param side the border to check * @param h 0 if there is no fence, otherwise the fence type - * @pre IsClearGround(t, CLEAR_FIELDS) + * @pre IsClearGround(t, ClearGround::Fields) */ inline void SetFence(Tile t, DiagDirection side, uint h) { - assert(IsClearGround(t, CLEAR_FIELDS)); + assert(IsClearGround(t, ClearGround::Fields)); switch (side) { default: NOT_REACHED(); case DIAGDIR_SE: SB(t.m4(), 2, 3, h); break; @@ -272,7 +272,7 @@ inline void MakeField(Tile t, uint field_type, IndustryID industry) t.m2() = industry.base(); t.m3() = field_type; t.m4() = 0 << 5 | 0 << 2; - SetClearGroundDensity(t, CLEAR_FIELDS, 3); + SetClearGroundDensity(t, ClearGround::Fields, 3); SB(t.m6(), 2, 6, 0); t.m7() = 0; t.m8() = 0; @@ -288,8 +288,8 @@ inline void MakeSnow(Tile t, uint density = 0) { assert(!IsSnowTile(t)); SetBit(t.m3(), 4); - if (GetClearGround(t) == CLEAR_FIELDS) { - SetClearGroundDensity(t, CLEAR_GRASS, density); + if (GetClearGround(t) == ClearGround::Fields) { + SetClearGroundDensity(t, ClearGround::Grass, density); } else { SetClearDensity(t, density); } diff --git a/src/heightmap.cpp b/src/heightmap.cpp index dda810bac5..24b83c96b2 100644 --- a/src/heightmap.cpp +++ b/src/heightmap.cpp @@ -390,7 +390,7 @@ static void GreyscaleToMapHeights(uint img_width, uint img_height, std::spanindex) { SetIndustryIndexOfField(tile_cur, IndustryID::Invalid()); } @@ -1004,9 +1004,9 @@ static bool IsSuitableForFarmField(TileIndex tile, bool allow_fields, bool allow case TileType::Clear: if (IsSnowTile(tile)) return false; switch (GetClearGround(tile)) { - case CLEAR_DESERT: return false; - case CLEAR_ROUGH: return allow_rough; - case CLEAR_FIELDS: return allow_fields; + case ClearGround::Desert: return false; + case ClearGround::Rough: return allow_rough; + case ClearGround::Fields: return allow_fields; default: return true; } case TileType::Trees: return GetTreeGround(tile) != TREE_GROUND_SHORE && (allow_rough || GetTreeGround(tile) != TREE_GROUND_ROUGH); @@ -1029,9 +1029,9 @@ static void SetupFarmFieldFence(TileIndex tile, int size, uint8_t type, DiagDire do { tile = Map::WrapToMap(tile); - if (IsTileType(tile, TileType::Clear) && IsClearGround(tile, CLEAR_FIELDS)) { + if (IsTileType(tile, TileType::Clear) && IsClearGround(tile, ClearGround::Fields)) { TileIndex neighbour = tile + neighbour_diff; - if (!IsTileType(neighbour, TileType::Clear) || !IsClearGround(neighbour, CLEAR_FIELDS) || GetFence(neighbour, ReverseDiagDir(side)) == 0) { + if (!IsTileType(neighbour, TileType::Clear) || !IsClearGround(neighbour, ClearGround::Fields) || GetFence(neighbour, ReverseDiagDir(side)) == 0) { /* Add fence as long as neighbouring tile does not already have a fence in the same position. */ uint8_t or_ = type; diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index a2ed6da366..8190d04e99 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -618,8 +618,8 @@ public: /* Clear farmland. */ for (const auto tile : Map::Iterate()) { - if (IsTileType(tile, TileType::Clear) && GetClearGround(tile) == CLEAR_FIELDS) { - MakeClear(tile, CLEAR_GRASS, 3); + if (IsTileType(tile, TileType::Clear) && GetClearGround(tile) == ClearGround::Fields) { + MakeClear(tile, ClearGround::Grass, 3); } } diff --git a/src/landscape.cpp b/src/landscape.cpp index 08687a2596..9b2e7bdda4 100644 --- a/src/landscape.cpp +++ b/src/landscape.cpp @@ -545,7 +545,7 @@ void DoClearSquare(TileIndex tile) if (MayAnimateTile(tile)) DeleteAnimatedTile(tile, true); bool remove = IsDockingTile(tile); - MakeClear(tile, CLEAR_GRASS, _generating_world ? 3 : 0); + MakeClear(tile, ClearGround::Grass, _generating_world ? 3 : 0); MarkTileDirtyByTile(tile); if (remove) RemoveDockingTile(tile); @@ -845,7 +845,7 @@ void InitializeLandscape() { for (uint y = _settings_game.construction.freeform_edges ? 1 : 0; y < Map::MaxY(); y++) { for (uint x = _settings_game.construction.freeform_edges ? 1 : 0; x < Map::MaxX(); x++) { - MakeClear(TileXY(x, y), CLEAR_GRASS, 3); + MakeClear(TileXY(x, y), ClearGround::Grass, 3); SetTileHeight(TileXY(x, y), 0); SetTropicZone(TileXY(x, y), TROPICZONE_NORMAL); ClearBridgeMiddle(TileXY(x, y)); @@ -1012,7 +1012,7 @@ static void CreateDesertOrRainForest(uint desert_tropic_line) auto allows_rainforest = [tile](auto &offset) { TileIndex t = AddTileIndexDiffCWrap(tile, offset); - return t == INVALID_TILE || !IsTileType(t, TileType::Clear) || !IsClearGround(t, CLEAR_DESERT); + return t == INVALID_TILE || !IsTileType(t, TileType::Clear) || !IsClearGround(t, ClearGround::Desert); }; if (std::all_of(std::begin(_make_desert_or_rainforest_data), std::end(_make_desert_or_rainforest_data), allows_rainforest)) { SetTropicZone(tile, TROPICZONE_RAINFOREST); @@ -1128,7 +1128,7 @@ static void MakeWetlands(TileIndex centre, uint height, uint river_length) MakeRiverAndModifyDesertZoneAround(tile); } else if (IsTileType(tile, TileType::Clear)) { /* This tile is ground, which we always make rough. */ - SetClearGroundDensity(tile, CLEAR_ROUGH, 3); + SetClearGroundDensity(tile, ClearGround::Rough, 3); /* Maybe place trees? */ if (has_trees && _settings_game.game_creation.tree_placer != TreePlacer::None) { PlaceTree(tile, Random(), true); diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index 2513a79b32..f701a2585b 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -465,7 +465,7 @@ static void FixOwnerOfRailTrack(Tile t) } /* if it's not a crossing, make it clean land */ - MakeClear(t, CLEAR_GRASS, 0); + MakeClear(t, ClearGround::Grass, 0); } /** @@ -1252,7 +1252,7 @@ bool AfterLoadGame() } } else { if (GB(t.m5(), 3, 2) == 0) { - MakeClear(t, CLEAR_GRASS, 3); + MakeClear(t, ClearGround::Grass, 3); } else { if (!IsTileFlat(t)) { MakeShore(t); @@ -1477,9 +1477,9 @@ bool AfterLoadGame() * plant new ones. */ if (IsSavegameVersionBefore(SLV_32)) { for (const auto t : Map::Iterate()) { - if (IsTileType(t, TileType::Clear) && IsClearGround(t, CLEAR_FIELDS)) { + if (IsTileType(t, TileType::Clear) && IsClearGround(t, ClearGround::Fields)) { /* remove fields */ - MakeClear(t, CLEAR_GRASS, 3); + MakeClear(t, ClearGround::Grass, 3); } } @@ -2434,8 +2434,8 @@ bool AfterLoadGame() if (IsSavegameVersionBefore(SLV_135)) { for (auto t : Map::Iterate()) { if (IsTileType(t, TileType::Clear)) { - if (GetClearGround(t) == ClearGround{4}) { // CLEAR_SNOW becomes CLEAR_GRASS with IsSnowTile() set. - SetClearGroundDensity(t, CLEAR_GRASS, GetClearDensity(t)); + if (GetClearGround(t) == ClearGround{4}) { // CLEAR_SNOW becomes ClearGround::Grass with IsSnowTile() set. + SetClearGroundDensity(t, ClearGround::Grass, GetClearDensity(t)); SetBit(t.m3(), 4); } else { ClrBit(t.m3(), 4); @@ -2915,13 +2915,13 @@ bool AfterLoadGame() /* We store 4 fences in the field tiles instead of only SE and SW. */ for (auto t : Map::Iterate()) { if (!IsTileType(t, TileType::Clear) && !IsTileType(t, TileType::Trees)) continue; - if (IsTileType(t, TileType::Clear) && IsClearGround(t, CLEAR_FIELDS)) continue; + if (IsTileType(t, TileType::Clear) && IsClearGround(t, ClearGround::Fields)) continue; uint fence = GB(t.m4(), 5, 3); - if (fence != 0 && IsTileType(TileAddXY(t, 1, 0), TileType::Clear) && IsClearGround(TileAddXY(t, 1, 0), CLEAR_FIELDS)) { + if (fence != 0 && IsTileType(TileAddXY(t, 1, 0), TileType::Clear) && IsClearGround(TileAddXY(t, 1, 0), ClearGround::Fields)) { SetFence(TileAddXY(t, 1, 0), DIAGDIR_NE, fence); } fence = GB(t.m4(), 2, 3); - if (fence != 0 && IsTileType(TileAddXY(t, 0, 1), TileType::Clear) && IsClearGround(TileAddXY(t, 0, 1), CLEAR_FIELDS)) { + if (fence != 0 && IsTileType(TileAddXY(t, 0, 1), TileType::Clear) && IsClearGround(TileAddXY(t, 0, 1), ClearGround::Fields)) { SetFence(TileAddXY(t, 0, 1), DIAGDIR_NW, fence); } SB(t.m4(), 2, 3, 0); diff --git a/src/script/api/script_tile.cpp b/src/script/api/script_tile.cpp index 21b5129ff0..2c85173da9 100644 --- a/src/script/api/script_tile.cpp +++ b/src/script/api/script_tile.cpp @@ -123,21 +123,21 @@ { if (!::IsValidTile(tile)) return false; - return (::IsTileType(tile, TileType::Clear) && ::IsClearGround(tile, CLEAR_FIELDS)); + return (::IsTileType(tile, TileType::Clear) && ::IsClearGround(tile, ClearGround::Fields)); } /* static */ bool ScriptTile::IsRockTile(TileIndex tile) { if (!::IsValidTile(tile)) return false; - return (::IsTileType(tile, TileType::Clear) && ::GetClearGround(tile) == ::CLEAR_ROCKS); + return (::IsTileType(tile, TileType::Clear) && ::GetClearGround(tile) == ::ClearGround::Rocks); } /* static */ bool ScriptTile::IsRoughTile(TileIndex tile) { if (!::IsValidTile(tile)) return false; - return (::IsTileType(tile, TileType::Clear) && ::GetClearGround(tile) == ::CLEAR_ROUGH); + return (::IsTileType(tile, TileType::Clear) && ::GetClearGround(tile) == ::ClearGround::Rough); } /* static */ bool ScriptTile::IsSnowTile(TileIndex tile) @@ -151,7 +151,7 @@ { if (!::IsValidTile(tile)) return false; - return (::IsTileType(tile, TileType::Clear) && ::IsClearGround(tile, CLEAR_DESERT)); + return (::IsTileType(tile, TileType::Clear) && ::IsClearGround(tile, ClearGround::Desert)); } /* static */ bool ScriptTile::IsHouseTile(TileIndex tile) diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp index b604c405c8..19b645a076 100644 --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -549,11 +549,11 @@ static inline uint32_t GetSmallMapVegetationPixels(TileIndex tile, TileType t) switch (t) { case TileType::Clear: if (IsSnowTile(tile)) return MKCOLOUR_XXXX(PC_LIGHT_BLUE); - if (IsClearGround(tile, CLEAR_GRASS)) { + if (IsClearGround(tile, ClearGround::Grass)) { if (GetClearDensity(tile) < 3) return MKCOLOUR_XXXX(PC_BARE_LAND); if (GetTropicZone(tile) == TROPICZONE_RAINFOREST) return MKCOLOUR_XXXX(PC_RAINFOREST); } - return _vegetation_clear_bits[GetClearGround(tile)]; + return _vegetation_clear_bits[to_underlying(GetClearGround(tile))]; case TileType::Industry: return IsTileForestIndustry(tile) ? MKCOLOUR_XXXX(PC_GREEN) : MKCOLOUR_XXXX(PC_DARK_RED); diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp index 37ababbb1d..9b8f6a38dd 100644 --- a/src/terraform_gui.cpp +++ b/src/terraform_gui.cpp @@ -87,7 +87,7 @@ static void GenerateRockyArea(TileIndex end, TileIndex start) [[fallthrough]]; case TileType::Clear: - MakeClear(tile, CLEAR_ROCKS, 3); + MakeClear(tile, ClearGround::Rocks, 3); break; default: diff --git a/src/tgp.cpp b/src/tgp.cpp index a48147a910..5b4894daed 100644 --- a/src/tgp.cpp +++ b/src/tgp.cpp @@ -1002,7 +1002,7 @@ static void TgenSetTileHeight(TileIndex tile, int height) /* Only clear the tiles within the map area. */ if (IsInnerTile(tile)) { - MakeClear(tile, CLEAR_GRASS, 3); + MakeClear(tile, ClearGround::Grass, 3); } } diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index 8e4ac627b7..7e6b1ff456 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -2151,7 +2151,7 @@ static CommandCost TownCanBePlacedHere(TileIndex tile, bool check_surrounding) switch (GetTileType(t)) { case TileType::Clear: /* Don't allow rough tiles, as they are likely wetlands. */ - if (GetClearGround(t) == CLEAR_ROUGH) continue; + if (GetClearGround(t) == ClearGround::Rough) continue; break; case TileType::Trees: diff --git a/src/tree_cmd.cpp b/src/tree_cmd.cpp index 8609edc002..e814b6051a 100644 --- a/src/tree_cmd.cpp +++ b/src/tree_cmd.cpp @@ -53,7 +53,7 @@ static const uint16_t EDITOR_TREE_DIV = 5; ///< Game editor tr * This is true for clear ground without farms or rocks. * * @param tile the tile of interest - * @param allow_desert Allow planting trees on CLEAR_DESERT? + * @param allow_desert Allow planting trees on ClearGround::Desert? * @return true if trees can be built. */ static bool CanPlantTreesOnTile(TileIndex tile, bool allow_desert) @@ -63,8 +63,8 @@ static bool CanPlantTreesOnTile(TileIndex tile, bool allow_desert) return !IsBridgeAbove(tile) && IsCoast(tile) && !IsSlopeWithOneCornerRaised(GetTileSlope(tile)); case TileType::Clear: - return !IsBridgeAbove(tile) && !IsClearGround(tile, CLEAR_FIELDS) && !IsClearGround(tile, CLEAR_ROCKS) && - (allow_desert || !IsClearGround(tile, CLEAR_DESERT)); + return !IsBridgeAbove(tile) && !IsClearGround(tile, ClearGround::Fields) && !IsClearGround(tile, ClearGround::Rocks) && + (allow_desert || !IsClearGround(tile, ClearGround::Desert)); default: return false; } @@ -98,15 +98,15 @@ static void PlantTreesOnTile(TileIndex tile, TreeType treetype, uint count, Tree case TileType::Clear: { ClearGround clearground = GetClearGround(tile); if (IsSnowTile(tile)) { - ground = clearground == CLEAR_ROUGH ? TREE_GROUND_ROUGH_SNOW : TREE_GROUND_SNOW_DESERT; + ground = clearground == ClearGround::Rough ? TREE_GROUND_ROUGH_SNOW : TREE_GROUND_SNOW_DESERT; } else { switch (clearground) { - case CLEAR_GRASS: ground = TREE_GROUND_GRASS; break; - case CLEAR_ROUGH: ground = TREE_GROUND_ROUGH; break; + case ClearGround::Grass: ground = TREE_GROUND_GRASS; break; + case ClearGround::Rough: ground = TREE_GROUND_ROUGH; break; default: ground = TREE_GROUND_SNOW_DESERT; break; } } - if (clearground != CLEAR_ROUGH) density = GetClearDensity(tile); + if (clearground != ClearGround::Rough) density = GetClearDensity(tile); break; } @@ -574,8 +574,8 @@ CommandCost CmdPlantTree(DoCommandFlags flags, TileIndex tile, TileIndex start_t if (IsTileType(current_tile, TileType::Clear)) { /* Remove fields or rocks. Note that the ground will get barrened */ switch (GetClearGround(current_tile)) { - case CLEAR_FIELDS: - case CLEAR_ROCKS: { + case ClearGround::Fields: + case ClearGround::Rocks: { CommandCost ret = Command::Do(flags, current_tile); if (ret.Failed()) return ret; cost.AddCost(ret.GetCost()); @@ -891,7 +891,7 @@ static void TileLoop_Trees(TileIndex tile) if (!CanPlantTreesOnTile(tile, false)) return; /* Don't plant trees, if ground was freshly cleared */ - if (IsTileType(tile, TileType::Clear) && GetClearGround(tile) == CLEAR_GRASS && !IsSnowTile(tile) && GetClearDensity(tile) != 3) return; + if (IsTileType(tile, TileType::Clear) && GetClearGround(tile) == ClearGround::Grass && !IsSnowTile(tile) && GetClearDensity(tile) != 3) return; PlantTreesOnTile(tile, treetype, 0, TreeGrowthStage::Growing1); @@ -916,20 +916,20 @@ static void TileLoop_Trees(TileIndex tile) /* just one tree, change type into TileType::Clear */ switch (GetTreeGround(tile)) { case TREE_GROUND_SHORE: MakeShore(tile); break; - case TREE_GROUND_GRASS: MakeClear(tile, CLEAR_GRASS, GetTreeDensity(tile)); break; - case TREE_GROUND_ROUGH: MakeClear(tile, CLEAR_ROUGH, 3); break; + case TREE_GROUND_GRASS: MakeClear(tile, ClearGround::Grass, GetTreeDensity(tile)); break; + case TREE_GROUND_ROUGH: MakeClear(tile, ClearGround::Rough, 3); break; case TREE_GROUND_ROUGH_SNOW: { uint density = GetTreeDensity(tile); - MakeClear(tile, CLEAR_ROUGH, 3); + MakeClear(tile, ClearGround::Rough, 3); MakeSnow(tile, density); break; } default: // snow or desert if (_settings_game.game_creation.landscape == LandscapeType::Tropic) { - MakeClear(tile, CLEAR_DESERT, GetTreeDensity(tile)); + MakeClear(tile, ClearGround::Desert, GetTreeDensity(tile)); } else { uint density = GetTreeDensity(tile); - MakeClear(tile, CLEAR_GRASS, 3); + MakeClear(tile, ClearGround::Grass, 3); MakeSnow(tile, density); } break; diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp index 0565ecb61b..ab7585df2c 100644 --- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -1260,7 +1260,7 @@ static void DoDryUp(TileIndex tile) assert(IsCoast(tile)); if (Command::Do(DoCommandFlag::Execute, tile).Succeeded()) { - MakeClear(tile, CLEAR_GRASS, 3); + MakeClear(tile, ClearGround::Grass, 3); MarkTileDirtyByTile(tile); } break;