Play your Steam library's Windows games on a jailbroken PS5.
C++
Check every program for a missing PhysX engine
Leonardo Lobatoe357fff839e1
diff --git a/src/homebrew/runtime_host.cpp b/src/homebrew/runtime_host.cppindex 0d8f0aa..66677ec 100644--- a/src/homebrew/runtime_host.cpp+++ b/src/homebrew/runtime_host.cpp@@ -1005,12 +1005,9 @@ std::string RuntimeHost::InstallScriptsStep(const GameFiles& files) {// Still without the engine the game was built for, and a package added to its folder would be found: say which.std::optional<std::string> physx_needed;if (redist.physx_searched)- for (const auto& program : files.programs) {- if (!rt::ProgramUsesPhysx(files.root.string(), program) || rt::PhysxEngineBeside(files.root.string(), program)) continue;- const auto version = rt::PhysxVersionBeside(files.root.string(), program);- if (!rt::BottleHasPhysxEngine(files.prefix, version)) physx_needed = version;- break;- }+ physx_needed = rt::MissingPhysxEngine(files.root.string(), files.programs, files.prefix, [&files](const std::string& program) {+ return rt::ProgramUsesPhysx(files.root.string(), program);+ });if (physx_needed) Log("redist app=" + std::to_string(number) + " physx engine missing version=" + (physx_needed->empty() ? "unknown" : *physx_needed));Publish([&](RuntimeSnapshot& s) {if (physx_needed) s.physx_needed[number] = *physx_needed;diff --git a/src/runtime/redist_install.cpp b/src/runtime/redist_install.cppindex 012591c..5f38871 100644--- a/src/runtime/redist_install.cpp+++ b/src/runtime/redist_install.cpp@@ -809,6 +809,17 @@ bool BottleHasPhysxEngine(const std::string& prefix_dir, const std::string& versreturn false;}+std::optional<std::string> MissingPhysxEngine(const std::string& game_root, const std::vector<std::string>& programs,+ const std::string& prefix_dir,+ const std::function<bool(const std::string&)>& uses_physx) {+ for (const auto& program : programs) {+ if (!uses_physx(program) || PhysxEngineBeside(game_root, program)) continue;+ const auto version = PhysxVersionBeside(game_root, program);+ if (!BottleHasPhysxEngine(prefix_dir, version)) return version;+ }+ return std::nullopt;+}+bool RedistIsPhysx(const std::string& name) { return Lower(name).find("physx") != std::string::npos; }RedistInstallResult InstallRedistributables(const std::string& game_root, const std::string& install_dir,diff --git a/src/runtime/redist_install.h b/src/runtime/redist_install.hindex bf70e34..a48cc8e 100644--- a/src/runtime/redist_install.h+++ b/src/runtime/redist_install.h@@ -53,6 +53,12 @@ bool PhysxEngineBeside(const std::string& game_root, const std::string& program)// With an empty version, any engine.bool BottleHasPhysxEngine(const std::string& prefix_dir, const std::string& version);+// The PhysX version the first of a game's programs needs and the bottle lacks (empty when the program doesn't say+// which), of those uses_physx accepts and that have no engine of their own; nullopt when none lacks one.+std::optional<std::string> MissingPhysxEngine(const std::string& game_root, const std::vector<std::string>& programs,+ const std::string& prefix_dir,+ const std::function<bool(const std::string&)>& uses_physx);+// Whether a redistributable's name (an install script's entry) is PhysX's.bool RedistIsPhysx(const std::string& name);diff --git a/tests/runtime_redist_test.cpp b/tests/runtime_redist_test.cppindex 37c290c..a72877e 100644--- a/tests/runtime_redist_test.cpp+++ b/tests/runtime_redist_test.cpp@@ -502,6 +502,16 @@ void TestFoundPhysx() {BottleHasPhysxEngine(bottle.string(), ""));WriteText(bottle / "drive_c/Program Files (x86)/AGEIA Technologies/v2.8.1/PhysXCore.dll", "core");CHECK(BottleHasPhysxEngine(bottle.string(), "2.8.1"));+ // Every program counts: one with its engine doesn't hide another that lacks its own.+ const auto uses = [](const std::string& program) { return program != "Tools/Plain.exe"; };+ std::string older = resource;+ older[older.size() - 8] = '\x07'; // 2.7+ older[older.size() - 2] = '\x05'; // .5+ WriteText(versioned / "Older/NxCooking.dll", older);+ CHECK(PhysxVersionBeside(versioned.string(), "Older/Game.exe") == "2.7.5");+ CHECK((MissingPhysxEngine(versioned.string(), {"Tools/Plain.exe", "Binaries/Game.exe", "Local/Game.exe", "Older/Game.exe"},+ bottle.string(), uses) == std::optional<std::string>("2.7.5")));+ CHECK(!MissingPhysxEngine(versioned.string(), {"Tools/Plain.exe", "Binaries/Game.exe", "Local/Game.exe"}, bottle.string(), uses));}// Needed, and nothing to install.