(svn r19019) -Codechange: use HasExactlyOneBit() and HasAtMostOneBit() instead of CountBits() where possible

This commit is contained in:
smatz
2010-02-05 17:05:58 +00:00
parent 1d6bfd2a6c
commit 6c1ab1a2fa
8 changed files with 35 additions and 11 deletions

View File

@@ -53,7 +53,7 @@
DEBUG(ai, 0, "GetCoverageRadius(): coverage radius of airports needs to be requested via AIAirport::GetAirportCoverageRadius(), as it requires AirportType");
return -1;
}
if (CountBits(station_type) != 1) return -1;
if (!HasExactlyOneBit(station_type)) return -1;
if (!_settings_game.station.modified_catchment) return CA_UNMODIFIED;
switch (station_type) {
@@ -89,7 +89,7 @@
/* static */ bool AIStation::HasStationType(StationID station_id, StationType station_type)
{
if (!IsValidStation(station_id)) return false;
if (CountBits(station_type) != 1) return false;
if (!HasExactlyOneBit(station_type)) return false;
return (::Station::Get(station_id)->facilities & station_type) != 0;
}

View File

@@ -35,7 +35,7 @@
if (::GetRoadTypes(tile) != ROADTYPES_ROAD) return false;
/* Depots and crossings aren't considered buildable */
if (::GetRoadTileType(tile) != ROAD_TILE_NORMAL) return false;
if (CountBits(::GetRoadBits(tile, ROADTYPE_ROAD)) != 1) return false;
if (!HasExactlyOneBit(::GetRoadBits(tile, ROADTYPE_ROAD))) return false;
if (::IsRoadOwner(tile, ROADTYPE_ROAD, OWNER_TOWN)) return true;
if (::IsRoadOwner(tile, ROADTYPE_ROAD, _current_company)) return true;
return false;

View File

@@ -31,7 +31,7 @@
/* static */ bool AIWaypoint::HasWaypointType(StationID waypoint_id, WaypointType waypoint_type)
{
if (!IsValidWaypoint(waypoint_id)) return false;
if (CountBits(waypoint_type) != 1) return false;
if (!HasExactlyOneBit(waypoint_type)) return false;
return (::Waypoint::Get(waypoint_id)->facilities & waypoint_type) != 0;
}