diff options
-rw-r--r-- | src/rail_cmd.cpp | 2 | ||||
-rw-r--r-- | src/road_cmd.cpp | 10 |
2 files changed, 11 insertions, 1 deletions
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp index d4442a9b9..afa071b14 100644 --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -1532,7 +1532,7 @@ CommandCost CmdConvertRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3 } /* Update the company infrastructure counters. */ - if (IsRailStationTile(tile) && !IsStationTileBlocked(tile)) { + if (!IsRailStationTile(tile) || !IsStationTileBlocked(tile)) { Company *c = Company::Get(GetTileOwner(tile)); uint num_pieces = IsLevelCrossingTile(tile) ? LEVELCROSSING_TRACKBIT_FACTOR : 1; if (IsPlainRailTile(tile)) { diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp index b4b7b600e..3df83c821 100644 --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -377,6 +377,11 @@ static CommandCost RemoveRoad(TileIndex tile, DoCommandFlag flags, RoadBits piec bool reserved = HasCrossingReservation(tile); MakeRailNormal(tile, GetTileOwner(tile), tracks, GetRailType(tile)); if (reserved) SetTrackReservation(tile, tracks); + + /* Update rail count for level crossings. The plain track should still be accounted + * for, so only subtract the difference to the level crossing cost. */ + c = Company::GetIfValid(GetTileOwner(tile)); + if (c != NULL) c->infrastructure.rail[GetRailType(tile)] -= LEVELCROSSING_TRACKBIT_FACTOR - 1; } else { SetRoadTypes(tile, rts); /* If we ever get HWAY and it is possible without road then we will need to promote ownership and invalidate town index here, too */ @@ -609,6 +614,11 @@ CommandCost CmdBuildRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 if (rt != ROADTYPE_ROAD) c->infrastructure.road[ROADTYPE_ROAD] += 2; DirtyCompanyInfrastructureWindows(_current_company); } + /* Update rail count for level crossings. The plain track is already + * counted, so only add the difference to the level crossing cost. */ + c = Company::GetIfValid(GetTileOwner(tile)); + if (c != NULL) c->infrastructure.rail[GetRailType(tile)] += LEVELCROSSING_TRACKBIT_FACTOR - 1; + /* Always add road to the roadtypes (can't draw without it) */ bool reserved = HasBit(GetRailReservationTrackBits(tile), railtrack); MakeRoadCrossing(tile, _current_company, _current_company, GetTileOwner(tile), roaddir, GetRailType(tile), RoadTypeToRoadTypes(rt) | ROADTYPES_ROAD, p2); |