Exemple #1
0
void scaling_t::create_options()
{
  sim->add_option(opt_bool("calculate_scale_factors", calculate_scale_factors));
  sim->add_option(opt_func("normalize_scale_factors", parse_normalize_scale_factors));
  sim->add_option(opt_bool("debug_scale_factors", debug_scale_factors));
  sim->add_option(opt_bool("center_scale_delta", center_scale_delta));
  sim->add_option(opt_float("scale_delta_multiplier", scale_delta_multiplier)); // multiplies all default scale deltas
  sim->add_option(opt_bool("positive_scale_delta", positive_scale_delta));
  sim->add_option(opt_bool("scale_lag", scale_lag));
  sim->add_option(opt_float("scale_factor_noise", scale_factor_noise));
  sim->add_option(opt_float("scale_strength", stats.attribute[ATTR_STRENGTH]));
  sim->add_option(opt_float("scale_agility", stats.attribute[ATTR_AGILITY]));
  sim->add_option(opt_float("scale_stamina", stats.attribute[ATTR_STAMINA]));
  sim->add_option(opt_float("scale_intellect", stats.attribute[ATTR_INTELLECT]));
  sim->add_option(opt_float("scale_spirit", stats.attribute[ATTR_SPIRIT]));
  sim->add_option(opt_float("scale_spell_power", stats.spell_power));
  sim->add_option(opt_float("scale_attack_power", stats.attack_power));
  sim->add_option(opt_float("scale_crit_rating", stats.crit_rating));
  sim->add_option(opt_float("scale_haste_rating", stats.haste_rating));
  sim->add_option(opt_float("scale_mastery_rating", stats.mastery_rating));
  sim->add_option(opt_float("scale_multistrike_rating", stats.multistrike_rating));
  sim->add_option(opt_float("scale_readiness_rating", stats.readiness_rating));
  sim->add_option(opt_float("scale_versatility_rating", stats.versatility_rating));
  sim->add_option(opt_float("scale_weapon_dps", stats.weapon_dps));
  sim->add_option(opt_float("scale_offhand_weapon_dps", stats.weapon_offhand_dps));
  sim->add_option(opt_string("scale_only", scale_only_str));
  sim->add_option(opt_string("scale_over", scale_over));
  sim->add_option(opt_string("scale_over_player", scale_over_player));
}
void reforge_plot_t::create_options()
{
  sim->add_option(opt_int("reforge_plot_iterations", reforge_plot_iterations));
  sim->add_option(opt_float("reforge_plot_target_error", reforge_plot_target_error));
  sim->add_option(opt_int("reforge_plot_step", reforge_plot_step));
  sim->add_option(opt_int("reforge_plot_amount", reforge_plot_amount));
  sim->add_option(opt_string("reforge_plot_stat", reforge_plot_stat_str));
  sim->add_option(opt_bool("reforge_plot_debug", reforge_plot_debug));
}
void scaling_t::create_options()
{
  option_t scaling_options[] =
  {
    // @option_doc loc=global/scale_factors title="Scale Factors"
    opt_bool( "calculate_scale_factors", calculate_scale_factors ),
    opt_func( "normalize_scale_factors", parse_normalize_scale_factors ),
    opt_bool( "debug_scale_factors", debug_scale_factors ),
    opt_bool( "center_scale_delta", center_scale_delta ),
    opt_float( "scale_delta_multiplier", scale_delta_multiplier ), // multiplies all default scale deltas
    opt_bool( "positive_scale_delta", positive_scale_delta ),
    opt_bool( "scale_lag", scale_lag ),
    opt_float( "scale_factor_noise", scale_factor_noise ),
    opt_float( "scale_strength",  stats.attribute[ ATTR_STRENGTH  ] ),
    opt_float( "scale_agility",   stats.attribute[ ATTR_AGILITY   ] ),
    opt_float( "scale_stamina",   stats.attribute[ ATTR_STAMINA   ] ),
    opt_float( "scale_intellect", stats.attribute[ ATTR_INTELLECT ] ),
    opt_float( "scale_spirit",    stats.attribute[ ATTR_SPIRIT    ] ),
    opt_float( "scale_spell_power", stats.spell_power ),
    opt_float( "scale_attack_power", stats.attack_power ),
    opt_float( "scale_expertise_rating", stats.expertise_rating ),
    opt_float( "scale_hit_rating", stats.hit_rating ),
    opt_float( "scale_crit_rating", stats.crit_rating ),
    opt_float( "scale_haste_rating", stats.haste_rating ),
    opt_float( "scale_mastery_rating", stats.mastery_rating ),
    opt_float( "scale_dodge_rating", stats.dodge_rating ),
    opt_float( "scale_parry_rating", stats.parry_rating ),
    opt_float( "scale_weapon_dps", stats.weapon_dps ),
    opt_float( "scale_weapon_speed", stats.weapon_speed ),
    opt_float( "scale_offhand_weapon_dps", stats.weapon_offhand_dps ),
    opt_float( "scale_offhand_weapon_speed", stats.weapon_offhand_speed ),
    opt_string( "scale_only", scale_only_str ),
    opt_string( "scale_over", scale_over ),
    opt_string( "scale_over_player", scale_over_player ),
    opt_null()
  };

  option_t::copy( sim -> options, scaling_options );
}
Exemple #4
0
/**
 * Add hidden options for those supplied by the app modes that are not
 * the calling app.
 *
 * For example, add the opts for gtdownload and gtupload if the caller
 * was gtserver.
 *
 * It's possible for the app to be none of gtserver, gtupload or
 * gtdownload.
 *
 * This allows the options to appear in the config file
 * without generating an error about them being unknown.
 *
 * @param app The mode of the app calling this: 'S', 'D', or 'U'
 */
