Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into zoomer
Browse files Browse the repository at this point in the history
  • Loading branch information
dallmeyer committed Sep 2, 2024
2 parents 26b0507 + 6b8e44e commit 9c2f542
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 2 deletions.
4 changes: 4 additions & 0 deletions decompiler/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,10 @@ Config make_config_via_json(nlohmann::json& json) {
inputs_json.at("animated_textures").get<std::unordered_set<std::string>>();
}

if (json.contains("common_art_groups")) {
config.common_art_groups = json.at("common_art_groups").get<std::unordered_set<std::string>>();
}

if (inputs_json.contains("common_tpages")) {
config.common_tpages = inputs_json.at("common_tpages").get<std::unordered_set<int>>();
}
Expand Down
1 change: 1 addition & 0 deletions decompiler/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ struct Config {
std::unordered_map<std::string, int> bad_format_strings;

std::unordered_set<std::string> animated_textures;
std::unordered_set<std::string> common_art_groups;
std::unordered_set<int> common_tpages;

std::vector<std::string> levels_to_extract;
Expand Down
6 changes: 6 additions & 0 deletions decompiler/config/jak1/jak1_config.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@
// whether or not to dump out streamed audio files to decompiler_out/<game>/audio
"rip_streamed_audio": false,

// art groups that should always be possible to access, e.g. "common_art_groups": ["eichar-racer+0-ag", "racer-ag", "ef-plane-ag"]
"common_art_groups": [],

// tpages that should always be possible to access, e.g. "common_tpages": [1119],
"common_tpages": [],

////////////////////////////
// PATCHING OPTIONS
////////////////////////////
Expand Down
34 changes: 32 additions & 2 deletions decompiler/level_extractor/extract_level.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@ void extract_common(const ObjectFileDB& db,
const TextureDB& tex_db,
const std::string& dgo_name,
const fs::path& output_folder,
const Config& config) {
const Config& config,
const std::vector<std::string>& all_dgo_names) {
if (db.obj_files_by_dgo.count(dgo_name) == 0) {
lg::warn("Skipping common extract for {} because the DGO was not part of the input", dgo_name);
return;
Expand All @@ -278,6 +279,35 @@ void extract_common(const ObjectFileDB& db,
add_all_textures_from_level(tfrag_level, "ARTSPOOL", tex_db);
extract_art_groups_from_level(db, tex_db, {}, "ARTSPOOL", tfrag_level, art_group_data);

// copy in any art groups that were requested to be common
if (config.common_art_groups.size() > 0) {
std::unordered_set<std::string> art_groups_made_common;
for (const std::string& lvl_dgo_name : all_dgo_names) {
// exit early if we've found everything
if (config.common_art_groups.size() == art_groups_made_common.size()) {
lg::info("Found all requested art groups to be made common!");
break;
}

lg::info("Looking for common art groups in {}", lvl_dgo_name);
auto tex_remap = extract_tex_remap(db, lvl_dgo_name);
if (db.obj_files_by_dgo.count(lvl_dgo_name)) {
const auto& files = db.obj_files_by_dgo.at(lvl_dgo_name);
for (const auto& file : files) {
if (!art_groups_made_common.contains(file.name) && config.common_art_groups.contains(file.name)) {
lg::info("Art group {} was requested to be made common, we found it in {}!", file.name,
lvl_dgo_name);
const auto& ag_file = db.lookup_record(file);
extract_merc(ag_file, tex_db, db.dts, tex_remap, tfrag_level, false, db.version());
extract_joint_group(ag_file, db.dts, db.version(), art_group_data);
// track found art groups so we don't borther re-processing in a later level
art_groups_made_common.insert(file.name);
}
}
}
}
}

std::set<std::string> textures_we_have;

// put _all_ index textures in common.
Expand Down Expand Up @@ -378,7 +408,7 @@ void extract_all_levels(const ObjectFileDB& db,
const std::string& common_name,
const Config& config,
const fs::path& output_path) {
extract_common(db, tex_db, common_name, output_path, config);
extract_common(db, tex_db, common_name, output_path, config, dgo_names);
auto entities_dir = file_util::get_jak_project_dir() / "decompiler_out" /
game_version_names[config.game_version] / "entities";
file_util::create_dir_if_needed(entities_dir);
Expand Down
Binary file modified out/build/Release/bin/decompiler.exe
Binary file not shown.
Binary file modified out/build/Release/bin/extractor.exe
Binary file not shown.
Binary file modified out/build/Release/bin/gk.exe
Binary file not shown.
Binary file modified out/build/Release/bin/goalc.exe
Binary file not shown.

0 comments on commit 9c2f542

Please sign in to comment.