diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp index ede00b2fc5..f039f3b5df 100644 --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -391,7 +391,7 @@ Foundation GetRailFoundation(Slope tileh, TrackBits bits) static CommandCost CheckRailSlope(Slope tileh, TrackBits rail_bits, TrackBits existing, TileIndex tile) { /* don't allow building on the lower side of a coast */ - if (GetFloodingBehaviour(tile) != FLOOD_NONE) { + if (GetFloodingBehaviour(tile) != FloodingBehaviour::None) { if (!IsSteepSlope(tileh) && ((~_valid_tracks_on_leveled_foundation[tileh] & (rail_bits | existing)) != 0)) return CommandCost(STR_ERROR_CAN_T_BUILD_ON_WATER); } diff --git a/src/water.h b/src/water.h index 0498844a7a..35b92091d9 100644 --- a/src/water.h +++ b/src/water.h @@ -16,11 +16,11 @@ /** * Describes the behaviour of a tile during flooding. */ -enum FloodingBehaviour : uint8_t { - FLOOD_NONE, ///< The tile does not flood neighboured tiles. - FLOOD_ACTIVE, ///< The tile floods neighboured tiles. - FLOOD_PASSIVE, ///< The tile does not actively flood neighboured tiles, but it prevents them from drying up. - FLOOD_DRYUP, ///< The tile drys up if it is not constantly flooded from neighboured tiles. +enum class FloodingBehaviour : uint8_t { + None, ///< The tile does not flood neighboured tiles. + Active, ///< The tile floods neighboured tiles. + Passive, ///< The tile does not actively flood neighboured tiles, but it prevents them from drying out. + DryOut, ///< The tile drys out if it is not constantly flooded from neighboured tiles. }; FloodingBehaviour GetFloodingBehaviour(TileIndex tile); diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp index fb9cc3c2b5..5c9be60348 100644 --- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -1139,37 +1139,37 @@ static void FloodVehicles(TileIndex tile) */ FloodingBehaviour GetFloodingBehaviour(TileIndex tile) { - /* FLOOD_ACTIVE: 'single-corner-raised'-coast, sea, sea-shipdepots, sea-buoys, sea-docks (water part), rail with flooded halftile, sea-water-industries, sea-oilrigs - * FLOOD_DRYUP: coast with more than one corner raised, coast with rail-track, coast with trees - * FLOOD_PASSIVE: (not used) - * FLOOD_NONE: canals, rivers, everything else + /* FloodingBehaviour::Active: 'single-corner-raised'-coast, sea, sea-shipdepots, sea-buoys, sea-docks (water part), rail with flooded halftile, sea-water-industries, sea-oilrigs + * FloodingBehaviour::DryOut: coast with more than one corner raised, coast with rail-track, coast with trees + * FloodingBehaviour::Passive: (not used) + * FloodingBehaviour::None: canals, rivers, everything else */ switch (GetTileType(tile)) { case TileType::Water: if (IsCoast(tile)) { Slope tileh = GetTileSlope(tile); - return (IsSlopeWithOneCornerRaised(tileh) ? FLOOD_ACTIVE : FLOOD_DRYUP); + return IsSlopeWithOneCornerRaised(tileh) ? FloodingBehaviour::Active : FloodingBehaviour::DryOut; } [[fallthrough]]; case TileType::Station: case TileType::Industry: case TileType::Object: - return (GetWaterClass(tile) == WaterClass::Sea) ? FLOOD_ACTIVE : FLOOD_NONE; + return GetWaterClass(tile) == WaterClass::Sea ? FloodingBehaviour::Active : FloodingBehaviour::None; case TileType::Railway: if (GetRailGroundType(tile) == RailGroundType::HalfTileWater) { - return (IsSlopeWithOneCornerRaised(GetTileSlope(tile)) ? FLOOD_ACTIVE : FLOOD_DRYUP); + return IsSlopeWithOneCornerRaised(GetTileSlope(tile)) ? FloodingBehaviour::Active : FloodingBehaviour::DryOut; } - return FLOOD_NONE; + return FloodingBehaviour::None; case TileType::Trees: - return (GetTreeGround(tile) == TreeGround::Shore ? FLOOD_DRYUP : FLOOD_NONE); + return GetTreeGround(tile) == TreeGround::Shore ? FloodingBehaviour::DryOut : FloodingBehaviour::None; case TileType::Void: - return FLOOD_ACTIVE; + return FloodingBehaviour::Active; default: - return FLOOD_NONE; + return FloodingBehaviour::None; } } @@ -1297,7 +1297,7 @@ void TileLoop_Water(TileIndex tile) } switch (GetFloodingBehaviour(tile)) { - case FLOOD_ACTIVE: { + case FloodingBehaviour::Active: { bool continue_flooding = false; for (Direction dir = DIR_BEGIN; dir < DIR_END; dir++) { TileIndex dest = AddTileIndexDiffCWrap(tile, TileIndexDiffCByDir(dir)); @@ -1326,7 +1326,7 @@ void TileLoop_Water(TileIndex tile) break; } - case FLOOD_DRYUP: { + case FloodingBehaviour::DryOut: { Slope slope_here = std::get(GetFoundationSlope(tile)) & ~SLOPE_HALFTILE_MASK & ~SLOPE_STEEP; for (Direction dir : _flood_from_dirs[slope_here]) { TileIndex dest = AddTileIndexDiffCWrap(tile, TileIndexDiffCByDir(dir)); @@ -1334,7 +1334,7 @@ void TileLoop_Water(TileIndex tile) if (dest == INVALID_TILE) continue; FloodingBehaviour dest_behaviour = GetFloodingBehaviour(dest); - if ((dest_behaviour == FLOOD_ACTIVE) || (dest_behaviour == FLOOD_PASSIVE)) return; + if (dest_behaviour == FloodingBehaviour::Active || dest_behaviour == FloodingBehaviour::Passive) return; } DoDryUp(tile); break;