summaryrefslogtreecommitdiff
path: root/src/station_cmd.cpp
diff options
context:
space:
mode:
authormichi_cc <michi_cc@openttd.org>2012-01-22 22:21:21 +0000
committermichi_cc <michi_cc@openttd.org>2012-01-22 22:21:21 +0000
commit52b951ca6ffda7c465bd8ca3bfdb7ecdfe211a5b (patch)
tree7d3acf3780f3ec66b5aac4255cf3fb12bba966e9 /src/station_cmd.cpp
parentb888027dddfd448a99116cfb82e3608c0c5ae7bd (diff)
downloadopenttd-52b951ca6ffda7c465bd8ca3bfdb7ecdfe211a5b.tar.xz
(svn r23844) -Fix (r23414): Infrastructure count for stations wasn't updated properly on company takeover. And don't count buoys while loading a game either.
Diffstat (limited to 'src/station_cmd.cpp')
-rw-r--r--src/station_cmd.cpp43
1 files changed, 34 insertions, 9 deletions
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 2925d5a89..b22630717 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -3612,16 +3612,41 @@ static void ChangeTileOwner_Station(TileIndex tile, Owner old_owner, Owner new_o
Company *old_company = Company::Get(old_owner);
Company *new_company = Company::Get(new_owner);
- if ((IsRailWaypoint(tile) || IsRailStation(tile)) && !IsStationTileBlocked(tile)) {
- old_company->infrastructure.rail[GetRailType(tile)]--;
- new_company->infrastructure.rail[GetRailType(tile)]++;
+ /* Update counts for underlying infrastructure. */
+ switch (GetStationType(tile)) {
+ case STATION_RAIL:
+ case STATION_WAYPOINT:
+ if (!IsStationTileBlocked(tile)) {
+ old_company->infrastructure.rail[GetRailType(tile)]--;
+ new_company->infrastructure.rail[GetRailType(tile)]++;
+ }
+ break;
+
+ case STATION_BUS:
+ case STATION_TRUCK:
+ if (!IsDriveThroughStopTile(tile)) {
+ /* Drive-through stops were already handled above. */
+ old_company->infrastructure.road[FIND_FIRST_BIT(GetRoadTypes(tile))] -= 2;
+ new_company->infrastructure.road[FIND_FIRST_BIT(GetRoadTypes(tile))] += 2;
+ }
+ break;
+
+ case STATION_BUOY:
+ case STATION_DOCK:
+ if (GetWaterClass(tile) == WATER_CLASS_CANAL) {
+ old_company->infrastructure.water--;
+ new_company->infrastructure.water++;
+ }
+ break;
+
+ default:
+ break;
}
- if (IsRoadStop(tile) && !IsDriveThroughStopTile(tile)) {
- RoadType rt;
- FOR_EACH_SET_ROADTYPE(rt, GetRoadTypes(tile)) {
- old_company->infrastructure.road[rt] -= 2;
- new_company->infrastructure.road[rt] += 2;
- }
+
+ /* Update station tile count. */
+ if (!IsBuoy(tile) && !IsAirport(tile)) {
+ old_company->infrastructure.station--;
+ new_company->infrastructure.station++;
}
/* for buoys, owner of tile is owner of water, st->owner == OWNER_NONE */