diff --git a/common/type_system/TypeSystem.cpp b/common/type_system/TypeSystem.cpp index c37fc7dc7..fad3de375 100644 --- a/common/type_system/TypeSystem.cpp +++ b/common/type_system/TypeSystem.cpp @@ -1308,6 +1308,14 @@ int TypeSystem::get_size_in_type(const Field& field) const { } } +std::vector TypeSystem::get_all_type_names() { + std::vector results = {}; + for (const auto& [type_name, type_info] : m_types) { + results.push_back(type_name); + } + return results; +} + std::vector TypeSystem::search_types_by_parent_type( const std::string& parent_type, const std::vector& existing_matches) { diff --git a/common/type_system/TypeSystem.h b/common/type_system/TypeSystem.h index 93b366cfe..7be9a81b3 100644 --- a/common/type_system/TypeSystem.h +++ b/common/type_system/TypeSystem.h @@ -263,6 +263,7 @@ class TypeSystem { m_types_allowed_to_be_redefined.push_back(type_name); } + std::vector get_all_type_names(); std::vector search_types_by_parent_type( const std::string& parent_type, const std::vector& existing_matches = {}); diff --git a/tools/type_searcher/main.cpp b/tools/type_searcher/main.cpp index 14b010a3f..147f8d56a 100644 --- a/tools/type_searcher/main.cpp +++ b/tools/type_searcher/main.cpp @@ -24,11 +24,13 @@ int main(int argc, char** argv) { int method_id_min = -1; int type_size = -1; std::string field_json = ""; + bool get_all = false; lg::initialize(); CLI::App app{"OpenGOAL Type Searcher"}; app.add_option("--output-path", output_path, "Where to output the search results file"); + app.add_flag("-a,--all", get_all, "Just retrieve all possible type names"); app.add_option("-g,--game", game_name, "Specify the game name, defaults to 'jak1'"); app.add_option("-s,--size", type_size, "The size of the type we are searching for"); app.add_option("-m,--method_id", method_id_min, @@ -61,6 +63,20 @@ int main(int argc, char** argv) { return 1; } + auto results = nlohmann::json::array({}); + + if (get_all) { + auto type_names = dts.ts.get_all_type_names(); + for (const auto& name : type_names) { + fmt::print("{}\n", name); + results.push_back(name); + } + + // Output the results as a json list + file_util::write_text_file(output_path.string(), results.dump()); + return 0; + } + std::vector potential_types = {}; // First filter by parent type is available @@ -97,7 +113,6 @@ int main(int argc, char** argv) { potential_types = dts.ts.search_types_by_fields(search_fields, potential_types); } - auto results = nlohmann::json::array({}); for (const auto& val : potential_types) { fmt::print("{}\n", val); results.push_back(val);