train_cmd.c
changeset 2617 a9e1a187de99
parent 2612 744aef3af72f
child 2618 7546b838230b
equal deleted inserted replaced
2616:e47170379049 2617:a9e1a187de99
   750 			v->date_of_last_service = _date;
   750 			v->date_of_last_service = _date;
   751 			v->build_year = _cur_year;
   751 			v->build_year = _cur_year;
   752 			v->type = VEH_Train;
   752 			v->type = VEH_Train;
   753 			v->cur_image = 0xAC2;
   753 			v->cur_image = 0xAC2;
   754 
   754 
       
   755 			v->u.rail.shortest_platform[0] = 255;
       
   756 			v->u.rail.shortest_platform[1] = 0;
       
   757 
   755 			VehiclePositionChanged(v);
   758 			VehiclePositionChanged(v);
   756 
   759 
   757 			if (rvi->flags & RVI_MULTIHEAD && !HASBIT(p2, 0)) {
   760 			if (rvi->flags & RVI_MULTIHEAD && !HASBIT(p2, 0)) {
   758 				AddRearEngineToMultiheadedTrain(vl[0], vl[1], true);
   761 				AddRearEngineToMultiheadedTrain(vl[0], vl[1], true);
   759 			} else {
   762 			} else {
  2346 
  2349 
  2347 	// Otherwise set it, and determine the destination tile.
  2350 	// Otherwise set it, and determine the destination tile.
  2348 	v->current_order = *order;
  2351 	v->current_order = *order;
  2349 
  2352 
  2350 	v->dest_tile = 0;
  2353 	v->dest_tile = 0;
       
  2354 
       
  2355 	// store the station length if no shorter station was visited this order round
       
  2356 	if (v->cur_order_index == 0) {
       
  2357 		if (v->u.rail.shortest_platform[1] != 0 && v->u.rail.shortest_platform[1] != 255) {
       
  2358 			// we went though a whole round of orders without interruptions, so we store the length of the shortest station
       
  2359 			v->u.rail.shortest_platform[0] = v->u.rail.shortest_platform[1];
       
  2360 		}
       
  2361 		// all platforms are shorter than 255, so now we can find the shortest in the next order round. They might have changed size
       
  2362 		v->u.rail.shortest_platform[1] = 255;
       
  2363 	}
       
  2364 
       
  2365 	if (v->last_station_visited != INVALID_STATION) {
       
  2366 		Station *st = GetStation(v->last_station_visited);
       
  2367 		if (TileBelongsToRailStation(st, v->tile)) {
       
  2368 			byte length = GetStationPlatforms(st, v->tile);
       
  2369 
       
  2370 			if (length < v->u.rail.shortest_platform[1]) {
       
  2371 				v->u.rail.shortest_platform[1] = length;
       
  2372 			}
       
  2373 		}
       
  2374 	}
  2351 
  2375 
  2352 	result = false;
  2376 	result = false;
  2353 	switch (order->type) {
  2377 	switch (order->type) {
  2354 		case OT_GOTO_STATION:
  2378 		case OT_GOTO_STATION:
  2355 			if (order->station == v->last_station_visited)
  2379 			if (order->station == v->last_station_visited)