summaryrefslogtreecommitdiff
path: root/src/road_cmd.cpp
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2010-02-05 17:05:58 +0000
committersmatz <smatz@openttd.org>2010-02-05 17:05:58 +0000
commitd62d0ac48997f9b72da0f554dcf5269694d5999e (patch)
treee849059133de10814a39a544a3060a9d7dcff672 /src/road_cmd.cpp
parenta80eb0a1c00136ca3c4bbbe94842f386fdd2a334 (diff)
downloadopenttd-d62d0ac48997f9b72da0f554dcf5269694d5999e.tar.xz
(svn r19019) -Codechange: use HasExactlyOneBit() and HasAtMostOneBit() instead of CountBits() where possible
Diffstat (limited to 'src/road_cmd.cpp')
-rw-r--r--src/road_cmd.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp
index 4b2f0957d..8b7643cc1 100644
--- a/src/road_cmd.cpp
+++ b/src/road_cmd.cpp
@@ -422,7 +422,7 @@ static CommandCost CheckRoadSlope(Slope tileh, RoadBits *pieces, RoadBits existi
return CommandCost();
}
} else {
- if (CountBits(existing) == 1 && GetRoadFoundation(tileh, existing) == FOUNDATION_NONE) return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_FOUNDATION]);
+ if (HasExactlyOneBit(existing) && GetRoadFoundation(tileh, existing) == FOUNDATION_NONE) return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_FOUNDATION]);
return CommandCost();
}
}
@@ -911,7 +911,7 @@ static CommandCost ClearTile_Road(TileIndex tile, DoCommandFlag flags)
RoadBits b = GetAllRoadBits(tile);
/* Clear the road if only one piece is on the tile OR we are not using the DC_AUTO flag */
- if ((CountBits(b) == 1 && GetRoadBits(tile, ROADTYPE_TRAM) == ROAD_NONE) || !(flags & DC_AUTO)) {
+ if ((HasExactlyOneBit(b) && GetRoadBits(tile, ROADTYPE_TRAM) == ROAD_NONE) || !(flags & DC_AUTO)) {
RoadTypes rts = GetRoadTypes(tile);
CommandCost ret(EXPENSES_CONSTRUCTION);
for (RoadType rt = ROADTYPE_ROAD; rt < ROADTYPE_END; rt++) {
@@ -1145,7 +1145,7 @@ static void DrawRoadBits(TileInfo *ti)
}
/* If there are no road bits, return, as there is nothing left to do */
- if (CountBits(road) < 2) return;
+ if (HasAtMostOneBit(road)) return;
/* Draw extra details. */
for (const DrawRoadTileStruct *drts = _road_display_table[roadside][road | tram]; drts->image != 0; drts++) {
@@ -1322,7 +1322,7 @@ static void TileLoop_Road(TileIndex tile)
/* Show an animation to indicate road work */
if (t->road_build_months != 0 &&
(DistanceManhattan(t->xy, tile) < 8 || grp != HZB_TOWN_EDGE) &&
- IsNormalRoad(tile) && CountBits(GetAllRoadBits(tile)) > 1 ) {
+ IsNormalRoad(tile) && !HasAtMostOneBit(GetAllRoadBits(tile))) {
if (GetFoundationSlope(tile, NULL) == SLOPE_FLAT && EnsureNoVehicleOnGround(tile) && Chance16(1, 40)) {
StartRoadWorks(tile);