src/autoreplace_cmd.cpp
changeset 8021 9825c7a74648
parent 8020 58097db31633
child 8022 32b885de2410
equal deleted inserted replaced
8020:58097db31633 8021:9825c7a74648
   247 		}
   247 		}
   248 	} else { // flags & DC_EXEC not set
   248 	} else { // flags & DC_EXEC not set
   249 		CommandCost tmp_move;
   249 		CommandCost tmp_move;
   250 
   250 
   251 		if (old_v->type == VEH_TRAIN && IsFrontEngine(old_v)) {
   251 		if (old_v->type == VEH_TRAIN && IsFrontEngine(old_v)) {
   252 			Vehicle *next_veh = IsMultiheaded(old_v) ? old_v->Next()->Next() : old_v->Next();
   252 			Vehicle *next_veh = GetNextVehicle(old_v);
       
   253 			if (IsMultiheaded(next_veh) && !IsTrainEngine(next_veh)) next_veh = next_veh->Next(); // don't try to move the rear multiheaded engine
   253 			if (next_veh != NULL) {
   254 			if (next_veh != NULL) {
   254 				/* Verify that the wagons can be placed on the engine in question.
   255 				/* Verify that the wagons can be placed on the engine in question.
   255 				 * This is done by building an engine, test if the wagons can be added and then sell the test engine. */
   256 				 * This is done by building an engine, test if the wagons can be added and then sell the test engine. */
   256 				DoCommand(old_v->tile, new_engine_type, 3, DC_EXEC, GetCmdBuildVeh(old_v));
   257 				DoCommand(old_v->tile, new_engine_type, 3, DC_EXEC, GetCmdBuildVeh(old_v));
   257 				Vehicle *temp = GetVehicle(_new_vehicle_id);
   258 				Vehicle *temp = GetVehicle(_new_vehicle_id);