void
gtBaseOpts::add_options_hidden (const char app)
{
    boost::program_options::options_description hidden_desc;

    if (app != 'D')
    {
        hidden_desc.add_options ()
            (OPT_MAX_CHILDREN,          opt_string(), "hidden, ignored")
            ;
    }

    if (app != 'S')
    {
        hidden_desc.add_options ()
            (OPT_SERVER,                opt_string(), "hidden, ignored")
            (OPT_QUEUE,                 opt_string(), "hidden, ignored")
            ;
    }

    add_desc (hidden_desc, NOT_VISIBLE);
}
void plot_t::create_options()
{
  option_t plot_options[] =
  {
    // @option_doc loc=global/scale_factors title="Plots"
    opt_int( "dps_plot_iterations", dps_plot_iterations ),
    opt_int( "dps_plot_points",     dps_plot_points ),
    opt_string( "dps_plot_stat",    dps_plot_stat_str ),
    opt_float( "dps_plot_step",     dps_plot_step ),
    opt_bool( "dps_plot_debug",     dps_plot_debug ),
    opt_bool( "dps_plot_positive", dps_plot_positive ),
    opt_bool( "dps_plot_negative", dps_plot_negative ),
    opt_null()
  };

  option_t::copy( sim -> options, plot_options );
}
sequence_t::sequence_t( player_t* p, const std::string& sub_action_str ) :
  action_t( ACTION_SEQUENCE, "default", p ),
  waiting( false ), sequence_wait_on_ready( -1 ),
  current_action( -1 ), restarted( false ), last_restart( timespan_t::min() )
{
  trigger_gcd = timespan_t::zero();

  std::vector<std::string> splits = util::string_split( sub_action_str, ":" );
  if ( ! splits.empty() )
  {
    option_t options[] =
    {
      opt_string( "name", name_str ),
      opt_null()
    };
    parse_options( options, splits[ 0 ] );
  }

  // First token is sequence options, so skip
  for ( size_t i = 1; i < splits.size(); ++i )
  {
    std::string::size_type cut_pt = splits[ i ].find( ',' );
    std::string action_name( splits[ i ], 0, cut_pt );
    std::string action_options;

    if ( cut_pt != std::string::npos )
      action_options.assign( splits[ i ], cut_pt + 1, std::string::npos );

    action_t* a = p -> create_action( action_name, action_options );
    if ( ! a )
    {
      sim -> errorf( "Player %s has unknown sequence action: %s\n", p -> name(), splits[ i ].c_str() );
      sim -> cancel();
      continue;
    }

    a -> sequence = true;
    sub_actions.push_back( a );
  }
  sequence_wait_on_ready = wait_on_ready;
  wait_on_ready = -1;
}
Exemple #7
0
/** ***************************************************************************
 * Process command line arguments and set corresponding globals.
 * Shows usage and exits if errors are detected in argument usage.
 *
 */
