Changeset - r9875:2fcfb23aeaeb
[Not reviewed]
master
0 1 0
smatz - 16 years ago 2008-08-08 13:53:06
smatz@openttd.org
(svn r14022) -Fix (r13957) [YAPP]: Removing station tiles could produce stale reservations, too. (michi_cc)
1 file changed with 18 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/station_cmd.cpp
Show inline comments
 
@@ -1027,6 +1027,7 @@ CommandCost CmdBuildRailroadStation(Tile
 
			do {
 
				byte layout = *layout_ptr++;
 
				if (IsRailwayStationTile(tile) && GetRailwayStationReservation(tile)) {
 
					/* Check for trains having a reservation for this tile. */
 
					Vehicle *v = GetTrainForReservation(tile, AxisToTrack(GetRailStationAxis(tile)));
 
					if (v != NULL) {
 
						FreeTrainTrackReservation(v);
 
@@ -1062,9 +1063,10 @@ CommandCost CmdBuildRailroadStation(Tile
 
		} while (--numtracks);
 

	
 
		for (uint i = 0; i < affected_vehicles.Length(); ++i) {
 
			/* Restore reservations of trains. */
 
			Vehicle *v = affected_vehicles[i];
 
			if (IsRailwayStationTile(v->tile)) SetRailwayStationPlatformReservation(v->tile, TrackdirToExitdir(GetVehicleTrackdir(v)), true);
 
			TryPathReserve(v, true);
 
			TryPathReserve(v, true, true);
 
			for (; v->Next() != NULL; v = v->Next()) ;
 
			if (IsRailwayStationTile(v->tile)) SetRailwayStationPlatformReservation(v->tile, TrackdirToExitdir(ReverseTrackdir(GetVehicleTrackdir(v))), true);
 
		}
 
@@ -1198,7 +1200,14 @@ CommandCost CmdRemoveFromRailroadStation
 

	
 
			if (GetRailwayStationReservation(tile2)) {
 
				v = GetTrainForReservation(tile2, track);
 
				if (v != NULL) FreeTrainTrackReservation(v);
 
				if (v != NULL) {
 
					/* Free train reservation. */
 
					FreeTrainTrackReservation(v);
 
					if (IsRailwayStationTile(v->tile)) SetRailwayStationPlatformReservation(v->tile, TrackdirToExitdir(GetVehicleTrackdir(v)), false);
 
					Vehicle *temp = v;
 
					for (; temp->Next() != NULL; temp = temp->Next()) ;
 
					if (IsRailwayStationTile(temp->tile)) SetRailwayStationPlatformReservation(temp->tile, TrackdirToExitdir(ReverseTrackdir(GetVehicleTrackdir(temp))), false);
 
				}
 
			}
 

	
 
			DoClearSquare(tile2);
 
@@ -1215,7 +1224,13 @@ CommandCost CmdRemoveFromRailroadStation
 
			st->MarkTilesDirty(false);
 
			UpdateStationSignCoord(st);
 

	
 
			if (v != NULL) TryPathReserve(v, true);
 
			if (v != NULL) {
 
				/* Restore station reservation. */
 
				if (IsRailwayStationTile(v->tile)) SetRailwayStationPlatformReservation(v->tile, TrackdirToExitdir(GetVehicleTrackdir(v)), true);
 
				TryPathReserve(v, true, true);
 
				for (; v->Next() != NULL; v = v->Next()) ;
 
				if (IsRailwayStationTile(v->tile)) SetRailwayStationPlatformReservation(v->tile, TrackdirToExitdir(ReverseTrackdir(GetVehicleTrackdir(v))), true);
 
			}
 

	
 
			/* if we deleted the whole station, delete the train facility. */
 
			if (st->train_tile == 0) {
0 comments (0 inline, 0 general)