From bd6407daecf9fb93cba15a92cd6fc5c358c6f7a2 Mon Sep 17 00:00:00 2001 From: cdozdil Date: Sun, 13 Sep 2026 14:40:13 +0300 Subject: [PATCH] Fix broad search issue with old UE games at FindFilePath --- OptiScaler/Util.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/OptiScaler/Util.cpp b/OptiScaler/Util.cpp index 4df963da..1e68b2f1 100644 --- a/OptiScaler/Util.cpp +++ b/OptiScaler/Util.cpp @@ -562,7 +562,30 @@ std::optional 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();