Mercurial > hg > openttd
changeset 12693:3916fe720543 draft
(svn r17152) -Fix: A stuck train could free the reservation of another train if it was reversed or did crash.
author | michi_cc <michi_cc@openttd.org> |
---|---|
date | Mon, 10 Aug 2009 23:52:44 +0000 |
parents | 09fa66ffeadd |
children | 8d6be3e8bd6e |
files | src/train_cmd.cpp src/water_cmd.cpp |
diffstat | 2 files changed, 6 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -1910,8 +1910,8 @@ InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile); } - /* Clear path reservation in front. */ - FreeTrainTrackReservation(v); + /* Clear path reservation in front if train is not stuck. */ + if (!HasBit(v->flags, VRF_TRAIN_STUCK)) FreeTrainTrackReservation(v); /* Check if we were approaching a rail/road-crossing */ TileIndex crossing = TrainApproachingCrossingTile(v); @@ -3510,11 +3510,10 @@ { if (v->crash_anim_pos != 0) return; - /* Free a possible path reservation and try to mark all tiles occupied by the train reserved. */ if (v->IsFrontEngine()) { - /* Remove all reservations, also the ones currently under the train - * and any railway station paltform reservation. */ - FreeTrainTrackReservation(v); + /* Remove the reserved path in front of the train if it is not stuck. + * Also clear all reserved tracks the train is currently on. */ + if (!HasBit(v->flags, VRF_TRAIN_STUCK)) FreeTrainTrackReservation(v); for (const Train *u = v; u != NULL; u = u->Next()) { ClearPathReservation(u, u->tile, u->GetVehicleTrackdir()); if (IsTileType(u->tile, MP_TUNNELBRIDGE)) {
--- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -805,7 +805,7 @@ /* FreeTrainTrackReservation() calls GetVehicleTrackdir() that doesn't like crashed vehicles. * In this case, v->direction matches v->u.rail.track, so we can do this (it wasn't crashed before) */ t->vehstatus &= ~VS_CRASHED; - FreeTrainTrackReservation(t); + if (!HasBit(t->flags, VRF_TRAIN_STUCK)) FreeTrainTrackReservation(t); t->vehstatus |= VS_CRASHED; } t->crash_anim_pos = 4000; // max 4440, disappear pretty fast