summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/economy.cpp3
-rw-r--r--src/saveload/company_sl.cpp2
-rw-r--r--src/station_cmd.cpp43
3 files changed, 38 insertions, 10 deletions
diff --git a/src/economy.cpp b/src/economy.cpp
index d5652cd49..6e08b8638 100644
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -471,6 +471,9 @@ void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner)
UpdateSignalsInBuffer();
}
+ /* Add airport infrastructure count of the old company to the new one. */
+ if (new_owner != INVALID_OWNER) Company::Get(new_owner)->infrastructure.airport += Company::Get(old_owner)->infrastructure.airport;
+
/* convert owner of stations (including deleted ones, but excluding buoys) */
Station *st;
FOR_ALL_STATIONS(st) {
diff --git a/src/saveload/company_sl.cpp b/src/saveload/company_sl.cpp
index 836d20783..588d0fb18 100644
--- a/src/saveload/company_sl.cpp
+++ b/src/saveload/company_sl.cpp
@@ -139,7 +139,7 @@ void AfterLoadCompanyStats()
case MP_STATION:
c = Company::GetIfValid(GetTileOwner(tile));
- if (c != NULL && GetStationType(tile) != STATION_AIRPORT) c->infrastructure.station++;
+ if (c != NULL && GetStationType(tile) != STATION_AIRPORT && !IsBuoy(tile)) c->infrastructure.station++;
switch (GetStationType(tile)) {
case STATION_RAIL:
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 */