diff src/train_cmd.cpp @ 15449:f6ee1b7fde96 draft

(svn r20098) -Fix [FS#3898]: A train reversing in a station would sometimes fail to release its reserved path.
author michi_cc <michi_cc@openttd.org>
date Fri, 09 Jul 2010 14:14:17 +0000 (2010-07-09)
parents a90f03aeb026
children 683f2dbe75bb
line wrap: on
line diff
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -3808,8 +3808,17 @@
 		v->wait_counter = 0;
 		v->cur_speed = 0;
 		v->subspeed = 0;
+		ClrBit(v->flags, VRF_LEAVING_STATION);
 		ReverseTrainDirection(v);
 		return true;
+	} else if (HasBit(v->flags, VRF_LEAVING_STATION)) {
+		/* Try to reserve a path when leaving the station as we
+		 * might not be marked as wanting a reservation, e.g.
+		 * when an overlength train gets turned around in a station. */
+		if (UpdateSignalsOnSegment(v->tile, TrackdirToExitdir(v->GetVehicleTrackdir()), v->owner) == SIGSEG_PBS || _settings_game.pf.reserve_paths) {
+			TryPathReserve(v, true, true);
+		}
+		ClrBit(v->flags, VRF_LEAVING_STATION);
 	}
 
 	v->HandleLoading(mode);