Changeset - r20245:d6cac039be4b
[Not reviewed]
master
0 1 0
rubidium - 11 years ago 2013-05-18 18:59:06
rubidium@openttd.org
(svn r25251) -Fix [FS#5540]: when overbuilding a reserved track with a non-track station tile, that tile would remain reserved and eventually trigger a crash upon removal
1 file changed with 3 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/station_cmd.cpp
Show inline comments
 
@@ -1308,24 +1308,27 @@ CommandCost CmdBuildRailStation(TileInde
 
			if (IsRailStationTile(v->tile)) SetRailStationPlatformReservation(v->tile, TrackdirToExitdir(ReverseTrackdir(v->GetVehicleTrackdir())), true);
 
		}
 

	
 
		/* Check whether we need to expand the reservation of trains already on the station. */
 
		TileArea update_reservation_area;
 
		if (axis == AXIS_X) {
 
			update_reservation_area = TileArea(tile_org, 1, numtracks_orig);
 
		} else {
 
			update_reservation_area = TileArea(tile_org, numtracks_orig, 1);
 
		}
 

	
 
		TILE_AREA_LOOP(tile, update_reservation_area) {
 
			/* Don't even try to make eye candy parts reserved. */
 
			if (IsStationTileBlocked(tile)) continue;
 

	
 
			DiagDirection dir = AxisToDiagDir(axis);
 
			TileIndexDiff tile_offset = TileOffsByDiagDir(dir);
 
			TileIndex platform_begin = tile;
 
			TileIndex platform_end = tile;
 

	
 
			/* We can only account for tiles that are reachable from this tile, so ignore primarily blocked tiles while finding the platform begin and end. */
 
			for (TileIndex next_tile = platform_begin - tile_offset; IsCompatibleTrainStationTile(next_tile, platform_begin); next_tile -= tile_offset) {
 
				platform_begin = next_tile;
 
			}
 
			for (TileIndex next_tile = platform_end + tile_offset; IsCompatibleTrainStationTile(next_tile, platform_end); next_tile += tile_offset) {
 
				platform_end = next_tile;
 
			}
0 comments (0 inline, 0 general)