[Patcher] Check for missing entries and use relative paths

This commit is contained in:
Adrian 2024-09-22 23:12:02 +01:00 committed by Radosław Gliński
parent 2fcf8c1163
commit 7003e54e51
2 changed files with 23 additions and 6 deletions

View File

@ -65,7 +65,8 @@ PatchFileEntry PatchDB::ReadPatchFile(
try {
patch_toml_fields = ParseFile(file_path);
} catch (...) {
XELOGE("PatchDB: Cannot load patch file: {}", path_to_utf8(file_path));
XELOGE("PatchDB: Cannot load patch file: {}",
path_to_utf8(file_path.filename()));
patch_file.title_id = -1;
return patch_file;
};
@ -74,6 +75,13 @@ PatchFileEntry PatchDB::ReadPatchFile(
auto title_id = patch_toml_fields.get_as<std::string>("title_id");
auto hashes_node = patch_toml_fields.get("hash");
if (!title_name || !title_id || !hashes_node) {
XELOGE("PatchDB: Cannot load patch file: {}",
path_to_utf8(file_path.filename()));
patch_file.title_id = -1;
return patch_file;
}
patch_file.title_id = strtoul(title_id->get().c_str(), NULL, 16);
patch_file.title_name = title_name->get();
ReadHashes(patch_file, hashes_node);

View File

@ -116,13 +116,17 @@ void PluginLoader::LoadTitleConfig(const uint32_t title_id) {
plugin_entry.as_table()->get_as<bool>("is_enabled")->get();
}
if (!plugin_entry.as_table()->contains("hash")) {
entry.hashes = GetHashes(plugin_entry.as_table()->get("hash"));
if (!plugin_entry.as_table()->contains("hash") || entry.hashes.empty()) {
const std::string file =
fmt::format("plugins\\{:08X}\\plugins.toml", title_id);
XELOGE("Hash error! skipping plugin {} in: {}", entry.name,
path_to_utf8(title_plugins_config));
path_to_utf8(file));
continue;
}
entry.hashes = GetHashes(plugin_entry.as_table()->get("hash"));
plugin_configs_.push_back(entry);
}
}
@ -136,8 +140,13 @@ std::vector<uint64_t> PluginLoader::GetHashes(
}
if (toml_entry->is_value()) {
hashes.push_back(xe::string_util::from_string<uint64_t>(
toml_entry->as_string()->get(), true));
const std::string hash = toml_entry->as_string()->get();
if (hash.empty()) {
return hashes;
}
hashes.push_back(xe::string_util::from_string<uint64_t>(hash, true));
}
if (toml_entry->is_array()) {