Fix broad search issue with old UE games at FindFilePath

This commit is contained in:
cdozdil committed 2026-09-13 14:40:13 +03:00
1 parent d817d5b4c8
commit bd6407daec
1 file changed
+24 -1
+24 -1
View File
@@ -562,7 +562,30 @@ std::optional<std::filesystem::path> Util::FindFilePath(const std::filesystem::p
// Move up two more levels from 'parent' to reach UE project root but one level for KCD2
std::filesystem::path gameRoot;
if (cnt < 2)
gameRoot = parent.parent_path().parent_path();
{
do
{
// Check one below Win64, old UE games have binaries here
gameRoot = parent.parent_path();
if (std::filesystem::exists(gameRoot / "Binaries") &&
std::filesystem::is_directory(gameRoot / "Binaries"))
{
gameRoot = gameRoot.parent_path();
break;
}
// Check two below Win64, newer UE games have binaries here
gameRoot = gameRoot.parent_path();
if (std::filesystem::exists(gameRoot / "Binaries") &&
std::filesystem::is_directory(gameRoot / "Binaries"))
{
gameRoot = gameRoot.parent_path();
break;
}
} while (false);
}
else
gameRoot = parent.parent_path();