diff options
author | rubidium <rubidium@openttd.org> | 2008-08-04 13:15:15 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2008-08-04 13:15:15 +0000 |
commit | 7a50ae28d54559a2c28c7b133f0c854cceb061ba (patch) | |
tree | e085a4620a0b16591285ed70f74f7b465f696b24 | |
parent | c88cb1daa05e447cdcd2daec62501869e4e12fdf (diff) | |
download | openttd-7a50ae28d54559a2c28c7b133f0c854cceb061ba.tar.xz |
(svn r13989) -Fix [FS#2186] (r13953): YAPP track reservation for crashed trains was broken for depots and wormholes (michi_cc).
-rw-r--r-- | src/train_cmd.cpp | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 5db19dcd9..94b708389 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -3436,6 +3436,11 @@ static void SetVehicleCrashed(Vehicle *v) FreeTrainTrackReservation(v); for (const Vehicle *u = v; u != NULL; u = u->Next()) { ClearPathReservation(u->tile, GetVehicleTrackdir(u)); + if (IsTileType(u->tile, MP_TUNNELBRIDGE)) { + /* ClearPathReservation will not free the wormhole exit + * if the train has just entered the wormhole. */ + SetTunnelBridgeReservation(GetOtherTunnelBridgeEnd(u->tile), false); + } } } @@ -3511,7 +3516,12 @@ static Vehicle *FindTrainCollideEnum(Vehicle *v, void *data) * As there might be more than two trains involved, we have to do that for all vehicles */ const Vehicle *u; FOR_ALL_VEHICLES(u) { - if (u->type == VEH_TRAIN && HASBITS(u->vehstatus, VS_CRASHED)) { + if (u->type == VEH_TRAIN && HASBITS(u->vehstatus, VS_CRASHED) && (u->u.rail.track & TRACK_BIT_DEPOT) == TRACK_BIT_NONE) { + TrackBits trackbits = u->u.rail.track; + if ((trackbits & TRACK_BIT_WORMHOLE) == TRACK_BIT_WORMHOLE) { + /* Vehicle is inside a wormhole, v->u.rail.track contains no useful value then. */ + trackbits |= DiagDirToDiagTrackBits(GetTunnelBridgeDirection(u->tile)); + } TryReserveRailTrack(u->tile, TrackBitsToTrack(u->u.rail.track)); } } @@ -3843,7 +3853,14 @@ static Vehicle *CollectTrackbitsFromCrashedVehiclesEnum(Vehicle *v, void *data) { TrackBits *trackbits = (TrackBits *)data; - if (v->type == VEH_TRAIN && (v->vehstatus & VS_CRASHED) != 0) *trackbits |= v->u.rail.track; + if (v->type == VEH_TRAIN && (v->vehstatus & VS_CRASHED) != 0) { + if ((v->u.rail.track & TRACK_BIT_WORMHOLE) == TRACK_BIT_WORMHOLE) { + /* Vehicle is inside a wormhole, v->u.rail.track contains no useful value then. */ + *trackbits |= DiagDirToDiagTrackBits(GetTunnelBridgeDirection(v->tile)); + } else { + *trackbits |= v->u.rail.track; + } + } return NULL; } @@ -3886,13 +3903,18 @@ static void DeleteLastWagon(Vehicle *v) /* 'v' shouldn't be accessed after it has been deleted */ TrackBits trackbits = v->u.rail.track; - Track track = TrackBitsToTrack(trackbits); TileIndex tile = v->tile; Owner owner = v->owner; delete v; v = NULL; // make sure nobody will try to read 'v' anymore + if ((trackbits & TRACK_BIT_WORMHOLE) == TRACK_BIT_WORMHOLE) { + /* Vehicle is inside a wormhole, v->u.rail.track contains no useful value then. */ + trackbits |= DiagDirToDiagTrackBits(GetTunnelBridgeDirection(tile)); + } + + Track track = TrackBitsToTrack(trackbits); if (HasReservedTracks(tile, trackbits)) { UnreserveRailTrack(tile, track); |