(svn r4192) - Fix: In the depot, moving wagons from the end of a very long train to a short train where the short train was scrolled off the window would cause a game crash. (Thanks to SimonRC for reporting.)
authorpeter1138
Fri, 31 Mar 2006 08:39:10 +0000
changeset 3384 486b8091f166
parent 3383 a4828297b799
child 3385 18e4ca6d3ef4
(svn r4192) - Fix: In the depot, moving wagons from the end of a very long train to a short train where the short train was scrolled off the window would cause a game crash. (Thanks to SimonRC for reporting.)
train_gui.c
--- a/train_gui.c	Fri Mar 31 08:35:05 2006 +0000
+++ b/train_gui.c	Fri Mar 31 08:39:10 2006 +0000
@@ -515,13 +515,10 @@
 	if (x < 0 && IsFrontEngine(v)) return (x >= -10) ? -2 : -1;
 
 	// skip vehicles that are scrolled off the left side
-	while (skip--) v = v->next;
+	while (v != NULL && skip--) v = v->next;
 
 	/* find the vehicle in this row that was clicked */
-	while ((x -= WagonLengthToPixels(v->u.rail.cached_veh_length)) >= 0) {
-		v = v->next;
-		if (v == NULL) break;
-	}
+	while (v != NULL && (x -= WagonLengthToPixels(v->u.rail.cached_veh_length)) >= 0) v = v->next;
 
 	// if an articulated part was selected, find its parent
 	while (v != NULL && IsArticulatedPart(v)) v = GetPrevVehicleInChain(v);