add --multiply option to convert-rare-item-set

This commit is contained in:
Martin Michelsen
2024-03-07 22:51:32 -08:00
parent 70c57e7727
commit 8a7e19757a
3 changed files with 26 additions and 2 deletions
+9 -2
View File
@@ -1605,7 +1605,7 @@ Action a_cat_client(
Action a_convert_rare_item_set(
"convert-rare-item-set", "\
convert-rare-item-set INPUT-FILENAME [OUTPUT-FILENAME]\n\
convert-rare-item-set INPUT-FILENAME [OUTPUT-FILENAME] [OPTIONS]\n\
If OUTPUT-FILENAME is not given, print the contents of a rare item table in\n\
a human-readable format. Otherwise, convert the input rare item set to a\n\
different format and write it to OUTPUT-FILENAME. Both filenames must end\n\
@@ -1614,10 +1614,13 @@ Action a_convert_rare_item_set(
.gsl (PSO BB little-endian GSL archive)\n\
.gslb (PSO GC big-endian GSL archive)\n\
.afs (PSO V2 little-endian AFS archive)\n\
.rel (Schtserv rare table; cannot be used in output filename)\n",
.rel (Schtserv rare table; cannot be used in output filename)\n\
If the --multiply=X option is given, multiplies all drop rates by X (given\n\
as a decimal value).\n",
+[](Arguments& args) {
auto version = get_cli_version(args);
double rate_factor = args.get<double>("multiply");
auto s = make_shared<ServerState>("system/config.json");
s->load_config_early();
s->load_patch_indexes(false);
@@ -1646,6 +1649,10 @@ Action a_convert_rare_item_set(
throw runtime_error("cannot determine input format; use a filename ending with .json, .gsl, .gslb, .afs, or .rel");
}
if (rate_factor != 1.0) {
rs->multiply_all_rates(rate_factor);
}
string output_filename = args.get<string>(2, false);
if (output_filename.empty() || (output_filename == "-")) {
rs->print_all_collections(stdout, s->item_name_index(version));