mirror of https://github.com/OpenTTD/OpenTTD
(svn r23593) -Fix (r23411): Infrastructure counts for rail were not properly updated when converting rail or building level crossings.
parent
b827694aec
commit
aba9f98a73
|
@ -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)) {
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue