(svn r23412) -Add: Company infrastructure counts for road.

This commit is contained in:
michi_cc
2011-12-03 23:40:18 +00:00
parent 85ec2f07af
commit 7a6b45c133
5 changed files with 195 additions and 3 deletions

View File

@@ -115,12 +115,21 @@ void AfterLoadCompanyStats()
}
break;
case MP_ROAD:
case MP_ROAD: {
if (IsLevelCrossing(tile)) {
c = Company::GetIfValid(GetTileOwner(tile));
if (c != NULL) c->infrastructure.rail[GetRailType(tile)] += LEVELCROSSING_TRACKBIT_FACTOR;
}
/* Iterate all present road types as each can have a different owner. */
RoadType rt;
FOR_EACH_SET_ROADTYPE(rt, GetRoadTypes(tile)) {
c = Company::GetIfValid(IsRoadDepot(tile) ? GetTileOwner(tile) : GetRoadOwner(tile, rt));
/* A level crossings and depots have two road bits. */
if (c != NULL) c->infrastructure.road[rt] += IsNormalRoad(tile) ? CountBits(GetRoadBits(tile, rt)) : 2;
}
break;
}
case MP_STATION:
c = Company::GetIfValid(GetTileOwner(tile));
@@ -131,6 +140,17 @@ void AfterLoadCompanyStats()
if (c != NULL && !IsStationTileBlocked(tile)) c->infrastructure.rail[GetRailType(tile)]++;
break;
case STATION_BUS:
case STATION_TRUCK: {
/* Iterate all present road types as each can have a different owner. */
RoadType rt;
FOR_EACH_SET_ROADTYPE(rt, GetRoadTypes(tile)) {
c = Company::GetIfValid(GetRoadOwner(tile, rt));
if (c != NULL) c->infrastructure.road[rt] += 2; // A road stop has two road bits.
}
break;
}
default:
break;
}
@@ -150,6 +170,16 @@ void AfterLoadCompanyStats()
if (c != NULL) c->infrastructure.rail[GetRailType(tile)] += len;
break;
case TRANSPORT_ROAD: {
/* Iterate all present road types as each can have a different owner. */
RoadType rt;
FOR_EACH_SET_ROADTYPE(rt, GetRoadTypes(tile)) {
c = Company::GetIfValid(GetRoadOwner(tile, rt));
if (c != NULL) c->infrastructure.road[rt] += len * 2; // A full diagonal road has two road bits.
}
break;
}
default:
break;
}