diff options
author | michi_cc <michi_cc@openttd.org> | 2011-12-03 23:40:18 +0000 |
---|---|---|
committer | michi_cc <michi_cc@openttd.org> | 2011-12-03 23:40:18 +0000 |
commit | a29a9d94b7216e41dc6d7f96345d2f66e882c89a (patch) | |
tree | 1bc66f82c6144656669317ee2b33997336e9a84d /src/saveload | |
parent | d30fcd4e354325af0d2b1968cd11c9db36a3e617 (diff) | |
download | openttd-a29a9d94b7216e41dc6d7f96345d2f66e882c89a.tar.xz |
(svn r23412) -Add: Company infrastructure counts for road.
Diffstat (limited to 'src/saveload')
-rw-r--r-- | src/saveload/company_sl.cpp | 32 |
1 files changed, 31 insertions, 1 deletions
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; } |