fix(cache): ignore modded rpfs. (#1651)

This commit is contained in:
Quentin 2023-07-09 16:05:41 +02:00 committed by GitHub
parent a83bc4f44c
commit 95f1db0894
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,12 +17,33 @@ namespace big
m_wrapper_call_back.push_back(cb);
}
static bool safe_open_pack_file(rage::fiPackfile& packfile, const std::u8string& path)
{
bool success = false;
__try
{
success = packfile.OpenPackfile(reinterpret_cast<const char*>(path.c_str()), true, 0, 0);
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
return false;
}
return success;
}
void yim_fipackfile::traverse_rpf_file(const std::u8string& path, int depth)
{
std::string mount_path = std::format("temp{}:/", depth);
rage::fiPackfile packfile;
packfile.OpenPackfile(reinterpret_cast<const char*>(path.c_str()), true, 0, 0);
if (!safe_open_pack_file(packfile, path))
{
LOG(INFO) << "Failed opening " << reinterpret_cast<const char*>(path.c_str());
return;
}
packfile.Mount(mount_path.c_str());
yim_fipackfile rpf_wrapper = yim_fipackfile(&packfile, mount_path);
@ -42,6 +63,14 @@ namespace big
if (encryption_type == 0xFFFFFF9)
continue; // skip AES encrypted RPFs
// OPEN / CFXP
if (encryption_type == 0x4E45504F || encryption_type == 0x50584643)
{
LOG(INFO) << "Modded RPF, skipping " << reinterpret_cast<const char*>(file.u8string().c_str());
continue;
}
traverse_rpf_file(file.u8string(), depth + 1);
}
}