(svn r2113) -Fix: first check if a vehicle is a train, before accessing u.rail
authortruelight
Thu, 31 Mar 2005 12:39:18 +0000
changeset 1609 b4d11170cbb5
parent 1608 074dff2e4890
child 1610 18e4f9e042a9
(svn r2113) -Fix: first check if a vehicle is a train, before accessing u.rail
rail_cmd.c
--- a/rail_cmd.c	Wed Mar 30 19:52:26 2005 +0000
+++ b/rail_cmd.c	Thu Mar 31 12:39:18 2005 +0000
@@ -1572,15 +1572,17 @@
 	SignalVehicleCheckStruct *dest = data;
 	TileIndex tile;
 
+	if (v->type != VEH_Train)
+		return NULL;
+
 	/* Find the tile outside the tunnel, for signalling */
-	if (v->u.rail.track == 0x40) {
+	if (v->u.rail.track == 0x40)
 		tile = GetVehicleOutOfTunnelTile(v);
-	} else {
+	else
 		tile = v->tile;
-	}
 
 	/* Wrong tile, or no train? Not a match */
-	if (tile != dest->tile || v->type != VEH_Train)
+	if (tile != dest->tile)
 		return NULL;
 
 	/* Are we on the same piece of track? */