diff --git a/src/Main.cc b/src/Main.cc index 0a924b75..204b6bdf 100644 --- a/src/Main.cc +++ b/src/Main.cc @@ -2153,16 +2153,20 @@ Action a_convert_rare_item_set( } }); -static shared_ptr load_common_item_set(const std::string& filename, bool big_endian) { +static shared_ptr load_common_item_set( + const std::string& filename, const std::string& ct_filename, bool big_endian) { auto data = make_shared(phosg::load_file(filename)); if (filename.ends_with(".json")) { return make_shared(phosg::JSON::parse(*data)); + } else if (filename.ends_with(".afs")) { + auto ct_data = make_shared(phosg::load_file(ct_filename)); + return make_shared(data, ct_data); } else if (filename.ends_with(".gsl")) { return make_shared(data, big_endian); } else if (filename.ends_with(".gslb")) { return make_shared(data, true); } else { - throw runtime_error("cannot determine input format; use a filename ending with .json, .gsl, or .gslb"); + throw runtime_error("cannot determine input format; use a filename ending with .json, .afs, .gsl, or .gslb"); } } @@ -2173,6 +2177,7 @@ Action a_convert_common_item_set( OUTPUT-FILENAME or stdout. The input filename must end in one of the\n\ following extensions:\n\ .json (newserv JSON common item table)\n\ + .afs (PSO v2 AFS archive; --ct-filename is required in this case)\n\ .gsl (PSO BB little-endian GSL archive)\n\ .gslb (PSO GC big-endian GSL archive)\n", +[](phosg::Arguments& args) { @@ -2181,7 +2186,7 @@ Action a_convert_common_item_set( throw runtime_error("input filename must be given"); } - auto cs = load_common_item_set(input_filename, args.get("big-endian")); + auto cs = load_common_item_set(input_filename, args.get("ct-filename", false), args.get("big-endian")); const string& output_filename = args.get(2, false); if (output_filename.empty()) { cs->print(stdout); @@ -2203,8 +2208,8 @@ Action a_compare_common_item_set( throw runtime_error("two input filenames must be given"); } - auto cs1 = load_common_item_set(input_filename1, args.get("big-endian1")); - auto cs2 = load_common_item_set(input_filename2, args.get("big-endian2")); + auto cs1 = load_common_item_set(input_filename1, args.get("ct-filename1", false), args.get("big-endian1")); + auto cs2 = load_common_item_set(input_filename2, args.get("ct-filename2", false), args.get("big-endian2")); cs1->print_diff(stdout, *cs2); });