static int process_args(int argc, char * argv[])
{
  char * options[COUNT_OPTIONS];
  uint64_t user_ram_limit = 0;

#ifdef USE_FIEMAP
  using_fiemap = 1;
#endif

  int rv = optgen_parse(argc, argv, &operation, options);

  if (options[OPT_help]) {
    show_help();
    return 1;
  }

  if (rv == OPTGEN_NONE) {
    show_banner();
    printf("\n");
    printf("Run 'dupd help' for a summary of available options.\n");
    printf("Run 'dupd usage' for more documentation.\n");
    return 1;
  }

  if (rv != OPTGEN_OK) {                                     // LCOV_EXCL_START
    printf("error parsing command line arguments\n");
    return 2;
  }                                                          // LCOV_EXCL_STOP

  if (options[OPT_x_small_buffers]) { x_small_buffers = 1; }
  if (options[OPT_x_testing]) { only_testing = 1; }
  if (options[OPT_quiet]) { log_level = -99; }
  log_level = opt_int(options[OPT_verbose_level], log_level);
  log_level += opt_count(options[OPT_verbose]);
  if (log_level > L_MAX_LOG_LEVEL) { log_level = L_MAX_LOG_LEVEL; }

  if (options[OPT_log_only]) { log_only = 1; }

  if (start_path_state == START_PATH_NULL) {
    start_path[0] = (char *)malloc(DUPD_PATH_MAX);
    getcwd(start_path[0], DUPD_PATH_MAX);
    start_path_count = 1;
    LOG(L_INFO, "Defaulting --path to [%s]\n", start_path[0]);
  }

  if (options[OPT_file] != NULL) {
    file_path = options[OPT_file];
    // file path can be relative, normalize in that case
    if (file_path[0] != '/') {
      file_path = (char *)malloc(DUPD_PATH_MAX);
      free_file_path = 1;
      getcwd(file_path, DUPD_PATH_MAX);
      strcat(file_path, "/");
      strcat(file_path, options[OPT_file]);
    }
  }

  db_path = options[OPT_db];
  if (db_path == NULL) {
    db_path = (char *)malloc(DUPD_PATH_MAX);
    free_db_path = 1;
    snprintf(db_path, DUPD_PATH_MAX, "%s/.dupd_sqlite", getenv("HOME"));
  }

  cache_db_path = options[OPT_cache];
  if (cache_db_path == NULL) {
    cache_db_path = (char *)malloc(DUPD_PATH_MAX);
    free_cache_db_path = 1;
    snprintf(cache_db_path, DUPD_PATH_MAX, "%s/.dupd_cache", getenv("HOME"));
  }

  if (options[OPT_link]) { rmsh_link = RMSH_LINK_SOFT; }
  if (options[OPT_hardlink]) { rmsh_link = RMSH_LINK_HARD; }
  if (options[OPT_hidden]) { scan_hidden = 1; }
  if (options[OPT_no_thread_scan]) { threaded_sizetree = 0; }
  if (options[OPT_hardlink_is_unique]) { hardlink_is_unique = 1; }
  if (options[OPT_one_file_system]) { one_file_system = 1; }
  if (options[OPT_x_no_cache]) { use_hash_cache = 0; }

  cache_min_size =
    (uint64_t)opt_int(options[OPT_x_cache_min_size], cache_min_size);

  hash_one_block_size = opt_int(options[OPT_firstblocksize],
                                hash_one_block_size);

  hash_block_size = opt_int(options[OPT_blocksize], hash_block_size);

  filecmp_block_size = opt_int(options[OPT_fileblocksize], filecmp_block_size);

  hash_one_max_blocks = opt_int(options[OPT_firstblocks], hash_one_max_blocks);

  cut_path = options[OPT_cut];

  exclude_path = options[OPT_exclude_path];
  if (exclude_path != NULL && exclude_path[0] != '/') {
    printf("error: --exclude-path must be absolute\n");
    return 2;
  }

  stats_file = options[OPT_stats_file];

  minimum_file_size = opt_int(options[OPT_minsize], minimum_file_size);
  if (minimum_file_size < 1) { minimum_file_size = 1; }

  path_sep_string = (char *)malloc(2);
  path_sep_string[0] = (char)path_separator;
  path_sep_string[1] = 0;

  char * hash_name = opt_string(options[OPT_hash], "xxhash");
  if (!strcmp("md5", hash_name)) {
    hash_function = HASH_FN_MD5;
  } else if (!strcmp("sha1", hash_name)) {
    hash_function = HASH_FN_SHA1;
  } else if (!strcmp("sha512", hash_name)) {
    hash_function = HASH_FN_SHA512;
  } else if (!strcmp("xxhash", hash_name)) {
    hash_function = HASH_FN_XXHASH;
  } else {
    printf("error: unknown hash %s\n", hash_name);
    return 2;
  }
  hash_bufsize = hash_get_bufsize(hash_function);

  char * report_format_name = opt_string(options[OPT_format], "text");
  if (!strcmp("text", report_format_name)) {
    report_format = REPORT_FORMAT_TEXT;
  } else if (!strcmp("csv", report_format_name)) {
    report_format = REPORT_FORMAT_CSV;
  } else if (!strcmp("json", report_format_name)) {
    report_format = REPORT_FORMAT_JSON;
  } else {
    printf("error: unknown report format %s\n", report_format_name);
    return 2;
  }

  char * buflimstr = opt_string(options[OPT_buflimit], "0");
  if (strcmp("0", buflimstr)) {
    int len = strlen(buflimstr);
    if (buflimstr[len-1] == 'M') {
      user_ram_limit = MB1;
      buflimstr[len-1] = 0;
    } else if (buflimstr[len-1] == 'G') {
      user_ram_limit = GB1;
      buflimstr[len-1] = 0;
    } else {
      user_ram_limit = 1;
    }
    long c = atol(buflimstr);
    user_ram_limit *= c;

    if (user_ram_limit < MB8) {
      user_ram_limit = MB8;
    }
  }

  if (options[OPT_cmp_two]) {
    opt_compare_two = 1;
  }

  if (hash_one_block_size == 0) {
    hash_one_block_size = DEF_HDD_hash_one_block_size;
  }

  round1_max_bytes = hash_one_block_size * hash_one_max_blocks;

  // If user hasn't provided a cache_min_size, do something reasonable
  if (cache_min_size == 0) {
    if (round1_max_bytes < K512) {
      cache_min_size = K512;
    } else {
      cache_min_size = round1_max_bytes;
    }
  }

  char * sortby = opt_string(options[OPT_sort_by], "def");
  if (!strcmp("inode", sortby)) {
    sort_bypass = SORT_BY_INODE;
  } else if (!strcmp("block", sortby)) {
    sort_bypass = SORT_BY_BLOCK;
  } else if (!strcmp("none", sortby)) {
    sort_bypass = SORT_BY_NONE;
  }
  if (sort_bypass != 0) {
    LOG(L_INFO, "Sort bypass set to %s\n", sortby);
    if (hardlink_is_unique) {
      printf("Don't do that..\n");
      return 2;
    }
  }

  if (sort_bypass != 0 && sort_bypass != SORT_BY_BLOCK) {
    using_fiemap = 0;
  }

  if (options[OPT_x_nofie]) { using_fiemap = 0; }

  LOG(L_INFO, "Will be using_fiemap (if available): %d\n", using_fiemap);

  uint64_t ram = total_ram();
  if (user_ram_limit > 0) {
    if (user_ram_limit > ram) {
      buffer_limit = 0.9 * ram;
    } else {
      buffer_limit = user_ram_limit;
    }
  }

  if (buffer_limit == 0) {
    buffer_limit = 0.5 * ram;
    if (x_small_buffers) {
      buffer_limit = MB1;
    }
  }

  int ramm = ram / (1024 * 1024);
  int blim = buffer_limit / (1024 * 1024);
  LOG(L_INFO, "Reported RAM: %dMB  buffer limit: %dMB\n", ramm, blim);

  return 0;
}
Exemple #8
0
void
gtBaseOpts::add_options ()
{
    m_base_desc.add_options ()
        (OPT_BIND_IP           ",b", opt_string(), "Bind IP.")
        (OPT_CRED_FILE         ",c", opt_string(), "Path/file to credentials file.")
        (OPT_CFG_DIR_DEPRECATED  ",C", opt_string(), "Deprecated use " OPT_RESOURCE_DIR ".")
        (OPT_RESOURCE_DIR      ",R", opt_string(), "Full path to a directory containing static resource files (dhparam.pem).")
        (OPT_ADVERT_IP         ",e", opt_string(), "IP Address advertised.")
        (OPT_ADVERT_PORT       ",f", opt_int(),    "TCP Port advertised.")
        (OPT_INTERNAL_PORT     ",i", opt_string(), "Local IP port to bind on.")
        (OPT_LOGGING           ",l", opt_string(), "Path/file to log file, follow"
                                                   " by the log level.")
        (OPT_RATE_LIMIT        ",r", opt_float(),  "Transfer rate limiter in MB/s.")
        (OPT_TIMESTAMP         ",t",               "Add timestamps to messages"
                                                   " logged to the screen.")
        (OPT_VERBOSE,                opt_int(),    "Set on screen verbosity level.")
        (OPT_INACTIVE_TIMEOUT  ",k", opt_int(),    "Timeout transfers after"
                                                   " inactivity in minutes.")
        (OPT_CURL_NO_VERIFY_SSL,                   "Do not verify SSL certificates"
                                                   " of web services.")
        (OPT_PEER_TIMEOUT,           opt_int(),    "Set libtorrent peer timeout in seconds.")
        (OPT_NO_USER_CFG_FILE,                     "Do not allow users to specify a config file.")
        (OPT_ALLOWED_MODES,          opt_string(), "Allowed modes in this GeneTorrent"
                                                   " installation.")
        (OPT_ALLOWED_SERVERS,        opt_string(), "Allowed IP address ranges for WSI, tracker,"
                                                   " and peer traffic.")
        ;

    if (m_use_path_opt)
    {
        m_base_desc.add_options ()
            (OPT_PATH              ",p", opt_string(), "File system path used for"
                                                   " uploads and downloads.")
            ;
    }

    if (m_use_security_api_opt)
    {
        m_base_desc.add_options ()
            (OPT_SECURITY_API,           opt_string(), "SSL Key Signing URL")
            ;
    }
    add_desc (m_base_desc);

    m_cli_desc.add_options ()
        (OPT_CFG_FILE,               opt_string(), "Path/file to optional config file.")
        (OPT_HELP              ",h",               "Show help and exit.")
        (OPT_VERBOSE_INCR      ",v", accumulator<int>(&global_verbosity),
                                                   "Increase on screen verbosity level.")
        (OPT_VERSION,                              "Show version and exit.")
        ;
    if (m_use_alt_storage_opts)
    {
        m_cli_desc.add_options ()
            (OPT_NULL_STORAGE,                     "Enable use of null storage.")
            (OPT_ZERO_STORAGE,                     "Enable use of zero storage.")
            ;
    }
    add_desc (m_cli_desc, VISIBLE, CLI_ONLY);
}