summaryrefslogtreecommitdiff
path: root/src/train_cmd.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2008-08-03 17:16:39 +0000
committerfrosch <frosch@openttd.org>2008-08-03 17:16:39 +0000
commitb92c4cfc92f53259dd8f108d7cbb29a19bdc61d6 (patch)
treeaf2744f05d7b6099dacc5923b484b93fb3b0f702 /src/train_cmd.cpp
parenta5453e43b1c56c117818d50ca3904c7ada3c8732 (diff)
downloadopenttd-b92c4cfc92f53259dd8f108d7cbb29a19bdc61d6.tar.xz
(svn r13976) -Fix (r13953) [YAPP]: A crashing train could sometimes free the reservation of another train. (assisted by michi_cc)
Diffstat (limited to 'src/train_cmd.cpp')
-rw-r--r--src/train_cmd.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index dc7ff694c..42c7806be 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -3437,11 +3437,6 @@ static void SetVehicleCrashed(Vehicle *v)
for (const Vehicle *u = v; u != NULL; u = u->Next()) {
ClearPathReservation(u->tile, GetVehicleTrackdir(u));
}
- /* Try to reserve all tiles directly under the train, but not the whole
- * railway station platform or both tunnel/bridge ends. */
- for (const Vehicle *u = v; u != NULL; u = u->Next()) {
- TryReserveRailTrack(u->tile, TrackdirToTrack(GetVehicleTrackdir(u)));
- }
}
/* we may need to update crossing we were approaching */
@@ -3511,6 +3506,15 @@ static Vehicle *FindTrainCollideEnum(Vehicle *v, void *data)
tcc->num += 2 + CountPassengersInTrain(coll);
SetVehicleCrashed(coll);
}
+
+ /* Try to reserve all tiles directly under the crashed trains.
+ * 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)) {
+ TryReserveRailTrack(u->tile, TrackBitsToTrack(u->u.rail.track));
+ }
+ }
}
return NULL;