diff options
author | frosch <frosch@openttd.org> | 2008-04-02 14:13:15 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2008-04-02 14:13:15 +0000 |
commit | fa68e5f77026835b02e1dc3d8eef09b57aac8249 (patch) | |
tree | 1c88a7fa03add5b3c621da72df5f777b12fdd26c /src | |
parent | 5e5e074a5dc68ed495de3234fda15989db34e23d (diff) | |
download | openttd-fa68e5f77026835b02e1dc3d8eef09b57aac8249.tar.xz |
(svn r12541) -Codechange: Declare Slope enum as bit set, and remove some (then) unneeded casts.
Diffstat (limited to 'src')
-rw-r--r-- | src/slope_func.h | 6 | ||||
-rw-r--r-- | src/slope_type.h | 1 | ||||
-rw-r--r-- | src/terraform_cmd.cpp | 12 | ||||
-rw-r--r-- | src/water_cmd.cpp | 6 |
4 files changed, 13 insertions, 12 deletions
diff --git a/src/slope_func.h b/src/slope_func.h index 6185d44d7..7bfa5e52d 100644 --- a/src/slope_func.h +++ b/src/slope_func.h @@ -54,7 +54,7 @@ static inline bool IsHalftileSlope(Slope s) */ static inline Slope RemoveHalftileSlope(Slope s) { - return (Slope)(s & ~SLOPE_HALFTILE_MASK); + return s & ~SLOPE_HALFTILE_MASK; } /** @@ -71,7 +71,7 @@ static inline Slope RemoveHalftileSlope(Slope s) static inline Slope ComplementSlope(Slope s) { assert(!IsSteepSlope(s) && !IsHalftileSlope(s)); - return (Slope)(0xF ^ s); + return s ^ SLOPE_ELEVATED; } /** @@ -200,7 +200,7 @@ static inline Slope SlopeWithThreeCornersRaised(Corner corner) */ static inline Slope SteepSlope(Corner corner) { - return (Slope)(SLOPE_STEEP | SlopeWithThreeCornersRaised(OppositeCorner(corner))); + return SLOPE_STEEP | SlopeWithThreeCornersRaised(OppositeCorner(corner)); } /** diff --git a/src/slope_type.h b/src/slope_type.h index a61a09182..2ba12bf38 100644 --- a/src/slope_type.h +++ b/src/slope_type.h @@ -70,6 +70,7 @@ enum Slope { SLOPE_HALFTILE_E = SLOPE_HALFTILE | (CORNER_E << 6), ///< the east halftile is leveled (non continuous slope) SLOPE_HALFTILE_N = SLOPE_HALFTILE | (CORNER_N << 6), ///< the north halftile is leveled (non continuous slope) }; +DECLARE_ENUM_AS_BIT_SET(Slope) /** diff --git a/src/terraform_cmd.cpp b/src/terraform_cmd.cpp index 27c8eb481..5e7e486b5 100644 --- a/src/terraform_cmd.cpp +++ b/src/terraform_cmd.cpp @@ -287,11 +287,11 @@ CommandCost CmdTerraformLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) uint z_max = max(max(z_N, z_W), max(z_S, z_E)); /* Compute tile slope */ - uint tileh = (z_max > z_min + 1 ? SLOPE_STEEP : SLOPE_FLAT); - if (z_W > z_min) tileh += SLOPE_W; - if (z_S > z_min) tileh += SLOPE_S; - if (z_E > z_min) tileh += SLOPE_E; - if (z_N > z_min) tileh += SLOPE_N; + Slope tileh = (z_max > z_min + 1 ? SLOPE_STEEP : SLOPE_FLAT); + if (z_W > z_min) tileh |= SLOPE_W; + if (z_S > z_min) tileh |= SLOPE_S; + if (z_E > z_min) tileh |= SLOPE_E; + if (z_N > z_min) tileh |= SLOPE_N; /* Check if bridge would take damage */ if (direction == 1 && MayHaveBridgeAbove(tile) && IsBridgeAbove(tile) && @@ -305,7 +305,7 @@ CommandCost CmdTerraformLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) return_cmd_error(STR_1002_EXCAVATION_WOULD_DAMAGE); } /* Check tiletype-specific things, and add extra-cost */ - CommandCost cost = _tile_type_procs[GetTileType(tile)]->terraform_tile_proc(tile, flags | DC_AUTO, z_min * TILE_HEIGHT, (Slope) tileh); + CommandCost cost = _tile_type_procs[GetTileType(tile)]->terraform_tile_proc(tile, flags | DC_AUTO, z_min * TILE_HEIGHT, tileh); if (CmdFailed(cost)) { _terraform_err_tile = tile; return cost; diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp index 349d0cab8..eba83f1d3 100644 --- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -1040,7 +1040,7 @@ void TileLoop_Water(TileIndex tile) if (IsTileType(dest, MP_WATER)) continue; uint z_dest; - Slope slope_dest = (Slope)(GetFoundationSlope(dest, &z_dest) & ~SLOPE_HALFTILE_MASK & ~SLOPE_STEEP); + Slope slope_dest = GetFoundationSlope(dest, &z_dest) & ~SLOPE_HALFTILE_MASK & ~SLOPE_STEEP; if (z_dest > 0) continue; if (!HasBit(_flood_from_dirs[slope_dest], ReverseDir(dir))) continue; @@ -1050,7 +1050,7 @@ void TileLoop_Water(TileIndex tile) break; case FLOOD_DRYUP: { - Slope slope_here = (Slope)(GetFoundationSlope(tile, NULL) & ~SLOPE_HALFTILE_MASK & ~SLOPE_STEEP); + Slope slope_here = GetFoundationSlope(tile, NULL) & ~SLOPE_HALFTILE_MASK & ~SLOPE_STEEP; uint check_dirs = _flood_from_dirs[slope_here]; uint dir; FOR_EACH_SET_BIT(dir, check_dirs) { @@ -1097,7 +1097,7 @@ void ConvertGroundTilesIntoWaterTiles() uint dir; FOR_EACH_SET_BIT(dir, check_dirs) { TileIndex dest = TILE_ADD(tile, TileOffsByDir((Direction)dir)); - Slope slope_dest = (Slope)(GetTileSlope(dest, NULL) & ~SLOPE_STEEP); + Slope slope_dest = GetTileSlope(dest, NULL) & ~SLOPE_STEEP; if (slope_dest == SLOPE_FLAT || IsSlopeWithOneCornerRaised(slope_dest)) { MakeShore(tile); break; |