From a29a9d94b7216e41dc6d7f96345d2f66e882c89a Mon Sep 17 00:00:00 2001 From: michi_cc Date: Sat, 3 Dec 2011 23:40:18 +0000 Subject: (svn r23412) -Add: Company infrastructure counts for road. --- src/saveload/company_sl.cpp | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'src/saveload/company_sl.cpp') diff --git a/src/saveload/company_sl.cpp b/src/saveload/company_sl.cpp index 358600948..4d4c50c9e 100644 --- a/src/saveload/company_sl.cpp +++ b/src/saveload/company_sl.cpp @@ -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; } -- cgit v1.2.3-54-g00ecf