changeset 7832:1f9fb5d427f9 draft

(svn r11382) -Codechange: renamed COUNTBITS to CountBits, as it is no longer a macro (skidd13)
author truelight <truelight@openttd.org>
date Sun, 04 Nov 2007 22:47:34 +0000
parents fa9e8633d075
children f79d18d560b2
files src/economy.cpp src/macros.h src/road.cpp src/road_cmd.cpp src/roadveh_cmd.cpp src/vehicle_gui.cpp
diffstat 6 files changed, 14 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -69,7 +69,7 @@
 	uint num = 0;
 
 	FOR_ALL_STATIONS(st) {
-		if (st->owner == owner) num += COUNTBITS(st->facilities);
+		if (st->owner == owner) num += CountBits(st->facilities);
 	}
 
 	value += num * _price.station_value * 25;
@@ -141,7 +141,7 @@
 		const Station* st;
 
 		FOR_ALL_STATIONS(st) {
-			if (st->owner == owner) num += COUNTBITS(st->facilities);
+			if (st->owner == owner) num += CountBits(st->facilities);
 		}
 		_score_part[owner][SCORE_STATIONS] = num;
 	}
@@ -186,7 +186,7 @@
 
 /* Generate score for variety of cargo */
 	{
-		uint num = COUNTBITS(p->cargo_types);
+		uint num = CountBits(p->cargo_types);
 		_score_part[owner][SCORE_CARGO] = num;
 		if (update) p->cargo_types = 0;
 	}
--- a/src/macros.h
+++ b/src/macros.h
@@ -432,7 +432,7 @@
  * @param value the value to count the number of bits in.
  * @return the number of bits.
  */
-template<typename T> static inline uint COUNTBITS(T value)
+template<typename T> static inline uint CountBits(T value)
 {
 	register uint num;
 
--- a/src/road.cpp
+++ b/src/road.cpp
@@ -42,7 +42,7 @@
 
 					/* Accept only connective tiles */
 					connective = (neighbor_rb & mirrored_rb) || // Neighbor has got the fitting RoadBit
-							COUNTBITS(neighbor_rb) == 1; // Neighbor has got only one Roadbit
+							CountBits(neighbor_rb) == 1; // Neighbor has got only one Roadbit
 
 				} break;
 
--- a/src/road_cmd.cpp
+++ b/src/road_cmd.cpp
@@ -220,7 +220,7 @@
 					MarkTileDirtyByTile(tile);
 				}
 			}
-			return CommandCost(COUNTBITS(c) * _price.remove_road);
+			return CommandCost(CountBits(c) * _price.remove_road);
 		}
 
 		case ROAD_TILE_CROSSING: {
@@ -352,7 +352,7 @@
 	/* Single bits on slopes.
 	 * We check for the roads that need at least 2 bits */
 	if (_patches.build_on_slopes && !_is_old_ai_player &&
-			existing == ROAD_NONE && COUNTBITS(*pieces) == 1 &&
+			existing == ROAD_NONE && CountBits(*pieces) == 1 &&
 			(_valid_tileh_slopes_road[2][tileh] & *pieces) == ROAD_NONE) {
 		return CommandCost(_price.terraform);
 	}
@@ -531,7 +531,7 @@
 		pieces &= ComplementRoadBits(existing);
 	}
 
-	cost.AddCost(COUNTBITS(pieces) * _price.build_road);
+	cost.AddCost(CountBits(pieces) * _price.build_road);
 	if (IsTileType(tile, MP_TUNNELBRIDGE)) {
 		/* Pay for *every* tile of the bridge or tunnel */
 		cost.MultiplyCost(DistanceManhattan(IsTunnel(tile) ? GetOtherTunnelEnd(tile) : GetOtherBridgeEnd(tile), tile));
@@ -838,7 +838,7 @@
 
 			/* Clear the road if only one piece is on the tile OR the AI tries
 			 * to clear town road OR we are not using the DC_AUTO flag */
-			if ((COUNTBITS(b) == 1 && GetRoadBits(tile, ROADTYPE_TRAM) == ROAD_NONE) ||
+			if ((CountBits(b) == 1 && GetRoadBits(tile, ROADTYPE_TRAM) == ROAD_NONE) ||
 			    ((flags & DC_AI_BUILDING) && IsTileOwner(tile, OWNER_TOWN)) ||
 			    !(flags & DC_AUTO)
 				) {
@@ -906,7 +906,7 @@
 			 * created directly, but the state itself is still perfectly drawable.
 			 * However, as we do not want this to be build directly, we need to check
 			 * for that situation in here. */
-			return (tileh != 0 && COUNTBITS(bits) == 1) ? FOUNDATION_LEVELED : FOUNDATION_NONE;
+			return (tileh != 0 && CountBits(bits) == 1) ? FOUNDATION_LEVELED : FOUNDATION_NONE;
 		}
 		if ((~_valid_tileh_slopes_road[1][tileh] & bits) == 0) return FOUNDATION_LEVELED;
 	}
@@ -1241,7 +1241,7 @@
 			/* Show an animation to indicate road work */
 			if (t->road_build_months != 0 &&
 					(DistanceManhattan(t->xy, tile) < 8 || grp != 0) &&
-					GetRoadTileType(tile) == ROAD_TILE_NORMAL && COUNTBITS(GetAllRoadBits(tile)) > 1 ) {
+					GetRoadTileType(tile) == ROAD_TILE_NORMAL && CountBits(GetAllRoadBits(tile)) > 1 ) {
 				if (GetTileSlope(tile, NULL) == SLOPE_FLAT && EnsureNoVehicleOnGround(tile) && CHANCE16(1, 40)) {
 					StartRoadWorks(tile);
 
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -1100,7 +1100,7 @@
 static int PickRandomBit(uint bits)
 {
 	uint i;
-	uint num = RandomRange(COUNTBITS(bits));
+	uint num = RandomRange(CountBits(bits));
 
 	for (i = 0; !(bits & 1) || (int)--num >= 0; bits >>= 1, i++) {}
 	return i;
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -485,7 +485,7 @@
 	char *b = _userstring;
 
 	/* Draw nothing if the engine is not refittable */
-	if (COUNTBITS(cmask) <= 1) return 0;
+	if (CountBits(cmask) <= 1) return 0;
 
 	b = InlineString(b, STR_PURCHASE_INFO_REFITTABLE_TO);
 
@@ -495,7 +495,7 @@
 	} else {
 		/* Check if we are able to refit to more cargo types and unable to. If
 		 * so, invert the cargo types to list those that we can't refit to. */
-		if (COUNTBITS(cmask ^ lmask) < COUNTBITS(cmask)) {
+		if (CountBits(cmask ^ lmask) < CountBits(cmask)) {
 			cmask ^= lmask;
 			b = InlineString(b, STR_PURCHASE_INFO_ALL_BUT);
 		}