Changeset - r25379:98a0c3d6dc80
[Not reviewed]
master
0 6 0
glx22 - 4 years ago 2021-04-30 15:01:26
glx@openttd.org
Codechange: Replace FOR_ALL_ROADTRAMTYPES with range-based for loops
6 files changed with 12 insertions and 12 deletions:
0 comments (0 inline, 0 general)
src/road.h
Show inline comments
 
@@ -32,7 +32,7 @@ enum RoadTramTypes : uint8 {
 
};
 
DECLARE_ENUM_AS_BIT_SET(RoadTramTypes)
 

	
 
#define FOR_ALL_ROADTRAMTYPES(x) for (RoadTramType x : { RTT_ROAD, RTT_TRAM })
 
static const RoadTramType _roadtramtypes[] = { RTT_ROAD, RTT_TRAM };
 

	
 
/** Roadtype flags. Starts with RO instead of R because R is used for rails */
 
enum RoadTypeFlags {
src/road_cmd.cpp
Show inline comments
 
@@ -1238,7 +1238,7 @@ static CommandCost ClearTile_Road(TileIn
 
			/* Clear the road if only one piece is on the tile OR we are not using the DC_AUTO flag */
 
			if ((HasExactlyOneBit(b) && GetRoadBits(tile, RTT_TRAM) == ROAD_NONE) || !(flags & DC_AUTO)) {
 
				CommandCost ret(EXPENSES_CONSTRUCTION);
 
				FOR_ALL_ROADTRAMTYPES(rtt) {
 
				for (RoadTramType rtt : _roadtramtypes) {
 
					if (!MayHaveRoad(tile) || GetRoadType(tile, rtt) == INVALID_ROADTYPE) continue;
 

	
 
					CommandCost tmp_ret = RemoveRoad(tile, flags, GetRoadBits(tile, rtt), rtt, true);
 
@@ -2203,7 +2203,7 @@ static void ChangeTileOwner_Road(TileInd
 
				Company::Get(new_owner)->infrastructure.road[rt] += 2;
 

	
 
				SetTileOwner(tile, new_owner);
 
				FOR_ALL_ROADTRAMTYPES(rtt) {
 
				for (RoadTramType rtt : _roadtramtypes) {
 
					if (GetRoadOwner(tile, rtt) == old_owner) {
 
						SetRoadOwner(tile, rtt, new_owner);
 
					}
 
@@ -2213,7 +2213,7 @@ static void ChangeTileOwner_Road(TileInd
 
		return;
 
	}
 

	
 
	FOR_ALL_ROADTRAMTYPES(rtt) {
 
	for (RoadTramType rtt : _roadtramtypes) {
 
		/* Update all roadtypes, no matter if they are present */
 
		if (GetRoadOwner(tile, rtt) == old_owner) {
 
			RoadType rt = GetRoadType(tile, rtt);
src/saveload/afterload.cpp
Show inline comments
 
@@ -1855,7 +1855,7 @@ bool AfterLoadGame()
 
				}
 
			} else if (IsTileType(t, MP_ROAD)) {
 
				/* works for all RoadTileType */
 
				FOR_ALL_ROADTRAMTYPES(rtt) {
 
				for (RoadTramType rtt : _roadtramtypes) {
 
					/* update even non-existing road types to update tile owner too */
 
					Owner o = GetRoadOwner(t, rtt);
 
					if (o < MAX_COMPANIES && !Company::IsValidID(o)) SetRoadOwner(t, rtt, OWNER_NONE);
src/saveload/company_sl.cpp
Show inline comments
 
@@ -128,7 +128,7 @@ void AfterLoadCompanyStats()
 
				}
 

	
 
				/* Iterate all present road types as each can have a different owner. */
 
				FOR_ALL_ROADTRAMTYPES(rtt) {
 
				for (RoadTramType rtt : _roadtramtypes) {
 
					RoadType rt = GetRoadType(tile, rtt);
 
					if (rt == INVALID_ROADTYPE) continue;
 
					c = Company::GetIfValid(IsRoadDepot(tile) ? GetTileOwner(tile) : GetRoadOwner(tile, rtt));
 
@@ -151,7 +151,7 @@ void AfterLoadCompanyStats()
 
					case STATION_BUS:
 
					case STATION_TRUCK: {
 
						/* Iterate all present road types as each can have a different owner. */
 
						FOR_ALL_ROADTRAMTYPES(rtt) {
 
						for (RoadTramType rtt : _roadtramtypes) {
 
							RoadType rt = GetRoadType(tile, rtt);
 
							if (rt == INVALID_ROADTYPE) continue;
 
							c = Company::GetIfValid(GetRoadOwner(tile, rtt));
 
@@ -209,7 +209,7 @@ void AfterLoadCompanyStats()
 

	
 
						case TRANSPORT_ROAD: {
 
							/* Iterate all present road types as each can have a different owner. */
 
							FOR_ALL_ROADTRAMTYPES(rtt) {
 
							for (RoadTramType rtt : _roadtramtypes) {
 
								RoadType rt = GetRoadType(tile, rtt);
 
								if (rt == INVALID_ROADTYPE) continue;
 
								c = Company::GetIfValid(GetRoadOwner(tile, rtt));
src/station_cmd.cpp
Show inline comments
 
@@ -2029,7 +2029,7 @@ static CommandCost RemoveRoadStop(TileIn
 
		}
 

	
 
		/* Update company infrastructure counts. */
 
		FOR_ALL_ROADTRAMTYPES(rtt) {
 
		for (RoadTramType rtt : _roadtramtypes) {
 
			RoadType rt = GetRoadType(tile, rtt);
 
			UpdateCompanyRoadInfrastructure(rt, GetRoadOwner(tile, rtt), -static_cast<int>(ROAD_STOP_TRACKBIT_FACTOR));
 
		}
 
@@ -2110,7 +2110,7 @@ CommandCost CmdRemoveRoadStop(TileIndex 
 
		RoadType road_type[] = { INVALID_ROADTYPE, INVALID_ROADTYPE };
 
		Owner road_owner[] = { OWNER_NONE, OWNER_NONE };
 
		if (IsDriveThroughStopTile(cur_tile)) {
 
			FOR_ALL_ROADTRAMTYPES(rtt) {
 
			for (RoadTramType rtt : _roadtramtypes) {
 
				road_type[rtt] = GetRoadType(cur_tile, rtt);
 
				if (road_type[rtt] == INVALID_ROADTYPE) continue;
 
				road_owner[rtt] = GetRoadOwner(cur_tile, rtt);
 
@@ -4178,7 +4178,7 @@ void DeleteOilRig(TileIndex tile)
 
static void ChangeTileOwner_Station(TileIndex tile, Owner old_owner, Owner new_owner)
 
{
 
	if (IsRoadStopTile(tile)) {
 
		FOR_ALL_ROADTRAMTYPES(rtt) {
 
		for (RoadTramType rtt : _roadtramtypes) {
 
			/* Update all roadtypes, no matter if they are present */
 
			if (GetRoadOwner(tile, rtt) == old_owner) {
 
				RoadType rt = GetRoadType(tile, rtt);
src/tunnelbridge_cmd.cpp
Show inline comments
 
@@ -1811,7 +1811,7 @@ static void ChangeTileOwner_TunnelBridge
 
	 * don't want to update the infrastructure counts twice. */
 
	uint num_pieces = tile < other_end ? (GetTunnelBridgeLength(tile, other_end) + 2) * TUNNELBRIDGE_TRACKBIT_FACTOR : 0;
 

	
 
	FOR_ALL_ROADTRAMTYPES(rtt) {
 
	for (RoadTramType rtt : _roadtramtypes) {
 
		/* Update all roadtypes, no matter if they are present */
 
		if (GetRoadOwner(tile, rtt) == old_owner) {
 
			RoadType rt = GetRoadType(tile, rtt);
0 comments (0 inline, 0 general)