Mercurial > hg > openttd
changeset 9875:455ec20910c6 draft
(svn r14022) -Fix (r13957) [YAPP]: Removing station tiles could produce stale reservations, too. (michi_cc)
author | smatz <smatz@openttd.org> |
---|---|
date | Fri, 08 Aug 2008 13:53:06 +0000 |
parents | f6aeb086fbba |
children | f781986a229f |
files | src/station_cmd.cpp |
diffstat | 1 files changed, 18 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -1027,6 +1027,7 @@ 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 @@ } 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 @@ 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 @@ 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) {