Play your Steam library's Windows games on a jailbroken PS5.
C++
Accept a shipped recipe with any kit
Timothy Slater04a149296d3b
diff --git a/src/homebrew/runtime_host.cpp b/src/homebrew/runtime_host.cppindex 76aae87..7063f0f 100644--- a/src/homebrew/runtime_host.cpp+++ b/src/homebrew/runtime_host.cpp@@ -1474,9 +1474,9 @@ std::string RuntimeHost::RunPrepare(Composition& c, const RuntimePrepareRequest&std::string reason;const rt::GameRecipe* recipe = RecipeForPrepare(c, request, &reason);if (!recipe) return reason;- // A shipped recipe is trusted only from the kit that carries it.- if (!rt::IsGeneratedRecipeId(recipe->id) &&- (recipe->id != c.kit->view.recipe.id || std::to_string(recipe->version) != c.kit->view.recipe.version))+ // Playden ships its recipes (runtime/recipes) and the kit carries a copy of one of them;+ // only that one must agree with the kit, as the kit's shell was packaged for it.+ if (recipe->id == c.kit->view.recipe.id && std::to_string(recipe->version) != c.kit->view.recipe.version)return "The installed compatibility kit was built for another version of this game's setup.";if (recipe->launch_entries.empty()) return "Steam lists no Windows program this console can start for this game.";const auto settings = config_.settings_record ? config_.settings_record(request.app_id) : std::nullopt;@@ -2169,7 +2169,13 @@ void RuntimeHost::Run() {operations.canceled = [this] { return Stopping(); };operations.progress = [this](std::uint64_t done, std::uint64_t total) { ReportWork(done, total); };operations.log = [this](const std::string& line) { Log(line); };- c.installer = std::make_unique<rt::FilesystemPackageInstaller>(c.kit->view, config_.package_paths, operations);+ auto installer = std::make_unique<rt::FilesystemPackageInstaller>(c.kit->view, config_.package_paths, operations);+ // Records prepared with a recipe Playden ships resolve whatever recipe the kit carries.+ std::vector<std::string> shipped;+ for (const auto& recipe : c.recipes)+ if (!rt::IsGeneratedRecipeId(recipe.id)) shipped.push_back(recipe.id);+ installer->AcceptShippedRecipes(std::move(shipped));+ c.installer = std::move(installer);} else {if (kit_reason.empty()) kit_reason = "No verified compatibility kit is installed.";c.installer = std::make_unique<UnavailablePackageInstaller>(kit_reason);diff --git a/src/runtime/package_installer.cpp b/src/runtime/package_installer.cppindex 399f63d..35e721f 100644--- a/src/runtime/package_installer.cpp+++ b/src/runtime/package_installer.cpp@@ -516,13 +516,20 @@ bool FilesystemPackageInstaller::ValidView() const {return true;}-// The kit's own recipe, or the one Playden generated for this game from Steam's-// launch options (runtime::GeneratedRecipeId: "steam-<app id>-auto"). The kit's-// runtime and template run either; only the launch entries differ.+void FilesystemPackageInstaller::AcceptShippedRecipes(std::vector<std::string> recipe_ids) {+ shipped_recipe_ids_ = std::move(recipe_ids);+}++// The kit's own recipe at the kit's version, a recipe Playden ships (AcceptShippedRecipes)+// or the one Playden generated for this game from Steam's launch options+// (runtime::GeneratedRecipeId: "steam-<app id>-auto"). The kit's runtime and template+// run any of them; only the launch entries and bottle values differ.bool FilesystemPackageInstaller::RecipeAccepted(const RuntimeInstall& record) const {- if (record.recipe_id == kit_.recipe.id && record.recipe_version == kit_.recipe.version) return true;- return record.app_id != 0 && record.recipe_id == "steam-" + std::to_string(record.app_id) + "-auto" &&- !record.recipe_version.empty();+ if (record.recipe_id == kit_.recipe.id) return record.recipe_version == kit_.recipe.version;+ if (record.recipe_version.empty()) return false;+ if (std::find(shipped_recipe_ids_.begin(), shipped_recipe_ids_.end(), record.recipe_id) != shipped_recipe_ids_.end())+ return true;+ return record.app_id != 0 && record.recipe_id == "steam-" + std::to_string(record.app_id) + "-auto";}std::optional<FilesystemPackageInstaller::ResolvedPaths>diff --git a/src/runtime/package_installer.h b/src/runtime/package_installer.hindex 8903afe..2bbf774 100644--- a/src/runtime/package_installer.h+++ b/src/runtime/package_installer.h@@ -152,6 +152,10 @@ class FilesystemPackageInstaller final : public PackageInstaller {FilesystemPackageInstaller(VerifiedKitView kit, PackageInstallPaths paths,PackageInstallerOperations operations);+ // The recipes Playden ships (runtime/recipes) besides the kit's own. A record+ // prepared with one of them resolves whatever recipe the kit carries.+ void AcceptShippedRecipes(std::vector<std::string> recipe_ids);+PackageStatus Inspect(const RuntimeInstall& record) override;// The title's owner marker instead of its files and folder modes; the bottle,// artifacts and publication are checked as Inspect does.@@ -216,6 +220,7 @@ class FilesystemPackageInstaller final : public PackageInstaller {VerifiedKitView kit_;PackageInstallPaths paths_;PackageInstallerOperations operations_;+ std::vector<std::string> shipped_recipe_ids_;};} // namespace playden::runtimediff --git a/tests/homebrew_runtime_host_test.cpp b/tests/homebrew_runtime_host_test.cppindex 3011be8..b090a6f 100644--- a/tests/homebrew_runtime_host_test.cpp+++ b/tests/homebrew_runtime_host_test.cpp@@ -1702,6 +1702,50 @@ void PreparesUdkGameWithEulaAccepted() {host.Shutdown();}+// Playden ships more recipes than the one the kit carries: a game with its own shipped recipe+// (FF XIII) is prepared by a kit packaged for HL2, with the recipe's bottle values written.+void ShippedRecipePreparesWithAnotherKitsRecipe() {+ Fixture fixture;+ auto config = fixture.Config();+ config.host_namespace_prefix = fixture.root;+ 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");+ };+ const auto kit = SyntheticKit(fixture.root / "kit");+ 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}; };+ Write(fixture.root / "data/homebrew/FAKE77031/games/292120/white_data/prog/win/bin/ffxiiiimg.exe", "existing-game", 0644);+ RuntimeHost host(config);+ CHECK(host.Start());+ CHECK(WaitFor(host, Started).kit_available);+ host.Prepare({292120, "/data/homebrew/FAKE77031/games/292120", "internal", "Final Fantasy XIII"});+ const auto done = WaitFor(host, [](const RuntimeSnapshot& s) {+ return !s.preparing_app && (s.refusals.count(292120) || (!s.installs.empty() && s.installs[0].state == PreparationState::kReady));+ }, 60);+ if (done.refusals.count(292120)) std::fprintf(stderr, "Prepare refused: %s\n", done.refusals.at(292120).c_str());+ CHECK(!done.refusals.count(292120) && done.installs.size() == 1 && done.installs[0].app_id == 292120);+ CHECK(Read(config.state_root / "installs.json").find("\"recipe_id\":\"steam-292120-ffxiii-v1\"") != std::string::npos);+ const auto game = fixture.root / "data/playden/games/steam-292120";+ CHECK(Read(game / "library/profiles/playden-steam-292120.profile").find("ffxiiiimg.exe") != std::string::npos);+ CHECK(Read(game / "library/prefixes/game/user.reg").find("\"VideoMemorySize\"=\"4096\"") != std::string::npos);+ // A restart resolves the record again through the same rule.+ host.Shutdown();+ RuntimeHost restarted(config);+ CHECK(restarted.Start());+ const auto reloaded = WaitFor(restarted, Started);+ CHECK(reloaded.installs.size() == 1 && reloaded.installs[0].state == PreparationState::kReady);+ restarted.Shutdown();+}+int main(int argc, char** argv) {CHECK(argc == 2);g_runtime_dir = argv[1];@@ -1725,6 +1769,7 @@ int main(int argc, char** argv) {SettingsSavedDuringPrepareReachReadyTitle();KitRespinKeepsWaitingSettingsUpdate();RemovesTitleKeepingSaves();+ ShippedRecipePreparesWithAnotherKitsRecipe();std::puts("runtime host tests passed");return 0;}diff --git a/tests/runtime_package_installer_test.cpp b/tests/runtime_package_installer_test.cppindex 27821dd..51c0f1c 100644--- a/tests/runtime_package_installer_test.cpp+++ b/tests/runtime_package_installer_test.cpp@@ -949,10 +949,36 @@ void MissingReferencedInputAndSymlinkedManagedParentsAreRejected() {}}+// A record prepared with a recipe Playden ships resolves whatever recipe the kit carries;+// the kit's own recipe still has to be at the kit's version, and an unknown one is refused.+void ShippedRecipeResolvesWithAnyKit() {+ Fixture fixture;+ auto installer = fixture.Installer();+ auto record = Record();+ record.app_id = 292120; record.recipe_id = "steam-292120-ffxiii-v1"; record.recipe_version = "1";+ record.artifacts = {{"runtime", "rev", fixture.view.artifacts[0].sha256},+ {"recipe", "steam-220-hl2-v1-1", fixture.view.artifacts[1].sha256}};+ CHECK(installer.StageTitle(record).code == "kit-invalid");+ installer.AcceptShippedRecipes({"steam-292120-ffxiii-v1"});+ CHECK(installer.StageTitle(record).state == PackageActionState::kComplete);+ CHECK(installer.CopyTemplate(record).state == PackageActionState::kComplete);+ CHECK(installer.Inspect(record).known);+ auto other = record;+ other.recipe_id = "steam-440-tf2-v1";+ CHECK(installer.StageTitle(other).code == "kit-invalid");+ auto drifted = Record();+ drifted.recipe_version = "2";+ CHECK(installer.StageTitle(drifted).code == "kit-invalid");+ auto generated = Record();+ generated.recipe_id = "steam-220-auto";+ CHECK(!installer.Inspect(generated).title_source_path.empty());+}+} // namespaceint main() {TemplateCopyReportsProgress();+ ShippedRecipeResolvesWithAnyKit();{Fixture fixture;const auto game = fixture.host_data / "playden/games/install-hl2";