From aba9f98a73a065ecb79ea129f23d7c982df42e0d Mon Sep 17 00:00:00 2001 From: michi_cc Date: Mon, 19 Dec 2011 14:24:12 +0000 Subject: (svn r23593) -Fix (r23411): Infrastructure counts for rail were not properly updated when converting rail or building level crossings. --- src/road_cmd.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/road_cmd.cpp') 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); -- cgit v1.2.3-54-g00ecf