train_gui.c
branch0.4
changeset 9977 3ed9f10aa279
parent 9959 984493ab6fff
equal deleted inserted replaced
9976:151125c579c5 9977:3ed9f10aa279
   516 	/* either pressed the flag or the number, but only when it's a loco */
   516 	/* either pressed the flag or the number, but only when it's a loco */
   517 	if (x < 0 && IsFrontEngine(v))
   517 	if (x < 0 && IsFrontEngine(v))
   518 		return (x >= -10) ? -2 : -1;
   518 		return (x >= -10) ? -2 : -1;
   519 
   519 
   520 	// skip vehicles that are scrolled off the left side
   520 	// skip vehicles that are scrolled off the left side
   521 	while (skip--) v = v->next;
   521 	while (v != NULL && skip--) v = v->next;
   522 
   522 
   523 	/* find the vehicle in this row that was clicked */
   523 	/* find the vehicle in this row that was clicked */
   524 	while ((x -= WagonLengthToPixels(v->u.rail.cached_veh_length)) >= 0) {
   524 	while (v != NULL && (x -= WagonLengthToPixels(v->u.rail.cached_veh_length)) >= 0) v = v->next;
   525 		v = v->next;
       
   526 		if (v == NULL) break;
       
   527 	}
       
   528 
   525 
   529 	// if an articulated part was selected, find its parent
   526 	// if an articulated part was selected, find its parent
   530 	while (v != NULL && IsArticulatedPart(v)) v = GetPrevVehicleInChain(v);
   527 	while (v != NULL && IsArticulatedPart(v)) v = GetPrevVehicleInChain(v);
   531 
   528 
   532 	d->wagon = v;
   529 	d->wagon = v;