Exemplo n.º 1
0
void t_adv_blacksmith::calculate_purchase_options( t_purchase_options& purchase_options, t_creature_array const& army ) const
{
	for (int i = 0; i < t_creature_array::k_size; i++)
	{
		t_hero const* hero = army[i].get_const_hero();
		if (hero == NULL) 
			continue;

		for (int j=0; j < k_max_potions; j++)
		{
			t_artifact_value_query query_params( &army, hero, m_available_potions[j] );
			int cost = get_cost( m_available_potions[j] );
			float value = ai_value_of_artifact( query_params );
			
			if (value > 0)
				purchase_options.insert(t_purchase_options::value_type( value, cost ));
		}

		for (int j=0; j<k_max_items; j++)
		{
			t_artifact_value_query query_params( &army, hero, m_available_items[j] );
			int cost = get_cost( m_available_items[j] );
			float value = ai_value_of_artifact( query_params );
			
			if (value > 0)
				purchase_options.insert(t_purchase_options::value_type( value, cost ));
		}
	}
}
std::shared_ptr<stats::QueryMetric::QueryParams> StatsTestsUtil::GetQueryParams(
    std::shared_ptr<uchar> &type_buf, std::shared_ptr<uchar> &format_buf,
    std::shared_ptr<uchar> &val_buf) {

  // Type
  uchar *type_buf_data = new uchar[1];
  type_buf_data[0] = 'x';
  type_buf.reset(type_buf_data);
  stats::QueryMetric::QueryParamBuf type(type_buf_data, 1);

  // Format
  uchar *format_buf_data = new uchar[1];
  format_buf_data[0] = 'y';
  format_buf.reset(format_buf_data);
  stats::QueryMetric::QueryParamBuf format(format_buf_data, 1);

  // Value
  uchar *val_buf_data = new uchar[1];
  val_buf_data[0] = 'z';
  val_buf.reset(val_buf_data);
  stats::QueryMetric::QueryParamBuf val(val_buf_data, 1);

  // Construct a query param object
  std::shared_ptr<stats::QueryMetric::QueryParams> query_params(
      new stats::QueryMetric::QueryParams(format, type, val, 1));
  return query_params;
}
Exemplo n.º 3
0
int AxisCam::get_focus(int* focus)
{
    if (last_autofocus_enabled)
        set_focus(0, true); // manual focus but don't move it

    int ret = query_params();

    if (last_autofocus_enabled)
        set_focus(0); // re-enable autofocus

    *focus = last_focus;
    return ret;
}
Exemplo n.º 4
0
std::vector<std::shared_ptr<const X509_Certificate>> Certificate_Store_MacOS::find_all_certs(
         const X509_DN& subject_dn,
         const std::vector<uint8_t>& key_id) const
   {
   std::vector<uint8_t> dn_data;
   DER_Encoder encoder(dn_data);
   normalize(subject_dn).encode_into(encoder);

   scoped_CFType<CFDataRef> dn_cfdata(createCFDataView(dn_data));
   check_notnull(dn_cfdata, "create DN search object");

   Certificate_Store_MacOS_Impl::Query query_params(
      {
         {kSecAttrSubject, dn_cfdata.get()}
      });

   scoped_CFType<CFDataRef> keyid_cfdata(createCFDataView(key_id));
   check_notnull(keyid_cfdata, "create key ID search object");
   if(!key_id.empty())
      {
      query_params.push_back({kSecAttrSubjectKeyID, keyid_cfdata.get()});
      }

   scoped_CFType<CFArrayRef> result(m_impl->search(std::move(query_params)));

   if(!result)
      {
      return {};  // no certificates found
      }

   const auto count = CFArrayGetCount(result.get());
   BOTAN_ASSERT(count > 0, "certificate result list contains data");

   std::vector<std::shared_ptr<const X509_Certificate>> output;
   output.reserve(count);
   for(unsigned int i = 0; i < count; ++i)
      {
      auto cfCert = to_SecCertificateRef(CFArrayGetValueAtIndex(result.get(), i));
      output.emplace_back(readCertificate(cfCert));
      }

   return output;
   }
Exemplo n.º 5
0
void AxisCam::set_host(string ip)
{
    ostringstream oss;
    oss << "http://" << ip << "/jpg/image.jpg";
    image_url = new char[oss.str().length()+1];
    strcpy(image_url, oss.str().c_str());

    oss.str(""); // clear it
    oss << "http://" << ip << "/axis-cgi/com/ptz.cgi";
    ptz_url = new char[oss.str().length()+1];
    strcpy(ptz_url, oss.str().c_str());

    jpeg_curl = curl_easy_init();
    curl_easy_setopt(jpeg_curl, CURLOPT_URL, image_url);
    curl_easy_setopt(jpeg_curl, CURLOPT_WRITEFUNCTION, AxisCam::jpeg_write);
    curl_easy_setopt(jpeg_curl, CURLOPT_WRITEDATA, this);
    curl_easy_setopt(jpeg_curl, CURLOPT_TIMEOUT, 1);
    curl_easy_setopt(jpeg_curl, CURLOPT_FAILONERROR, 1);

    getptz_curl = curl_easy_init();
    curl_easy_setopt(getptz_curl, CURLOPT_URL, ptz_url);
    curl_easy_setopt(getptz_curl, CURLOPT_WRITEFUNCTION, AxisCam::ptz_write);
    curl_easy_setopt(getptz_curl, CURLOPT_WRITEDATA, this);
    curl_easy_setopt(getptz_curl, CURLOPT_POSTFIELDS, "query=position");
    curl_easy_setopt(getptz_curl, CURLOPT_TIMEOUT, 1);
    curl_easy_setopt(getptz_curl, CURLOPT_FAILONERROR, 1);

    setptz_curl = curl_easy_init();
    curl_easy_setopt(setptz_curl, CURLOPT_URL, ptz_url);
    curl_easy_setopt(setptz_curl, CURLOPT_WRITEFUNCTION, AxisCam::ptz_write);
    curl_easy_setopt(setptz_curl, CURLOPT_WRITEDATA, this);
    curl_easy_setopt(setptz_curl, CURLOPT_TIMEOUT, 1);

    if (query_params())
        fprintf(stderr, "[libaxis] Failed to query the camera parameters.\n");
}
Exemplo n.º 6
0
void AxisCam::print_params()
{
    query_params();
    printf("pan = %f\ntilt = %f\nzoom = %f\n",
           last_pan, last_tilt, last_zoom);
}