(svn r3422) - Fix: If an engine reaches the rear of a depot, make the engine turn around before it reaches the tile end (same as a normal end of line.) This fixes a bug whereby the engine could poke into the depot and crash with another engine just leaving it.
authorpeter1138
Mon, 23 Jan 2006 21:05:05 +0000
changeset 2874 30c79e6e1c3e
parent 2873 75b688d160d5
child 2875 905a06cc99c3
(svn r3422) - Fix: If an engine reaches the rear of a depot, make the engine turn around before it reaches the tile end (same as a normal end of line.) This fixes a bug whereby the engine could poke into the depot and crash with another engine just leaving it.
train_cmd.c
--- a/train_cmd.c	Mon Jan 23 19:12:35 2006 +0000
+++ b/train_cmd.c	Mon Jan 23 21:05:05 2006 +0000
@@ -3294,7 +3294,7 @@
 	TileIndex tile;
 	uint x,y;
 	uint16 break_speed;
-	int t;
+	DiagDirection t;
 	uint32 ts;
 	byte trackdir;
 
@@ -3368,8 +3368,11 @@
 	}
 
 	if (GB(ts, 0, 16) != 0) {
-		/* If we approach a rail-piece which we can't enter, don't enter it! */
-		if (x + 4 > 15 && !CheckCompatibleRail(v, tile)) {
+		/* If we approach a rail-piece which we can't enter, or the back of a depot, don't enter it! */
+		if (x + 4 > 15 &&
+				(!CheckCompatibleRail(v, tile) ||
+				(IsTileDepotType(tile, TRANSPORT_RAIL) &&
+				GetDepotDirection(tile, TRANSPORT_RAIL) == t))) {
 			v->cur_speed = 0;
 			ReverseTrainDirection(v);
 			return false;