Play your Steam library's Windows games on a jailbroken PS5.
C++
Ask for a restart when the kit changes under Playden
Leonardo Lobato3f2a7c5b4f67
diff --git a/src/homebrew/runtime_host.cpp b/src/homebrew/runtime_host.cppindex f4d661d..2ac4259 100644--- a/src/homebrew/runtime_host.cpp+++ b/src/homebrew/runtime_host.cpp@@ -391,6 +391,15 @@ void RuntimeHost::SetSteamAccount(std::string account_name, std::uint64_t steam_steam_id_ = steam_id;}+// A kit replaced after startup (an upload with --replace) keeps this Playden on the old kit's paths,+// which are gone: say so instead of failing on the first missing file.+std::string RuntimeHost::KitReplaced(const Composition& c) const {+ if (!c.kit || c.kit->manifest_sha256.empty() || !config_.package_operations.hash_file) return {};+ const auto current = config_.package_operations.hash_file(c.kit->view.root / "manifest.json");+ if (current && *current == c.kit->manifest_sha256) return {};+ return "The compatibility kit changed while Playden was running. Quit Playden and start it again.";+}+std::string RuntimeHost::ApplySteamworks(Composition& c, const rt::RuntimeInstall& record) {if (c.kit) {std::string reason;@@ -1018,6 +1027,8 @@ void RuntimeHost::RunPlay(Composition& c, std::uint32_t app_id) {result = rt::LaunchResult::Failure(rt::LaunchError::kPersistence, "Play is unavailable.");} else if (!record) {result = rt::LaunchResult::Failure(rt::LaunchError::kNotFound, "This game has no PS5 title yet.");+ } else if (const auto replaced = KitReplaced(c); !replaced.empty()) {+ result = rt::LaunchResult::Failure(rt::LaunchError::kPreflight, replaced);} else {// Settings changed since the title's publication take effect now, while nothing of// the game runs: Home and Playden then start the same published profile.@@ -1303,6 +1314,7 @@ void RuntimeHost::PublishRecipes(const Composition& c) {std::string RuntimeHost::RunPrepare(Composition& c, const RuntimePrepareRequest& request, bool* awaiting) {if (!c.kit) return Snapshot().kit_reason;+ if (const auto replaced = KitReplaced(c); !replaced.empty()) return replaced;// Where the time before the first step goes: the recipe, the reservation and the title's metadata.const auto began = std::chrono::steady_clock::now();const auto elapsed_ms = [&began] {@@ -1830,6 +1842,7 @@ std::string RuntimeHost::RunMaintenance(Composition& c, std::uint32_t app, Runtifor (const auto& candidate : c.repository.Snapshot())if (candidate.app_id == app) record = candidate;if (!record) return "This game has no PS5 title yet.";+ if (const auto replaced = KitReplaced(c); !replaced.empty()) return replaced;if (const auto refused = MaintenanceRefusal(c, *record); !refused.empty()) {// Settings saved while the game runs reach it on the next Play from Playden.if (action == RuntimeMaintenance::kApplySettings) return "Changes apply the next time Playden starts the game.";diff --git a/src/homebrew/runtime_host.hpp b/src/homebrew/runtime_host.hppindex ea4ea08..324d1b2 100644--- a/src/homebrew/runtime_host.hpp+++ b/src/homebrew/runtime_host.hpp@@ -333,6 +333,8 @@ class RuntimeHost {// Puts the game's steam_api DLLs in the state its "Steam features" setting asks for. Call// only while the game is stopped; empty on success, otherwise why not (for the player).std::string ApplySteamworks(Composition& composition, const runtime::RuntimeInstall& record);+ // Empty while the kit on disk is the one admitted at startup; otherwise what to tell the player.+ std::string KitReplaced(const Composition& composition) const;// Makes an owned, world-writable folder from root down to working 0755 (dxvk.conf goes there).std::string TightenWorkingFolder(const std::filesystem::path& root, const std::string& working);runtime::LaunchPreflight Preflight(Composition& composition, const runtime::RuntimeInstall& record);diff --git a/tests/homebrew_runtime_host_test.cpp b/tests/homebrew_runtime_host_test.cppindex 7c521e8..de70ce2 100644--- a/tests/homebrew_runtime_host_test.cpp+++ b/tests/homebrew_runtime_host_test.cpp@@ -971,6 +971,56 @@ void PlaysReadyTitleThroughHandoff() {// A game Playden ships no recipe for is prepared from Steam's launch options; the// generated recipe is saved and read back after a restart.+// A kit replaced while Playden runs (an upload with --replace) leaves the admitted paths behind:+// Play, preparation and maintenance say to restart Playden instead of failing on a missing file.+void ReplacedKitAsksForRestart() {+ Fixture fixture;+ auto config = fixture.Config();+ config.host_namespace_prefix = fixture.root;+ config.session_data_root = fixture.root / "data";+ config.package_paths.console_data_root = "/data";+ config.package_paths.host_data_root = fixture.root / "data";+ config.package_operations.hash_file = HashArtifactFile;+ config.package_operations.hash_bytes = HashArtifactBytes;+ config.package_operations.free_space_unverifiable = true;+ config.package_operations.validate_bottle = [](const fs::path& bottle) {+ return fs::is_regular_file(bottle / "system.reg") && fs::is_regular_file(bottle / "user.reg");+ };+ auto kit = SyntheticKit(fixture.root / "kit");+ Write(fixture.root / "kit/manifest.json", "{\"kit\":\"first\"}", 0644);+ kit.manifest_sha256 = *HashArtifactFile(fixture.root / "kit/manifest.json");+ config.admit_kit = [kit](std::string*) { return std::optional<RuntimeKit>(kit); };+ unsigned uuids = 0;+ config.uuid = [&uuids]() -> std::optional<std::string> {+ ++uuids; return std::string("00000000-0000-4000-8000-00000000000") + std::to_string(uuids);+ };+ config.unix_time = [] { return std::int64_t{1760000000}; };+ std::vector<std::string> launches;+ config.launch_title = [&launches](const std::string& title, const std::vector<std::string>&) {+ launches.push_back(title);+ return TitleResult{true, 0, "launch"};+ };+ Write(fixture.root / "data/homebrew/FAKE77031/games/220/hl2.exe", "existing-game", 0644);+ RuntimeHost host(config);+ CHECK(host.Start());+ CHECK(WaitFor(host, Started).kit_available);+ host.Prepare(Hl2());+ WaitFor(host, [](const RuntimeSnapshot& s) {+ return !s.preparing_app && !s.installs.empty() && s.installs[0].state == PreparationState::kReady;+ }, 60);++ Write(fixture.root / "kit/manifest.json", "{\"kit\":\"second\"}", 0644);+ const auto handled = host.Snapshot().plays_handled;+ host.Play(220);+ const auto refused = WaitFor(host, [handled](const RuntimeSnapshot& s) { return s.plays_handled > handled; }, 30);+ CHECK(refused.play_refusals.count(220) &&+ refused.play_refusals.at(220).find("Quit Playden and start it again") != std::string::npos);+ CHECK(!refused.handoff_ready && launches.empty());+ host.Prepare(Hl2());+ const auto held = WaitFor(host, [](const RuntimeSnapshot& s) { return s.refusals.count(220) != 0; }, 30);+ CHECK(held.refusals.at(220).find("changed while Playden was running") != std::string::npos);+}+void PreparesGameWithoutShippedRecipe() {Fixture fixture;auto config = fixture.Config();@@ -1926,6 +1976,7 @@ int main(int argc, char** argv) {RetryAfterKitRespinBindsTheNewArtifacts();RepairsBottleRegistryModes();PlaysReadyTitleThroughHandoff();+ ReplacedKitAsksForRestart();MaintainsReadyTitle();SettingsSavedDuringPrepareReachReadyTitle();KitRespinKeepsWaitingSettingsUpdate();