Skip to content

Play your Steam library's Windows games on a jailbroken PS5.

C++

Follow USB drives and update games after a new kit

Leonardo Lobato119932549cec
diff --git a/README.md b/README.md
index 86028b2..d4fb9cb 100644
--- a/README.md
+++ b/README.md
@@ -50,7 +50,8 @@ private Windows environment and its own tile on the PS5 Home screen.
mouse, or the D-pad as the arrow keys.
- **Import Windows games.** Add game folders you already have, from a USB drive, an M.2 SSD or over FTP. No Steam
account is needed. See [Import Windows games](#import-windows-games).
-- **Install to internal or external disks.** Console storage, or an exFAT USB drive formatted on a Mac or PC.
+- **Install to internal or external disks.** Console storage, or an exFAT USB drive formatted on a Mac or PC. USB
+ drives can change places: Playden and your games find them again.
See the [compatibility list](COMPATIBILITY.md) for the games we have tested.
@@ -204,7 +205,10 @@ The runtime kit is what runs Windows games: Wine, Mesa and DXVK. Playden
downloads the kit its version was made for from this repository's releases, on its first start and whenever the
installed kit isn't that one. It installs in the background, shows on the Queue screen, and games can be prepared
as soon as it is in place. If you choose Later, or the download fails, Settings › About › Runtime kit starts
-it again. Games pick up a new kit when you press Play.
+it again.
+
+Games pick up a new kit when you press Play, or all at once: Playden offers this the first time you open it with a new
+kit, and Settings › Manage installed games › Runtimes does it whenever you want. Saves and settings are kept.
You can also install the kit by hand, with Python 3: download `playden-kit-<version>.zip` from the release, unzip it
next to `playden-ps5-<version>`, and run this from the `playden-ps5-<version>` folder. A plain FTP copy does not
@@ -360,6 +364,7 @@ build/homebrew-host/playden-homebrew --simulation --scenario signed-out
## Known issues
+- If you plug in or swap USB drives while Playden is open, restart Playden so it sees them.
- Online multiplayer and games with anti-cheat do not work. See [Before you use it](#before-you-use-it).
- Uninstall games from Playden. Title folders belong to Playden; FTP and file managers can't delete them.
Leftover titles appear in Settings › Storage. Deleting a leftover removes its title folder and Home tile;
diff --git a/dependencies.lock.json b/dependencies.lock.json
index ebfc036..29288a6 100644
--- a/dependencies.lock.json
+++ b/dependencies.lock.json
@@ -177,7 +177,7 @@
}
},
"prospero_win": {
- "revision": "3b87bca0c759c6708090b0a6c6af81ce27f6073c",
+ "revision": "7537eb0113b438e8dc0730e594fa0743203bc7c9",
"url": "https://github.com/leolobato/prospero-win.git",
"default_source": "third_party/prospero-win",
"published": false,
@@ -185,7 +185,7 @@
"retained_runtime_artifact_revision": "bceed2d-kit-h-r1",
"upstream_url": "https://github.com/mpereiraesaa/prospero-win.git",
"branch": "main",
- "note": "Before kit 0.18: see this file's git history. 44ccf5a to 2b53efa add the exec chain and launcher mode: Wine patches 0994-0997, the profile's [launcher] section (kit capability launcher-mode), the touchpad preset swap, OpenAL Soft from win/openal-soft, and a chained program's own architecture and graphics. 008d3f7 pins the packager to the kit 0.18 runtime built from 2b53efa. d610e32 (Wine 0998) reports video memory above 4 GiB correctly, 24fdf79 adds the driver frame rate counter ([display] fps_counter), c290606 finds the title's sandbox, ba1455c adds the WAV, MP3 and ID3 parsers (Wine 0999), and e7582e9 releases a failed media graph once (Wine 0485). 0036091 pins the packager to the rebuilt kit 0.18. f33828e and a20e7dc take upstream 957d987 and 0e7b6b4 (Wine 0471, the other signed-in users' DualSenses as XInput controllers 1 to 3); 0d5a98d keeps the fork's rumble scaling, launcher presets and device-change notice on them, and 94222f8 adds Wine 0966 (those controllers as HID gamepads while connected, listed after controller 0, asked for when a program opens a HID device, waited for at a hosted start). c650ce5 adds Wine 0990-0992 and 3f1da26 the title's [input] mode = playstation (kit capability input-playstation): each controller as a DualShock 4 on the HID bus, and no XInput controllers. 7cccb5d pins the runtime built from 3f1da26 in the packager. 38f0998 adds Wine patch 0967 (a waiting send to the desktop window from another thread gets 0 at once); a kit with it needs win32u.prx from 38f0998, and kit 0.18 and its runtime are unchanged until a kit is built from it. fe8db51 tunes the rumble by feel: at least 20 ms per rumble (with the sink's peak, pw_wine_rumble_peak_at in ntdll.prx), 128 runs the motors at 140, L2 and R2 no longer vibrate; it takes effect from the next kit, which needs a new shell and ntdll.prx. bbf712b follows a virtual link when a path ends in a slash, so a drive root reaches Wine (ntdll.prx and wineserver.prx), 3f00982 adds Wine patch 0977 (GetLogicalDrives opens each letter's root when nothing is published; kernelbase.dll) and 37576d0 Wine patch 0979 (a title's root directory reports /data's free space; ntdll). They take effect from the next kit. 3b87bca adds Wine patch 0968 (the pointer stays on the image under a display mode; win32u.prx), from the next kit too."
+ "note": "Before kit 0.18: see this file's git history. 44ccf5a to 2b53efa add the exec chain and launcher mode: Wine patches 0994-0997, the profile's [launcher] section (kit capability launcher-mode), the touchpad preset swap, OpenAL Soft from win/openal-soft, and a chained program's own architecture and graphics. 008d3f7 pins the packager to the kit 0.18 runtime built from 2b53efa. d610e32 (Wine 0998) reports video memory above 4 GiB correctly, 24fdf79 adds the driver frame rate counter ([display] fps_counter), c290606 finds the title's sandbox, ba1455c adds the WAV, MP3 and ID3 parsers (Wine 0999), and e7582e9 releases a failed media graph once (Wine 0485). 0036091 pins the packager to the rebuilt kit 0.18. f33828e and a20e7dc take upstream 957d987 and 0e7b6b4 (Wine 0471, the other signed-in users' DualSenses as XInput controllers 1 to 3); 0d5a98d keeps the fork's rumble scaling, launcher presets and device-change notice on them, and 94222f8 adds Wine 0966 (those controllers as HID gamepads while connected, listed after controller 0, asked for when a program opens a HID device, waited for at a hosted start). c650ce5 adds Wine 0990-0992 and 3f1da26 the title's [input] mode = playstation (kit capability input-playstation): each controller as a DualShock 4 on the HID bus, and no XInput controllers. 7cccb5d pins the runtime built from 3f1da26 in the packager. 38f0998 adds Wine patch 0967 (a waiting send to the desktop window from another thread gets 0 at once); a kit with it needs win32u.prx from 38f0998, and kit 0.18 and its runtime are unchanged until a kit is built from it. fe8db51 tunes the rumble by feel: at least 20 ms per rumble (with the sink's peak, pw_wine_rumble_peak_at in ntdll.prx), 128 runs the motors at 140, L2 and R2 no longer vibrate; it takes effect from the next kit, which needs a new shell and ntdll.prx. bbf712b follows a virtual link when a path ends in a slash, so a drive root reaches Wine (ntdll.prx and wineserver.prx), 3f00982 adds Wine patch 0977 (GetLogicalDrives opens each letter's root when nothing is published; kernelbase.dll) and 37576d0 Wine patch 0979 (a title's root directory reports /data's free space; ntdll). They take effect from the next kit. 3b87bca adds Wine patch 0968 (the pointer stays on the image under a display mode; win32u.prx), from the next kit too. 53c454f and 7537eb0 add the USB drive search and its wait screen to the title shell (capability game-root-usb-search), from the next kit too."
},
"prospero_bottle_preparation": {
"hl2-fresh-v16": {
diff --git a/src/app/preferences.cpp b/src/app/preferences.cpp
index 6f927ba..68161f7 100644
--- a/src/app/preferences.cpp
+++ b/src/app/preferences.cpp
@@ -19,11 +19,12 @@ std::string ToString(const Bytes& bytes) {
// Versions 8 to 11: one "key=value" line per field, in this order, each ending in a newline. Version 9 adds
// web_access (on in older files), version 10 content_language (English in older files, which is what they
-// downloaded), version 11 the launcher dialogs' "Don't show this again" (shown in older files).
+// downloaded), version 11 the launcher dialogs' "Don't show this again" (shown in older files), version 12 the kit
+// whose "Update your games" prompt was shown (none in older files, so they are offered it).
constexpr const char* kKeys[] = {"reduce_motion", "title_store_suffix", "cloud_saves_auto",
"steam_sign_in_password", "downloads_slow_network", "steam_stay_signed_in",
"beta_updates", "download_server", "web_access", "content_language",
- "hide_run_once_help", "hide_launcher_help"};
+ "hide_run_once_help", "hide_launcher_help", "runtime_prompt_kit"};
bool ParseFlag(const std::string& value, bool* flag) {
if (value != "0" && value != "1") return false;
@@ -43,7 +44,8 @@ bool ParseKeyed(const std::string& serialized, int version, Preferences* prefere
if (serialized.compare(0, header.size(), header) != 0 || serialized.back() != '\n') return false;
std::vector<std::string> values;
std::size_t start = header.size();
- const std::size_t count = std::size(kKeys) - static_cast<std::size_t>(version >= 11 ? 0 : 2 + (10 - version));
+ // Version 11 added two fields; the others one each from version 8's eight.
+ const std::size_t count = static_cast<std::size_t>(version >= 11 ? version + 1 : version);
for (std::size_t field = 0; field < count; ++field) {
const char* key = kKeys[field];
const std::string prefix = std::string(key) + "=";
@@ -66,6 +68,10 @@ bool ParseKeyed(const std::string& serialized, int version, Preferences* prefere
}
if (version >= 11 && (!ParseFlag(values[10], &parsed.hide_run_once_help) || !ParseFlag(values[11], &parsed.hide_launcher_help)))
return false;
+ // Anything but a SHA-256 is dropped: the prompt is offered again, and nothing else resets.
+ if (version >= 12 && values[12].size() == 64 &&
+ std::all_of(values[12].begin(), values[12].end(), [](char c) { return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f'); }))
+ parsed.runtime_prompt_kit = values[12];
// A host the current rule refuses is dropped without resetting unrelated preferences.
if (ValidDownloadServer(values[7])) parsed.download_server = values[7];
*preferences = std::move(parsed);
@@ -93,7 +99,7 @@ PreferencesLoadResult PreferencesStore::Load() const {
std::string serialized = ToString(read.value());
Preferences keyed;
- if (ParseKeyed(serialized, 11, &keyed) || ParseKeyed(serialized, 10, &keyed) || ParseKeyed(serialized, 9, &keyed) || ParseKeyed(serialized, 8, &keyed))
+ if (ParseKeyed(serialized, 12, &keyed) || ParseKeyed(serialized, 11, &keyed) || ParseKeyed(serialized, 10, &keyed) || ParseKeyed(serialized, 9, &keyed) || ParseKeyed(serialized, 8, &keyed))
return PreferencesLoadResult{std::move(keyed), PreferencesLoadStatus::kLoaded, std::string()};
bool beta_updates = false;
if (serialized.rfind("version=7\n", 0) == 0) {
@@ -194,7 +200,7 @@ Result<void> PreferencesStore::Save(const Preferences& preferences) const {
if(!ready.ok()) return ready;
// Never write a host that cannot be read back, including embedded newlines.
const std::string server = ValidDownloadServer(preferences.download_server) ? preferences.download_server : std::string();
- const std::string text = std::string("version=11\nreduce_motion=") + (preferences.reduce_motion ? "1" : "0") +
+ const std::string text = std::string("version=12\nreduce_motion=") + (preferences.reduce_motion ? "1" : "0") +
"\ntitle_store_suffix=" + (preferences.title_store_suffix ? "1" : "0") +
"\ncloud_saves_auto=" + (preferences.cloud_saves_auto ? "1" : "0") +
"\nsteam_sign_in_password=" + (preferences.steam_sign_in_password ? "1" : "0") +
@@ -207,7 +213,8 @@ Result<void> PreferencesStore::Save(const Preferences& preferences) const {
? preferences.content_language
: std::string(steam::kDefaultContentLanguage)) +
"\nhide_run_once_help=" + (preferences.hide_run_once_help ? "1" : "0") +
- "\nhide_launcher_help=" + (preferences.hide_launcher_help ? "1" : "0") + "\n";
+ "\nhide_launcher_help=" + (preferences.hide_launcher_help ? "1" : "0") +
+ "\nruntime_prompt_kit=" + preferences.runtime_prompt_kit + "\n";
return storage_.WriteAtomic(kPreferencesPath, Bytes(text.begin(), text.end()));
}
diff --git a/src/app/preferences.h b/src/app/preferences.h
index 28d5afe..f331aba 100644
--- a/src/app/preferences.h
+++ b/src/app/preferences.h
@@ -36,6 +36,8 @@ struct Preferences {
// Start through a launcher. Separate, because the second warns about other games.
bool hide_run_once_help = false;
bool hide_launcher_help = false;
+ // The runtime kit whose "Update your games" prompt has been shown (its manifest SHA-256): once per kit.
+ std::string runtime_prompt_kit;
};
enum class PreferencesLoadStatus {
diff --git a/src/homebrew/controller.cpp b/src/homebrew/controller.cpp
index 71786bb..5d4192f 100644
--- a/src/homebrew/controller.cpp
+++ b/src/homebrew/controller.cpp
@@ -1,6 +1,7 @@
#include "homebrew/controller.hpp"
#include "homebrew/program_icon.hpp"
#include "diagnostics/redaction.h"
+#include "platform/usb_mount.h"
#include "steam/install_volumes.h"
#include "steam/secret.h"
#include <algorithm>
@@ -969,17 +970,17 @@ void Controller::TickRuntime() {
};
const auto ready = [](const RuntimeInstallView* view) {
return view && view->state == runtime::PreparationState::kReady && !view->recovery_pending &&
- view->title_current && view->admission == "ok" && !view->files_changed;
+ view->title_current && !runtime::AdmissionNeedsRepair(view->admission) && !view->files_changed;
};
const auto refusal_of = [&prepared](GameId id) {
const auto found = prepared.refusals.find(NumberIn(prepared, id));
return found == prepared.refusals.end() ? std::string{} : found->second;
};
- // Play on a game that was never prepared prepares it first; on one whose title needs an
- // Update or a Repair, it updates or repairs it first. Both then start the game.
+ // Play on a game that was never prepared prepares it first and starts it; so does a Repair. A title a newer kit
+ // left behind updates and stops on a dialog, since the player may only have wanted the update.
const auto needs_work = [](const RuntimeInstallView* view) {
return view && view->state == runtime::PreparationState::kReady && !view->recovery_pending &&
- (!view->title_current || view->admission != "ok" || view->files_changed);
+ (!view->title_current || runtime::AdmissionNeedsRepair(view->admission) || view->files_changed);
};
// A record left before Ready by an earlier session, with no journal to resume, is what the
// game page calls "Not prepared": Play prepares it too, instead of asking the launcher.
@@ -995,7 +996,9 @@ void Controller::TickRuntime() {
if (view && view->moving) return true; // a move that stopped part way: Prepare finishes it
if (!view || view->install_path.empty() || view->recovery_pending) return false;
const auto root = game_roots_.find(view->game);
- return root != game_roots_.end() && root->second != view->install_path;
+ // The same folder on another USB mount is the game's drive changing places, which Prepare only records.
+ return root != game_roots_.end() &&
+ platform::WithoutUsbMountNumber(root->second) != platform::WithoutUsbMountNumber(view->install_path);
};
std::vector<GameId> direct;
for (const auto id : plays) {
@@ -1005,10 +1008,12 @@ void Controller::TickRuntime() {
auto& pending = play_after_prepare_[id];
if (const auto* view = record_of(id); moved(view))
pending.words = "Preparing the game on its new drive…";
- else if (needs_work(view))
- pending.words = !view->title_current ? "Updating runtime…"
- : view->admission != "ok" ? "Repairing runtime…"
+ else if (needs_work(view)) {
+ pending.words = !view->title_current ? "Updating runtime kit…"
+ : runtime::AdmissionNeedsRepair(view->admission) ? "Repairing game setup…"
: "Setting up the updated game…";
+ pending.stops_when_ready = !view->title_current;
+ }
std::erase(auto_prepare_, id);
++play_notes_revision_;
} else if (!play_after_prepare_.count(id)) {
@@ -1139,8 +1144,8 @@ void Controller::TickRuntime() {
if (!pending.seen_preparing && !handled && !unseen_too_long) { ++it; continue; }
const auto* record = record_of(id);
const auto refusal = refusal_of(id);
- runtime_update_results_[id] = ready(record) ? std::pair<bool, std::string>{true, "Runtime updated."}
- : std::pair<bool, std::string>{false, refusal.empty() ? "The runtime could not be updated." : refusal};
+ runtime_update_results_[id] = ready(record) ? std::pair<bool, std::string>{true, "Runtime kit updated."}
+ : std::pair<bool, std::string>{false, refusal.empty() ? "The runtime kit could not be updated." : refusal};
++play_notes_revision_;
it = runtime_updates_.erase(it);
}
@@ -1161,7 +1166,8 @@ void Controller::TickRuntime() {
if (IsNumber(prepared, prepared.preparing_app, id)) { pending.seen_preparing = true; ++it; continue; }
// A title still made for the game's old folder waits for the preparation that moves it.
if (ready(record_of(id)) && !moved(record_of(id))) {
- plays.push_back(id);
+ if (pending.stops_when_ready) model_.NotifyRuntimeUpdated(id);
+ else plays.push_back(id);
it = play_after_prepare_.erase(it);
++play_notes_revision_;
continue;
@@ -1334,7 +1340,7 @@ void Controller::TickRuntime() {
game.status = "Preparing"; game.detail = "Removing the PS5 title made for the game's old drive";
} else if (record && record->moving) {
// That removal stopped part way: Play or Prepare finishes the move, never an uninstall of the new download.
- game.status = "Needs repair"; game.can_prepare = usable;
+ game.status = "Needs repair"; game.can_prepare = usable; game.moving = true;
game.detail = "Play finishes moving the PS5 title to the game's new drive.";
} else if (record && record->state == runtime::PreparationState::kRemoving) {
game.status = "Removal incomplete"; game.can_prepare = true;
@@ -1344,12 +1350,12 @@ void Controller::TickRuntime() {
game.status = "Preparing"; game.detail = PreparationProgressWords(record != nullptr, record ? record->step : std::string{});
} else if (record && record->state == runtime::PreparationState::kReady && !record->recovery_pending &&
!record->title_current) {
- game.status = "Kit update available"; game.can_prepare = usable;
+ game.status = "Runtime kit update available"; game.can_prepare = usable;
game.detail = "Play updates the runtime kit first; the game and its saves stay as they are";
} else if (record && record->state == runtime::PreparationState::kReady && !record->recovery_pending &&
- record->admission != "ok") {
+ runtime::AdmissionNeedsRepair(record->admission)) {
game.status = "Needs repair"; game.can_prepare = usable;
- game.detail = "Play repairs the runtime first (" + record->admission + ")";
+ game.detail = "Play repairs the game's setup first (" + record->admission + ")";
} else if (record && record->state == runtime::PreparationState::kReady && !record->recovery_pending) {
game.status = "Ready"; game.detail = record->title_id; game.ready = true;
} else if (record && record->awaiting_registration) {
@@ -1374,22 +1380,22 @@ void Controller::TickRuntime() {
record->state == runtime::PreparationState::kUnavailable)) {
game.status = "Failed"; game.detail = record->failure; game.can_prepare = usable;
} else {
- game.status = usable ? "Not prepared" : "No kit";
+ game.status = usable ? "Not prepared" : "No runtime kit";
game.detail = usable ? "Play prepares it: a private bottle and the game's own PS5 title" : snapshot.kit_reason;
game.can_prepare = usable;
}
// Preparation and its recovery checks require the kit. Keep actions that
// launch or remove an existing title, and route blocked setup to Settings.
if (snapshot.status == RuntimeHostStatus::kReady && !usable &&
- (game.status == "Kit update available" || game.status == "Needs repair" ||
+ (game.status == "Runtime kit update available" || game.status == "Needs repair" ||
game.status == "Needs recovery" || game.status == "Failed" || game.status == "Registration pending"))
- game.status = "No kit";
+ game.status = "No runtime kit";
if (refusal != snapshot.refusals.end() && !game.ready) game.detail = refusal->second;
// A setup left over from an earlier kit: what to do, not the check that failed (or the refusal saying so).
if (record && record->setup_other_kit && usable &&
(game.status == "Needs recovery" || game.status == "Failed" || game.status == "Not prepared")) {
game.setup_other_kit = true;
- game.detail = "Started with an earlier kit · Recreate the bottle to finish (saves are kept)";
+ game.detail = "Started with an earlier version of the runtime kit · Recreate the bottle to finish (saves are kept)";
}
if (const auto refused = snapshot.play_refusals.find(NumberIn(snapshot, id)); refused != snapshot.play_refusals.end())
game.play_detail = "Could not start: " + refused->second;
@@ -1532,6 +1538,7 @@ void Controller::TickRuntime() {
}
}
model_.UpdateRuntime(state, games);
+ model_.UpdateDriveUpdates(snapshot.drive_updates_done, snapshot.drive_updates_total, snapshot.drive_updates_failed);
model_.SetRuntimeLeftovers(snapshot.leftover_requests);
LiveKitInfo kit;
if (snapshot.kit) {
@@ -1692,6 +1699,10 @@ void Controller::ProjectLocations(const std::vector<steam::InstalledGame>& manag
external_projected_ = games;
model_.UpdateExternalGames(std::move(games));
}
+ std::map<GameId, std::string> also_on;
+ for (const auto& location : locations_)
+ if (!location.also_on.empty()) also_on[location.game] = location.also_on;
+ model_.UpdateAlsoOnDrives(std::move(also_on));
}
game_roots_.clear();
game_volumes_.clear();
@@ -2472,14 +2483,20 @@ void Controller::SubmitPrepare(GameId id, bool announce) {
// An imported game starts the program chosen when it was added: written into Game settings when
// it was added, or here before its first preparation if that couldn't be; never over the player's
// own choice or reset (SeedGameProgram).
+ std::string imported_name;
if (id.store == Store::kLocal && local_) {
const auto snapshot = local_->Snapshot();
for (const auto& game : snapshot->games)
- if (game.id == id.value) model_.SeedGameProgram(id, game.program);
+ if (game.id == id.value) {
+ model_.SeedGameProgram(id, game.program);
+ imported_name = game.title;
+ }
}
RuntimePrepareRequest request{*app, root->second, game_volumes_[id], {}};
request.game = id;
for (const auto& game : model_.state().games) if (game.id == id) request.title_name = game.title;
+ // A new import prepares straight away, maybe before the library lists it: Home keeps the name it registers with.
+ if (request.title_name.empty()) request.title_name = imported_name;
if (model_.state().title_store_suffix && !request.title_name.empty()) request.title_name += TitleStoreSuffix(id.store);
if (const auto found = launch_options_.find(id); found != launch_options_.end())
for (const auto& option : found->second)
diff --git a/src/homebrew/controller.hpp b/src/homebrew/controller.hpp
index b471ad8..ed32a7b 100644
--- a/src/homebrew/controller.hpp
+++ b/src/homebrew/controller.hpp
@@ -261,6 +261,7 @@ class Controller {
std::string refusal;
std::uint64_t prepares_handled = 0; // the worker's count when this prepare was queued
std::chrono::steady_clock::time_point queued_at{};
+ bool stops_when_ready = false; // only the title's kit update was due: the player chooses whether to start it now
std::string words = "Preparing…"; // what Play says meanwhile: preparing, updating or repairing the runtime
};
std::map<GameId, PlayAfterPrepare> play_after_prepare_;
diff --git a/src/homebrew/ps5.cpp b/src/homebrew/ps5.cpp
index 53bba5e..b220da5 100644
--- a/src/homebrew/ps5.cpp
+++ b/src/homebrew/ps5.cpp
@@ -506,6 +506,7 @@ int main() {
config.homebrew_root = "/data/homebrew";
config.layout_paths = rt::LayoutPaths{paths.title_root, "/data/playden/user", "/data/playden/logs",
"/data/playden-games", "/data/playden/runtime-state", "/data"};
+ config.cloud_saves_root = "/data/playden-games/.playden-saves";
config.as_root = [](const std::function<bool()>& work) { return playden::ps5::WithRoot(work); };
config.writable_folders = {"/data/homebrew", "/data/playden", "/data/playden-games", "/data/playden/user",
"/data/playden/logs"};
diff --git a/src/homebrew/runtime_host.cpp b/src/homebrew/runtime_host.cpp
index 7d1cd1a..32c29d4 100644
--- a/src/homebrew/runtime_host.cpp
+++ b/src/homebrew/runtime_host.cpp
@@ -2,6 +2,9 @@
// Copyright (c) 2026 Playden contributors
// SPDX-License-Identifier: MIT
#include "homebrew/runtime_host.hpp"
+
+#include "pw_app_profile.h"
+#include "platform/usb_mount.h"
#include "installs/install_record.h"
#include "platform/random_id.h"
@@ -106,7 +109,7 @@ std::string KitLacksForRecipe(const rt::GameRecipe& recipe, const rt::VerifiedKi
if (recipe.id == kit.recipe.id) return {};
const auto unmet = rt::UnmetRecipeRequirements(recipe.requirements, kit);
return unmet.empty() ? std::string()
- : "The installed runtime kit lacks what this game needs (" + unmet + "); install a newer kit.";
+ : "The installed runtime kit lacks what this game needs (" + unmet + "); install a newer runtime kit.";
}
// Staged, its registration submitted, and only waiting for ShadowMountPlus, which
@@ -1342,6 +1345,12 @@ std::size_t RuntimeHost::LeftoverRequests(Composition& c, bool remove) {
return kept;
}
+// A finished publication's request is no longer named by any journal, so updating many games doesn't pile them up.
+void RuntimeHost::RemoveFinishedRequests(Composition& c) {
+ const auto kept = LeftoverRequests(c, true);
+ Publish([&](RuntimeSnapshot& s) { s.leftover_requests = kept; });
+}
+
bool RuntimeHost::Handoff() {
{
std::lock_guard<std::mutex> lock(launch_mutex_);
@@ -1607,7 +1616,7 @@ rt::KitCapabilities RuntimeHost::TitleKit(const Composition& c, const rt::Runtim
const auto kit = rt::KitCapabilitiesFromManifest(c.kit->capabilities, true);
// The title's markers are read only when the kit has something an older runtime would refuse.
return kit.display_120hz || kit.profile_version_2 || kit.input_rumble || kit.display_framegen || kit.display_fps_counter ||
- kit.launcher_mode || kit.input_playstation
+ kit.launcher_mode || kit.input_playstation || kit.game_root_usb_search
? rt::KitForTitleRuntime(kit, TitleRuntimeCurrent(c, record))
: kit;
}
@@ -1709,7 +1718,7 @@ rt::PackageActionResult RuntimeHost::DrivePublication(Composition& c, const rt::
for (const auto& preset : c.presets)
if (preset.id == input.record.preset_id) input.preset = &preset;
input.kit = TitleKit(c, record);
- input.target = {record.default_profile_id, record.install_path};
+ input.target = {record.default_profile_id, record.install_path, UsbSearchRoot(c, record)};
input.runtime_dir = config_.runtime_dir;
rt::SettingsLaunchPlan plan;
std::string reason;
@@ -1733,6 +1742,8 @@ rt::PackageActionResult RuntimeHost::DrivePublication(Composition& c, const rt::
return failed("settings-plan", unwritable);
}
}
+ // The program settled above decides this: a copy of another program on another drive doesn't count.
+ input.target.published_root = UsbSearchRoot(c, current);
// The first start may come from the PS5 Home screen, so the game's Steam files are set up now.
if (const auto steamworks = ApplyPreparationSteps(c, current); !steamworks.empty()) return failed("steamworks", steamworks);
if (!rt::BuildSettingsLaunchPlan(input, &plan, &reason)) {
@@ -1763,6 +1774,7 @@ rt::PackageActionResult RuntimeHost::DrivePublication(Composition& c, const rt::
const auto resumed = c.owner->ResumeRequested(*armed, c.request_directory, prefix);
Log("publication resume state=" + std::to_string(static_cast<int>(resumed.state)) + " code=" + resumed.code +
" message=" + resumed.message);
+ if (resumed.state == rt::PackageActionState::kComplete) RemoveFinishedRequests(c);
return resumed;
}
@@ -1854,6 +1866,38 @@ bool RuntimeHost::NeedsUnownedPublication(const Composition& c, const rt::Runtim
return rt::PublishedGameRootUnowned(record, config_.host_namespace_prefix) == std::optional<bool>(false);
}
+std::string RuntimeHost::UsbSearchRoot(const Composition& c, const rt::RuntimeInstall& record) const {
+ const auto root = platform::WithoutUsbMountNumber(record.install_path);
+ if (!platform::IsUsbSearchPath(root)) return {};
+ // A title older than the kit reads this form if it is already published in it: a kit change doesn't pin it to a mount.
+ if (!TitleKit(c, record).game_root_usb_search && rt::PublishedGameRoot(record, config_.host_namespace_prefix) != root) return {};
+ auto program = record.launch_path;
+ std::replace(program.begin(), program.end(), '\\', '/');
+ // The title puts the mount's number in, and the profile's limit is on the real paths too.
+ const auto working = WorkingFolder(record.launch_working_directory, record.launch_path, record.launch_in_install_root);
+ if (("Z:" + record.install_path + "/" + program).size() >= PW_APP_PATH_CAPACITY ||
+ ("Z:" + record.install_path + "/" + working).size() >= PW_APP_PATH_CAPACITY)
+ return {};
+ // A copy on another drive makes the title refuse the search: this drive's copy is named outright.
+ for (int number = 0; number < platform::kUsbMounts; ++number) {
+ const auto other = platform::OnUsbMount(record.install_path, number);
+ if (other == record.install_path) continue;
+ struct stat info{};
+ if (lstat((HostPath(other) / program).c_str(), &info) == 0 && S_ISREG(info.st_mode)) return {};
+ }
+ return root;
+}
+
+bool RuntimeHost::NeedsDrivePublication(const Composition& c, const rt::RuntimeInstall& record) const {
+ if (!c.kit || record.state != rt::PreparationState::kReady || record.journal || !record.moved_from.empty() ||
+ platform::WithoutUsbMountNumber(record.install_path) == record.install_path)
+ return false;
+ const auto published = rt::PublishedGameRoot(record, config_.host_namespace_prefix);
+ if (!published || platform::WithoutUsbMountNumber(*published) != platform::WithoutUsbMountNumber(record.install_path)) return false;
+ const auto wanted = UsbSearchRoot(c, record);
+ return *published != (wanted.empty() ? record.install_path : wanted);
+}
+
bool RuntimeHost::DropUpgradeRequest(Composition& c, const std::string& install_id, const std::string& why) {
const auto current = c.records.Find(install_id);
if (!current || current->state != rt::PreparationState::kReady || !current->moved_from.empty() || !current->journal ||
@@ -1995,7 +2039,8 @@ std::string RuntimeHost::RepublishSettings(Composition& c, const rt::RuntimeInst
const auto saved_revision = config_.settings_record
? config_.settings_record(GameOf(record)).value_or(rt::GameSettingsRecord{}).revision : 0;
const bool upgrade_only = !force && setup_program.empty() && record.setup_program.empty() && record.moved_from.empty() &&
- saved_revision <= record.settings_revision && NeedsUnownedPublication(c, record);
+ saved_revision <= record.settings_revision &&
+ (NeedsUnownedPublication(c, record) || NeedsDrivePublication(c, record));
// A game folder that isn't there (a stale record, an unplugged drive) can't be published, and
// arming the request first would leave a journal on the record: nothing is armed for it.
if (upgrade_only || !record.moved_from.empty()) {
@@ -2068,7 +2113,9 @@ std::string RuntimeHost::PublishSavedSettings(Composition& c, const rt::RuntimeI
// its descriptor, profile and dxvk.conf name the new folder.
const bool moved = !record.moved_from.empty();
// So is an owned publication the kit can replace by an unowned one (folders opened for mods).
- const bool unowned_upgrade = !moved && NeedsUnownedPublication(c, record);
+ // So is a USB game the other way round: naming no mount once its title can find the drive, and naming its mount
+ // once a copy on another drive would make the title refuse.
+ const bool unowned_upgrade = !moved && (NeedsUnownedPublication(c, record) || NeedsDrivePublication(c, record));
if (unowned_upgrade) Log("settings update app=" + std::to_string(record.runtime_number) + " publishes the game folder unowned");
// "Steam features" only swaps the game's own files, so it follows the saved value at once.
if (!force && setup_program.empty() && !restoring && saved.revision <= record.settings_revision && !moved &&
@@ -2145,7 +2192,7 @@ std::string RuntimeHost::PublishSavedSettings(Composition& c, const rt::RuntimeI
overrides["program_folder"] = next.launch_in_install_root ? std::string(".") : next.launch_working_directory;
input.preset = preset;
input.kit = kit;
- input.target = {next.default_profile_id, next.install_path};
+ input.target = {next.default_profile_id, next.install_path, UsbSearchRoot(c, next)};
input.runtime_dir = config_.runtime_dir;
rt::SettingsLaunchPlan plan;
std::string reason;
@@ -2236,6 +2283,7 @@ std::string RuntimeHost::PublishSavedSettings(Composition& c, const rt::RuntimeI
return "The settings could not be applied: " + resumed.message;
}
if (published) *published = true;
+ RemoveFinishedRequests(c);
if (const auto current = c.records.Find(record.install_id)) OpenGameFolders(c, *current);
if (moved) FinishGamesMove(c);
if (restoring) return MarkSetupProgram(c, record.install_id, {});
@@ -2349,6 +2397,114 @@ bool RuntimeHost::MoveGameRecords(Composition& c) {
return true;
}
+namespace {
+// A Ready game whose publication still names the mount its USB drive had.
+bool NeedsDriveUpdate(const rt::RuntimeInstall& record) {
+ return record.state == rt::PreparationState::kReady && !record.moved_from.empty() &&
+ record.moved_from != record.install_path &&
+ platform::WithoutUsbMountNumber(record.moved_from) == platform::WithoutUsbMountNumber(record.install_path);
+}
+} // namespace
+
+void RuntimeHost::RunDriveUpdateStep(Composition& c) {
+ constexpr auto kBusyRetry = std::chrono::seconds(3);
+ const auto finish = [&](std::size_t total) {
+ {
+ std::lock_guard<std::mutex> lock(mutex_);
+ drive_updates_pending_ = false;
+ }
+ Publish([&](RuntimeSnapshot& s) { s.drive_updates_done = total; s.drive_updates_total = total; });
+ };
+ const auto left = [&] {
+ std::vector<rt::RuntimeInstall> records;
+ for (const auto& record : c.repository.Snapshot())
+ if ((NeedsDriveUpdate(record) || NeedsDrivePublication(c, record)) && !drive_update_tried_.count(record.install_id))
+ records.push_back(record);
+ return records;
+ };
+ const auto total = Snapshot().drive_updates_total;
+ const auto records = left();
+ if (records.empty() || !c.kit) return finish(total);
+ // A game that is running or needs its title's recovery holds back only itself. Recovery is not this job's to do,
+ // so that game counts as not updated; a running one is tried again once nothing else is left.
+ const rt::RuntimeInstall* next = nullptr;
+ std::size_t needs_recovery = 0;
+ for (const auto& candidate : records) {
+ if (candidate.journal) {
+ Log("drive update app=" + std::to_string(candidate.runtime_number) + " failed: its title needs recovery");
+ drive_update_tried_.insert(candidate.install_id);
+ ++needs_recovery;
+ } else if (!next && MaintenanceRefusal(c, candidate).empty()) {
+ next = &candidate;
+ }
+ }
+ if (needs_recovery) {
+ const auto remaining = left().size();
+ Publish([&](RuntimeSnapshot& s) {
+ s.drive_updates_done = total > remaining ? total - remaining : 0;
+ s.drive_updates_failed += needs_recovery;
+ });
+ }
+ if (!next) {
+ if (left().empty()) return finish(total);
+ std::lock_guard<std::mutex> lock(mutex_);
+ drive_update_not_before_ = std::chrono::steady_clock::now() + kBusyRetry;
+ return;
+ }
+ const auto& record = *next;
+ bool published = false;
+ std::string deferred;
+ // The Steam account may not be known yet: the emulator's files and install scripts wait for Play.
+ const auto refused = RepublishSettings(c, record, &published, false, nullptr, &deferred);
+ Log("drive update app=" + std::to_string(record.runtime_number) + " " +
+ (published ? std::string("republished") : !deferred.empty() ? "deferred: " + deferred : "failed: " + refused));
+ drive_update_tried_.insert(record.install_id);
+ PublishInstalls(c, record.install_id);
+ const auto remaining = left().size();
+ // Whatever the reason, its publication still names the old mount.
+ Publish([&](RuntimeSnapshot& s) {
+ s.drive_updates_done = total > remaining ? total - remaining : 0;
+ s.drive_updates_failed += published ? 0 : 1;
+ });
+}
+
+bool RuntimeHost::RebaseUsbRecord(Composition& c, rt::RuntimeInstall record, const std::string& install_path) {
+ const auto from = record.install_path;
+ // What the publication names stays in moved_from, so a drive that goes back to its mount needs nothing published.
+ // Published naming no mount, nothing does: only this record says where the drive is.
+ const auto named = rt::PublishedGameRoot(record, config_.host_namespace_prefix);
+ const auto published = record.moved_from.empty() ? from : record.moved_from;
+ record.moved_from = published == install_path || (named && platform::IsUsbSearchPath(*named)) ? std::string() : published;
+ record.install_path = install_path;
+ const auto written = c.repository.UpdateAll({record});
+ Log("usb drive follows app=" + std::to_string(record.runtime_number) + " from=" + from + " to=" + install_path + " " +
+ (written.ok() ? std::string("rewritten") : "failed: " + written.message()));
+ if (!written.ok()) return false;
+ if (!config_.cloud_saves_root.empty()) RebaseCloudIndexes(HostPath(config_.cloud_saves_root), from, install_path);
+ return true;
+}
+
+void RuntimeHost::FollowUsbDrives(Composition& c) {
+ for (const auto& record : c.repository.Snapshot()) {
+ // A publication in progress names its folder: it finishes first, and the next start follows.
+ if (record.journal || platform::WithoutUsbMountNumber(record.install_path) == record.install_path) continue;
+ auto program = record.launch_path;
+ std::replace(program.begin(), program.end(), '\\', '/');
+ const auto holds = [&](const std::string& root) {
+ struct stat info{};
+ const auto folder = HostPath(root);
+ if (lstat(folder.c_str(), &info) != 0 || !S_ISDIR(info.st_mode)) return false;
+ return program.empty() || lstat((folder / program).c_str(), &info) == 0;
+ };
+ if (holds(record.install_path)) continue;
+ std::vector<std::string> found;
+ for (int number = 0; number < platform::kUsbMounts; ++number)
+ if (const auto root = platform::OnUsbMount(record.install_path, number); holds(root)) found.push_back(root);
+ if (found.size() == 1) RebaseUsbRecord(c, record, found.front());
+ else if (found.size() > 1) Log("usb drive app=" + std::to_string(record.runtime_number) + " on " + std::to_string(found.size()) + " drives: stays");
+ }
+}
+
void RuntimeHost::FinishGamesMove(Composition& c) {
if (!c.games_move) return;
// Games not prepared yet (or failed) keep their mark; their next preparation publishes the new folder.
@@ -2810,13 +2966,13 @@ rt::PackageActionResult RuntimeHost::WriteTitleMetadata(Composition& c, const rt
};
if (!c.kit) return failed("No verified runtime kit is installed.");
const rt::KitTitleVariant* variant = rt::KitVariantFor(c.kit->view, record.title_id);
- if (!variant) return failed("The kit has no title for this game.");
+ if (!variant) return failed("The runtime kit has no title for this game.");
// The kit's param.json with the game's name in place of the kit's.
std::string param;
{
const auto path = c.kit->view.root / variant->path / "sce_sys/param.json";
const int fd = open(path.c_str(), O_RDONLY | O_NOFOLLOW | O_CLOEXEC);
- if (fd < 0) return failed("The kit's title parameters are unreadable.");
+ if (fd < 0) return failed("The runtime kit's title parameters are unreadable.");
char chunk[4096];
for (ssize_t count; (count = read(fd, chunk, sizeof(chunk))) > 0 && param.size() < 64 * 1024;)
param.append(chunk, static_cast<std::size_t>(count));
@@ -2840,7 +2996,7 @@ rt::PackageActionResult RuntimeHost::WriteTitleMetadata(Composition& c, const rt
if (variant->any_title &&
!(replace_value("titleId", record.title_id) && replace_value("conceptId", record.title_id.substr(4)) &&
replace_value("contentId", "UP9000-" + record.title_id + "_00-PROSPEROWIN00001")))
- return failed("The kit's title parameters have an unexpected layout.");
+ return failed("The runtime kit's title parameters have an unexpected layout.");
const std::string name = title_name.empty() ? "Steam game " + std::to_string(record.runtime_number) : title_name;
if (!replace_value("titleName", JsonEscaped(name)))
Log("title metadata app=" + std::to_string(record.runtime_number) + " keeps the kit's name: unexpected layout");
@@ -3126,6 +3282,13 @@ std::string RuntimeHost::RunPrepare(Composition& c, const RuntimePrepareRequest&
return "This game's PS5 title is still being removed. Uninstall the game again to finish.";
// RunRemove runs inline, so removals_handled (the controller's uninstall progress) does not move.
// A pending move finishes whatever the paths say now (the game may be back in its first folder).
+ // The same folder on another USB mount: its drive changed places, and the game hasn't gone anywhere.
+ if (existing && !moving && !existing->journal && existing->install_path != request.install_path &&
+ platform::WithoutUsbMountNumber(existing->install_path) == platform::WithoutUsbMountNumber(request.install_path)) {
+ if (!RebaseUsbRecord(c, *existing, request.install_path)) return "The game's new drive could not be recorded.";
+ existing = c.records.Find(existing->install_id);
+ if (!existing) return "The game's install record is missing.";
+ }
if (existing && (moving || (!existing->journal && existing->install_path != request.install_path))) {
// Installed again on another drive (an uninstall that stopped part way can leave the title behind):
// the old title starts files that are no longer the game's. It goes, keeping its saves, and the
@@ -3178,7 +3341,7 @@ std::string RuntimeHost::RunPrepare(Composition& c, const RuntimePrepareRequest&
if (!*records_ownership) {
if (!rt::KitCapabilitiesFromManifest(c.kit->capabilities, true).game_root_unowned)
return "This drive doesn't keep file owners, and the installed runtime kit can't start games from it. "
- "Install the game on console storage, or update the kit.";
+ "Install the game on console storage, or update the runtime kit.";
Log("game root without ownership path=" + request.install_path);
game_root_owned = false;
} else if (info.st_uid != geteuid()) {
@@ -3215,7 +3378,7 @@ std::string RuntimeHost::RunPrepare(Composition& c, const RuntimePrepareRequest&
if (!record.artifacts.empty()) Log("prepare rebinds app=" + std::to_string(record.runtime_number) + " to the kit's artifacts");
record.artifacts = std::move(current);
const auto bound = c.repository.Update(record);
- if (!bound.ok()) return "The kit artifacts could not be recorded: " + bound.message();
+ if (!bound.ok()) return "The runtime kit artifacts could not be recorded: " + bound.message();
}
if (!c.installer->TitleMetadataCurrent(record)) {
const auto written = WriteTitleMetadata(c, record, request.title_name);
@@ -3289,7 +3452,7 @@ std::string RuntimeHost::RunPrepare(Composition& c, const RuntimePrepareRequest&
if (runtime_upgrade && refreshed.state == rt::PackageActionState::kComplete) {
const auto recorded = c.repository.Update(target);
Log("runtime upgrade app=" + std::to_string(request.runtime_number) + " recorded=" + std::to_string(recorded.ok()));
- if (!recorded.ok()) return "The runtime was updated but could not be recorded; press Update again.";
+ if (!recorded.ok()) return "The runtime kit was updated but could not be recorded; press Update again.";
*existing = target;
}
Log("title refresh app=" + std::to_string(request.runtime_number) + " state=" +
@@ -3302,7 +3465,7 @@ std::string RuntimeHost::RunPrepare(Composition& c, const RuntimePrepareRequest&
// owned publication again as unowned. A moved game whose publication can't be redone
// (settings older than its title, a recipe Playden no longer has) stays as it is: the way
// out is the player's confirmed choice.
- if (!existing->moved_from.empty() || NeedsUnownedPublication(c, *existing)) {
+ if (!existing->moved_from.empty() || NeedsUnownedPublication(c, *existing) || NeedsDrivePublication(c, *existing)) {
bool again = false;
std::string deferred;
if (const auto refused = RepublishSettings(c, *existing, nullptr, true, &again, &deferred); !refused.empty())
@@ -3316,7 +3479,7 @@ std::string RuntimeHost::RunPrepare(Composition& c, const RuntimePrepareRequest&
SettleBottle(c, *existing, "update");
if (const auto unlinked = UnlinkDxvkConfig(*existing); !unlinked.empty()) return unlinked;
auto admission = c.installer->AdmissionDiagnostic(*existing);
- if (admission != "ok") {
+ if (rt::AdmissionNeedsRepair(admission)) {
const auto repaired = c.installer->RepairBottle(*existing);
admission = c.installer->AdmissionDiagnostic(*existing);
Log("bottle repair app=" + std::to_string(request.runtime_number) + " state=" +
@@ -3329,7 +3492,7 @@ std::string RuntimeHost::RunPrepare(Composition& c, const RuntimePrepareRequest&
}
c.admission[existing->install_id] = admission;
PublishInstalls(c);
- if (admission != "ok") return "The PS5 title still fails its start check: " + admission;
+ if (rt::AdmissionNeedsRepair(admission)) return "The PS5 title still fails its start check: " + admission;
OpenGameFolders(c, *existing);
// An update changed the game's files since its launch was set up: the launch is made again from them.
if (FilesChanged(*existing)) {
@@ -3819,7 +3982,7 @@ std::string RuntimeHost::RunMaintenance(Composition& c, std::uint32_t app, Runti
case RuntimeMaintenance::kRepair: {
// An owned publication with a kit that admits unowned folders fails the start check once
// the player opened the folder; it is published again as unowned, just below.
- const bool unowned_upgrade = NeedsUnownedPublication(c, *record);
+ const bool unowned_upgrade = NeedsUnownedPublication(c, *record) || NeedsDrivePublication(c, *record);
const auto working = WorkingFolder(record->launch_working_directory, record->launch_path, record->launch_in_install_root);
if (const auto unwritable = EnsureWritable(record->install_path, working); !unwritable.empty())
return unwritable;
@@ -3832,7 +3995,7 @@ std::string RuntimeHost::RunMaintenance(Composition& c, std::uint32_t app, Runti
PublishInstalls(c, record->install_id);
if (repaired.state != rt::PackageActionState::kComplete) return "The bottle could not be repaired: " + repaired.message;
// A game whose folder moved fails the check until it is published again, just below.
- if (admission != "ok" && record->moved_from.empty() && !unowned_upgrade)
+ if (rt::AdmissionNeedsRepair(admission) && record->moved_from.empty() && !unowned_upgrade)
return "The PS5 title still fails its start check: " + admission;
std::string deferred;
if (auto refused = RepublishSettings(c, *record, nullptr, true, nullptr, &deferred); !refused.empty())
@@ -4673,6 +4836,7 @@ bool RuntimeHost::RunServices() {
// Install records with a journal wait for an explicit recovery action. Leftover-title
// deletion journals are resumed separately before their retired folders can be swept.
Log("startup records loaded installs=" + std::to_string(c.repository.Snapshot().size()));
+ FollowUsbDrives(c);
LoadGeneratedRecipes(c);
Log("startup generated recipes loaded");
PublishInstalls(c);
@@ -4800,7 +4964,9 @@ bool RuntimeHost::RunServices() {
if (record.state != rt::PreparationState::kReady) continue;
const bool moved = !record.moved_from.empty();
if (!moved && !NeedsUnownedPublication(c, record)) continue;
- const auto busy = c.kit ? MaintenanceRefusal(c, record) : std::string("no verified kit");
+ // The background job does these, after the first frame (below, with NeedsDrivePublication).
+ if (NeedsDriveUpdate(record)) continue;
+ const auto busy = c.kit ? MaintenanceRefusal(c, record) : std::string("no verified runtime kit");
bool published = false;
std::string deferred;
const auto refused = busy.empty() ? RepublishSettings(c, record, &published, false, nullptr, &deferred) : busy;
@@ -4825,14 +4991,22 @@ bool RuntimeHost::RunServices() {
if (published || !refused.empty())
Log("startup settings app=" + std::to_string(record.runtime_number) + " " + (refused.empty() ? "applied" : refused));
}
- const auto leftovers = LeftoverRequests(c, false);
- Publish([&](RuntimeSnapshot& s) { s.leftover_requests = leftovers; });
+ RemoveFinishedRequests(c);
const bool kit_available = c.kit.has_value();
Log("runtime ready installs=" + std::to_string(c.repository.Snapshot().size()) + " kit=" +
(kit_available ? c.kit->view.kit_id : "none (" + kit_reason + ")") +
(c.settings_data_reason.empty() ? std::string{} : " settings_data=" + c.settings_data_reason));
+ std::size_t drive_updates = 0;
+ drive_update_tried_.clear();
+ for (const auto& record : c.repository.Snapshot()) drive_updates += NeedsDriveUpdate(record) || NeedsDrivePublication(c, record) ? 1 : 0;
+ {
+ std::lock_guard<std::mutex> lock(mutex_);
+ drive_updates_pending_ = drive_updates > 0;
+ drive_update_not_before_ = {};
+ }
Publish([&](RuntimeSnapshot& s) {
s.status = RuntimeHostStatus::kReady; s.reason.clear();
+ s.drive_updates_done = 0; s.drive_updates_total = drive_updates; s.drive_updates_failed = 0;
s.kit_available = kit_available; s.kit_reason = kit_available ? std::string{} : kit_reason;
s.kit = c.kit;
// The UI reads the kit's identity and capabilities; its file and artifact lists (thousands of
@@ -4880,9 +5054,12 @@ bool RuntimeHost::RunServices() {
!scan_requests_.empty() || !prepared_dismissals_.empty() || prepared_clear_requested_ ||
(!maintenance_requests_.empty() && !snapshot_.handoff_ready) ||
(!relocation_requests_.empty() && !snapshot_.handoff_ready) ||
- (kit_reload_requested_ && !snapshot_.handoff_ready && !launch_poll_);
+ (kit_reload_requested_ && !snapshot_.handoff_ready && !launch_poll_) ||
+ (drive_updates_pending_ && !snapshot_.handoff_ready && !launch_poll_ &&
+ std::chrono::steady_clock::now() >= drive_update_not_before_);
};
if (launch_poll_) wake_.wait_for(lock, kLaunchPollInterval, ready);
+ else if (drive_updates_pending_) wake_.wait_until(lock, drive_update_not_before_, [&] { return ready() || launch_poll_; });
else wake_.wait(lock, [&] { return ready() || launch_poll_; });
if (stopping_) break;
// Between batches, with no launch to hand off or follow: the services hold no work, and PS5
@@ -5090,6 +5267,18 @@ bool RuntimeHost::RunServices() {
std::lock_guard<std::mutex> lock(mutex_);
launch_poll_ = again;
}
+ // What the player asked for goes first: one game of the drive update, only when nothing else waits.
+ if (composition) {
+ bool step = false;
+ {
+ std::lock_guard<std::mutex> lock(mutex_);
+ step = drive_updates_pending_ && !stopping_ && !launch_poll_ && !snapshot_.handoff_ready && !prepares_held_ &&
+ prepare_requests_.empty() && play_requests_.empty() && maintenance_requests_.empty() &&
+ remove_requests_.empty() && relocation_requests_.empty() &&
+ std::chrono::steady_clock::now() >= drive_update_not_before_;
+ }
+ if (step) RunDriveUpdateStep(*composition);
+ }
// One preparation per pass, taken from the front of the queue only as it starts, so PrepareNext
// reorders everything not started yet. A handoff that became ready during this pass reads install
// records on the application thread, and a quit to Home holds the queue: the queue waits for both.
diff --git a/src/homebrew/runtime_host.hpp b/src/homebrew/runtime_host.hpp
index 1c49ee0..7569e55 100644
--- a/src/homebrew/runtime_host.hpp
+++ b/src/homebrew/runtime_host.hpp
@@ -158,6 +158,8 @@ struct RuntimeHostConfig {
std::optional<runtime::LayoutPaths> layout_paths;
runtime::LayoutOps layout_operations;
std::function<std::optional<std::pair<std::string, std::string>>()> moved_games_root;
+ // Console path of the folder holding the games' Cloud indexes (.playden-saves on console storage).
+ std::string cloud_saves_root;
std::function<bool(std::string* error)> finish_games_move;
// SQLite and the native readers run on this worker. PS5 std::thread stacks are
// too small for them, so the worker uses an explicit stack size.
@@ -299,6 +301,10 @@ struct RuntimeSnapshot {
std::string reason; // why the runtime services are unavailable
bool kit_available = false;
std::string kit_reason; // why preparation is unavailable
+ // Games published again in the background after their USB drive changed places: how many of how many.
+ std::size_t drive_updates_done = 0;
+ std::size_t drive_updates_total = 0;
+ std::size_t drive_updates_failed = 0; // of those done, the ones that could not be published
std::optional<RuntimeKit> kit; // the admitted kit, for display
std::vector<RuntimeInstallView> installs;
// False while the PS5 title records could not be read (after a failed write): `installs` is then
@@ -610,6 +616,19 @@ class RuntimeHost {
// and marks the move done once no moved Ready game is left to republish.
bool MoveGames(Composition& composition, std::string* error);
bool MoveGameRecords(Composition& composition);
+ // USB drives can change places: records follow their games' folders. One publication still naming the old mount
+ // is marked (moved_from), and the startup pass or Play publishes it again; the title itself is kept.
+ void FollowUsbDrives(Composition& composition);
+ // What a game's profile and descriptor should name: the search form for a USB game whose title can find its drive,
+ // unless a copy on another drive would make the title refuse. Empty names install_path as it is.
+ std::string UsbSearchRoot(const Composition& composition, const runtime::RuntimeInstall& record) const;
+ // A Ready USB game whose publication names its folder the other way (see UsbSearchRoot).
+ bool NeedsDrivePublication(const Composition& composition, const runtime::RuntimeInstall& record) const;
+ bool RebaseUsbRecord(Composition& composition, runtime::RuntimeInstall record, const std::string& install_path);
+ // One game of that background job. A busy console (a game running, a session Playden hasn't closed yet) makes it
+ // try again shortly; a refusal is logged and left for Play.
+ void RunDriveUpdateStep(Composition& composition);
+ std::set<std::string> drive_update_tried_; // install IDs, this session; worker only
void FinishGamesMove(Composition& composition);
// Relocate on the worker.
RuntimeRelocationResult RunRelocate(Composition& composition, const RuntimeRelocation& request);
@@ -737,6 +756,7 @@ class RuntimeHost {
void PublishLaunch(Composition& composition, const runtime::LaunchSnapshot& launch);
// Settings request files that no record's journal names; with remove, deletes them.
std::size_t LeftoverRequests(Composition& composition, bool remove);
+ void RemoveFinishedRequests(Composition& composition);
bool Stopping() const;
void Log(const std::string& line) const;
void LogSteamStubPrograms(std::uint32_t app, const std::vector<runtime::GameProgram>& programs) const;
@@ -793,6 +813,9 @@ class RuntimeHost {
std::vector<std::shared_ptr<PendingRelocation>> relocation_requests_; // guarded by mutex_
int work_percent_ = -1; // worker thread only: the published work percent, -1 for none
bool launch_poll_ = false;
+ // More games to publish for a USB drive that changed places, and when to try next. Guarded by mutex_.
+ bool drive_updates_pending_ = false;
+ std::chrono::steady_clock::time_point drive_update_not_before_{};
bool cleanup_requested_ = false;
bool measure_requested_ = false;
bool kit_reload_requested_ = false; // guarded by mutex_
diff --git a/src/homebrew/simulation.cpp b/src/homebrew/simulation.cpp
index 3f569dc..bcc8e8d 100644
--- a/src/homebrew/simulation.cpp
+++ b/src/homebrew/simulation.cpp
@@ -4,6 +4,7 @@
// SPDX-License-Identifier: MIT
#include "homebrew/simulation.hpp"
+#include "platform/usb_mount.h"
#include "runtime/game_probe.h"
#include "app/diagnostic_log.h"
@@ -550,7 +551,7 @@ bool SheetDecoration(const std::string& key) { return key.rfind("heading-", 0) =
std::string action_label(const std::string& key) {
static const std::map<std::string, std::string> labels = {
- {"cancel", "Cancel"}, {"confirm-destructive", "Confirm"}, {"ready-later", "Later"}, {"alert-ok", "OK"}, {"alert-settings", "Game settings"}, {"runtime-cleanup-confirm", "Clean up"}, {"quit-to-home", "Play"}, {"favorite", "Favorite"},
+ {"cancel", "Cancel"}, {"confirm-destructive", "Confirm"}, {"runtime-batch-free", "Free up space"}, {"ready-later", "Later"}, {"update-ready-later", "Not now"}, {"update-ready-play", "Play"}, {"alert-ok", "OK"}, {"alert-settings", "Game settings"}, {"runtime-cleanup-confirm", "Clean up"}, {"quit-to-home", "Play"}, {"favorite", "Favorite"},
{"collection", "Collections"}, {"note", "Compatibility and note"}, {"verify", "Verify files"},
{"uninstall", "Uninstall…"}, {"import-remove", "Remove from library…"}, {"uninstall-delete-saves", "Delete saves too"}, {"run-once-dont-show", "Don't show again"}, {"launcher-help-dont-show", "Don't show again"}, {"launcher-help-on", "Turn on"}, {"launcher-hint-later", "Not now"}, {"launcher-hint-on", "Turn on and play"}, {"logs", "Open logs"}, {"logs-back", "Back"},
{"logs-pick", "Logs"}, {"log-install", "Install log"}, {"log-auth", "Sign-in log"},
@@ -1088,6 +1089,34 @@ void Simulation::UpdateKeptBottles(std::vector<LiveKeptBottle> kept) {
rebuild_view();
}
+void Simulation::UpdateDriveUpdates(std::size_t done, std::size_t total, std::size_t failed) {
+ if (!live() || total == 0 || (done == drive_updates_done_ && total == drive_updates_total_)) return;
+ drive_updates_done_ = done;
+ drive_updates_total_ = total;
+ const auto of = std::to_string(total) + (total == 1 ? " game" : " games");
+ if (done >= total) {
+ if (failed > 0 && failed <= total) {
+ push_notice({"drive-updates", "Drive change updated with problems", "", false, kLiveNoticeSeconds, false,
+ std::to_string(total - failed) + " of " + of + " · the others may not start from Home"});
+ return;
+ }
+ push_notice({"drive-updates", "Games updated for the drive change", "", false, kLiveNoticeSeconds, false, of});
+ return;
+ }
+ // It stays up until the job ends, however long a step waits for a game to close.
+ constexpr int kUntilItEnds = 24 * 60 * 60;
+ Notice notice{"drive-updates", "Updating games for the drive change", "", false, kUntilItEnds, false,
+ std::to_string(done) + " of " + of};
+ notice.progress = static_cast<float>(done) / static_cast<float>(total);
+ push_notice(std::move(notice));
+}
+
+void Simulation::UpdateAlsoOnDrives(std::map<GameId, std::string> drives) {
+ if (!live() || state_.also_on_drives == drives) return;
+ state_.also_on_drives = std::move(drives);
+ rebuild_view();
+}
+
void Simulation::UpdateExternalGames(std::vector<LiveExternalGame> games) {
if (!live() || games == state_.external_games) return;
state_.external_games = std::move(games);
@@ -1512,6 +1541,7 @@ std::vector<GameId> Simulation::manage_list(ManageTab tab) const {
struct Entry { GameId id; std::uint64_t bytes; std::optional<std::int64_t> played; std::string title; };
std::vector<Entry> entries;
const bool updates = tab == ManageTab::Updates;
+ const bool runtimes = tab == ManageTab::Runtimes;
const auto found = manage_tabs_.find(tab);
const bool by_played = found != manage_tabs_.end() && found->second.by_played;
// Move: nothing to list without a second drive to move to.
@@ -1524,6 +1554,11 @@ std::vector<GameId> Simulation::manage_list(ManageTab tab) const {
if (tab == ManageTab::Move && !manage_move_from_id_.empty() && installation.volume_id != manage_move_from_id_) continue;
if (tab == ManageTab::Uninstall && !manage_uninstall_from_id_.empty() && installation.volume_id != manage_uninstall_from_id_)
continue;
+ // Runtimes: games whose title a newer kit left behind or that need a repair, and those only Recreate can fix.
+ if (runtimes) {
+ const auto runtime = state_.runtime_games.find(id);
+ if (!runtime_work(id) && (runtime == state_.runtime_games.end() || !runtime->second.setup_other_kit)) continue;
+ }
// Updates: installed Steam games whose update or new DLC Steam told of; their size is the download (an
// unknown one sorts last).
if (updates) {
@@ -1565,10 +1600,39 @@ std::string Simulation::installed_blocker(GameId id) const {
return {};
}
+namespace {
+const Volume* volume_of(const State& state, const std::string& id);
+}
+
+std::optional<MaintenanceKind> Simulation::runtime_work(GameId id) const {
+ const auto found = state_.runtime_games.find(id);
+ if (found == state_.runtime_games.end()) return std::nullopt;
+ const auto& game = found->second;
+ if (game.status == "Runtime kit update available" || game.status == "Update available") return MaintenanceKind::UpdateRuntime;
+ if (game.status == "Needs repair") return MaintenanceKind::Repair;
+ return std::nullopt;
+}
+
std::string Simulation::manage_blocker(ManageTab tab, GameId id) const {
if (tab == ManageTab::Move) return move_blocker(id, manage_move_volume_id_);
auto blocker = installed_blocker(id);
- if (!blocker.empty() || tab != ManageTab::Updates) return blocker;
+ if (!blocker.empty() || tab == ManageTab::Uninstall) return blocker;
+ if (tab == ManageTab::Runtimes) {
+ // Waiting its turn in a batch that is running.
+ const auto batched = [id](const auto& entry) { return entry.first == id; };
+ if (std::any_of(runtime_batch_.begin(), runtime_batch_.end(), batched)) return "In Queue";
+ const auto* installation = find_installation(state_, id);
+ const auto* volume = installation ? volume_of(state_, installation->volume_id) : nullptr;
+ if (!installation || !installation->available || !volume || !volume->available)
+ return "Drive disconnected: connect it to update";
+ const auto runtime = state_.runtime_games.find(id);
+ if (runtime != state_.runtime_games.end() && runtime->second.setup_other_kit)
+ return "Needs Recreate bottle: open the game to do it";
+ if (runtime != state_.runtime_games.end() && runtime->second.moving)
+ return "Moving: press Play on the game to finish";
+ if (runtime == state_.runtime_games.end() || !runtime->second.can_prepare) return "Busy";
+ return {};
+ }
if (update_locked(id)) return "In Queue";
if (const auto check = update_check(id); !check.allowed) return check.reason;
return {};
@@ -1576,7 +1640,12 @@ std::string Simulation::manage_blocker(ManageTab tab, GameId id) const {
namespace {
// The tabs L1/R1 go through, in order; the destructive one last.
-constexpr ManageTab kManageTabs[] = {ManageTab::Updates, ManageTab::Move, ManageTab::Uninstall};
+constexpr ManageTab kManageTabs[] = {ManageTab::Updates, ManageTab::Runtimes, ManageTab::Move, ManageTab::Uninstall};
+
+// Below this much free on console storage the batch stops; the PS5 restarts itself at about 5 GB.
+constexpr std::uint64_t kRuntimeBatchFloorBytes = 8'000'000'000;
+// Room kept for the next game on top of that, since one can use space and free space is read every few seconds.
+constexpr std::uint64_t kRuntimeBatchStepBytes = 2'000'000'000;
const Volume* volume_of(const State& state, const std::string& id) {
const auto found = std::find_if(state.volumes.begin(), state.volumes.end(), [&id](const Volume& volume) { return volume.id == id; });
@@ -1620,6 +1689,107 @@ void Simulation::open_manage_games(ManageTab tab) {
// A batch the screen queued: it closes on the Queue so the player sees it start, on the first game's job once
// that is listed.
+// The Runtimes tab's Update: the chosen games in the order listed, one at a time. It goes to Queue, as Update does.
+void Simulation::start_runtime_batch() {
+ if (!runtime_batch_.empty() || runtime_batch_current_) return;
+ auto& tab = manage_tabs_[ManageTab::Runtimes];
+ std::vector<std::pair<GameId, MaintenanceKind>> chosen;
+ for (const auto id : manage_list(ManageTab::Runtimes))
+ if (tab.selected.contains(id) && manage_blocker(ManageTab::Runtimes, id).empty())
+ if (const auto work = runtime_work(id)) chosen.push_back({id, *work});
+ if (chosen.empty()) return;
+ tab.selected.clear();
+ runtime_batch_ = std::move(chosen);
+ runtime_batch_total_ = runtime_batch_.size();
+ runtime_batch_failed_ = 0;
+ state_.navigation.route = Route::Downloads;
+ state_.navigation.settings_rail_focused = false;
+ state_.queue_expanded = kQueuePreparation;
+ state_.navigation.focus_key = "queue-preparation";
+ if (!live()) {
+ // Fixture mode only describes what the real action does.
+ push_notice({"runtime-batch", std::to_string(runtime_batch_total_) + " games queued", "", false, kLiveNoticeSeconds, false,
+ "Fixture: nothing changes"});
+ runtime_batch_.clear();
+ return;
+ }
+ runtime_batch_step();
+}
+
+void Simulation::stop_runtime_batch() {
+ const auto done = runtime_batch_total_ - runtime_batch_.size();
+ const auto left = runtime_batch_.size();
+ runtime_batch_.clear();
+ UpdatePreparationQueue(runtime_queue_);
+ ModalEntry stopped{"confirmation", "Runtime kit update stopped", state_.navigation.focus_key, {"alert-ok", "runtime-batch-free"}, 0, false};
+ stopped.body = "Console storage would drop below " + format_bytes(kRuntimeBatchFloorBytes) +
+ ", and the PS5 can restart when it runs this low.\n\n" + std::to_string(done) + " of " +
+ std::to_string(runtime_batch_total_) + " games are done. The other " + std::to_string(left) +
+ " stay on the Runtimes tab, and they still start as they did.";
+ state_.notices.erase(std::remove_if(state_.notices.begin(), state_.notices.end(),
+ [](const Notice& notice) { return notice.id == "runtime-batch"; }),
+ state_.notices.end());
+ open_modal(std::move(stopped));
+}
+
+void Simulation::runtime_batch_step() {
+ if (!live() || (runtime_batch_.empty() && !runtime_batch_current_)) return;
+ if (runtime_batch_current_) {
+ const auto& [id, kind] = *runtime_batch_current_;
+ const auto found = state_.runtime_games.find(id);
+ if (found != state_.runtime_games.end()) {
+ const auto& game = found->second;
+ if (game.maintenance_running || game.status == "Preparing") return;
+ // A Repair is asked of the worker, which reports it a moment later: wait for its answer, within reason.
+ if (kind == MaintenanceKind::Repair && game.maintenance_message.empty() && !game.maintenance_ok &&
+ state_.clock_ticks - runtime_batch_sent_at_ < 120)
+ return;
+ if (!game.maintenance_ok) ++runtime_batch_failed_;
+ } else {
+ ++runtime_batch_failed_;
+ }
+ runtime_batch_current_.reset();
+ }
+ constexpr int kUntilItEnds = 24 * 60 * 60;
+ const auto done = runtime_batch_total_ - runtime_batch_.size();
+ if (runtime_batch_.empty()) {
+ const auto good = runtime_batch_total_ - runtime_batch_failed_;
+ const auto of = std::to_string(runtime_batch_total_) + (runtime_batch_total_ == 1 ? " game" : " games");
+ push_notice({"runtime-batch", runtime_batch_failed_ ? "Runtime kit updated with problems" : "Runtime kit updated", "",
+ false, kLiveNoticeSeconds, false,
+ runtime_batch_failed_ ? std::to_string(good) + " of " + of + " · the rest stay on the Runtimes tab" : of});
+ UpdatePreparationQueue(runtime_queue_);
+ return;
+ }
+ // Anything else being prepared goes first; the runtime tells again when it ends.
+ if (std::any_of(state_.runtime_games.begin(), state_.runtime_games.end(), [](const auto& entry) {
+ return entry.second.status == "Preparing" || entry.second.maintenance_running;
+ }))
+ return;
+ if (const auto* console = volume_of(state_, "internal"))
+ if (const auto free = volume_free(*console); free && *free < kRuntimeBatchFloorBytes + kRuntimeBatchStepBytes) {
+ stop_runtime_batch();
+ return;
+ }
+ // Things changed while it waited: a game that has since started, or that an update now holds, stays on the tab.
+ const auto next = runtime_batch_.front();
+ runtime_batch_.erase(runtime_batch_.begin());
+ const auto work = runtime_work(next.first);
+ if (!work || !manage_blocker(ManageTab::Runtimes, next.first).empty()) {
+ if (work) ++runtime_batch_failed_;
+ runtime_batch_step();
+ return;
+ }
+ runtime_batch_current_ = {next.first, *work};
+ runtime_batch_sent_at_ = state_.clock_ticks;
+ request_maintenance(runtime_batch_current_->first, runtime_batch_current_->second);
+ Notice notice{"runtime-batch", "Updating to the new runtime kit", "", false, kUntilItEnds, false,
+ std::to_string(done) + " of " + std::to_string(runtime_batch_total_) + (runtime_batch_total_ == 1 ? " game" : " games")};
+ notice.progress = static_cast<float>(done) / static_cast<float>(runtime_batch_total_);
+ push_notice(std::move(notice));
+ UpdatePreparationQueue(runtime_queue_);
+}
+
void Simulation::show_manage_queue(GameId first) {
state_.navigation.route = Route::Downloads;
state_.navigation.settings_rail_focused = false;
@@ -1978,7 +2148,7 @@ void Simulation::refresh_manage_games() {
auto& state = manage_tabs_[tab];
const auto games = manage_list(tab);
const std::set<GameId> listed(games.begin(), games.end());
- if (tab == ManageTab::Updates)
+ if (tab == ManageTab::Updates || tab == ManageTab::Runtimes)
for (const auto id : games)
if (state.listed.insert(id).second) state.selected.insert(id);
std::erase_if(state.selected, [&](GameId id) { return !listed.contains(id) || !manage_blocker(tab, id).empty(); });
@@ -2039,6 +2209,7 @@ void Simulation::build_manage_games_view() {
refresh_manage_games();
const auto current = state_.navigation.manage_tab;
const bool updates = current == ManageTab::Updates;
+ const bool runtimes = current == ManageTab::Runtimes;
const bool moves = current == ManageTab::Move;
auto& tab = manage_tabs_[current];
const auto& check = state_.update_check;
@@ -2051,11 +2222,18 @@ void Simulation::build_manage_games_view() {
};
for (const auto shown : kManageTabs) {
ViewRow item;
- item.key = shown == ManageTab::Updates ? "manage-tab-updates" : shown == ManageTab::Move ? "manage-tab-move" : "manage-tab-uninstall";
- item.title = shown == ManageTab::Updates ? "Updates" : shown == ManageTab::Move ? "Move" : "Uninstall";
+ item.key = shown == ManageTab::Updates ? "manage-tab-updates" : shown == ManageTab::Runtimes ? "manage-tab-runtimes"
+ : shown == ManageTab::Move ? "manage-tab-move" : "manage-tab-uninstall";
+ item.title = shown == ManageTab::Updates ? "Updates" : shown == ManageTab::Runtimes ? "Runtimes"
+ : shown == ManageTab::Move ? "Move" : "Uninstall";
item.selected = shown == current;
if (shown == ManageTab::Updates)
if (const auto count = manage_list(shown).size(); count > 0) item.value = std::to_string(count);
+ if (shown == ManageTab::Runtimes) {
+ std::size_t due = 0;
+ for (const auto id : manage_list(shown)) due += manage_blocker(shown, id).empty() ? 1 : 0;
+ if (due > 0) item.value = std::to_string(due);
+ }
view_.tabs.push_back(std::move(item));
}
for (const auto& volume : state_.volumes)
@@ -2063,10 +2241,14 @@ void Simulation::build_manage_games_view() {
view_.aside += (view_.aside.empty() ? "" : " · ") + volume.label + " " + (*free ? format_bytes(*free) : "0 GB") + " free";
const auto games = manage_list(current);
- view_.title = updates ? "Update games" : moves ? "Move games" : "Uninstall games";
+ view_.title = updates ? "Update games" : runtimes ? "Update to the new runtime kit" : moves ? "Move games" : "Uninstall games";
const auto* destination = moves ? volume_of(state_, manage_move_volume_id_) : nullptr;
if (moves) {
view_.subtitle = "Saves, settings and the PS5 title go with the game · it can't be played while it moves";
+ } else if (runtimes) {
+ view_.subtitle = !runtime_batch_.empty() || runtime_batch_current_
+ ? "Updating " + std::to_string(runtime_batch_total_ - runtime_batch_.size()) + " of " + std::to_string(runtime_batch_total_)
+ : "Moves games to the installed runtime kit and repairs their titles · saves and settings are kept";
} else if (!updates) {
view_.subtitle = !manage_message_.empty() ? manage_message_ : "Saves and settings are kept · free up space on your drives";
} else if (check.checking) {
@@ -2099,7 +2281,7 @@ void Simulation::build_manage_games_view() {
auto& move_to = row("manage-move-to", RowKind::Action, "Move to", "manage-move-to");
move_to.enabled = move_volumes().size() >= 2;
move_to.value = !move_to.enabled ? "No other drive" : destination ? destination->label : "No drive";
- } else if (!updates && (!uninstall_from_volumes().empty() || volume_of(state_, manage_uninstall_from_id_))) {
+ } else if (current == ManageTab::Uninstall && (!uninstall_from_volumes().empty() || volume_of(state_, manage_uninstall_from_id_))) {
// Drive narrows the list to one drive's games, to free room on that drive.
auto& drive = row("manage-uninstall-from", RowKind::Action, "Drive", "manage-uninstall-from");
const auto* source = volume_of(state_, manage_uninstall_from_id_);
@@ -2127,6 +2309,11 @@ void Simulation::build_manage_games_view() {
item.selected = tab.selected.contains(id);
const std::uint64_t size = installation ? installation->installed_bytes : 0;
item.value = update != check.games.end() ? update_size_text(id) : size > 0 ? format_bytes(size) : std::string();
+ if (runtimes) {
+ const auto work = runtime_work(id);
+ item.value = !manage_blocker(current, id).empty() ? "Skipped"
+ : work == MaintenanceKind::Repair ? "Repair" : "Runtime kit";
+ }
if (item.selected) bytes += size;
// The last-played column.
const auto runtime = state_.runtime_games.find(id);
@@ -2137,8 +2324,25 @@ void Simulation::build_manage_games_view() {
const auto blocker = manage_blocker(current, id);
if (!blocker.empty()) {
item.subtitle = blocker != "Playing" ? blocker
- : updates ? "Playing: close it to update" : moves ? "Playing: close it to move" : "Playing: close it to uninstall";
+ : updates || runtimes ? "Playing: close it to update" : moves ? "Playing: close it to move" : "Playing: close it to uninstall";
item.enabled = false;
+ } else if (runtimes) {
+ // The last try's failure stays until it goes again; the status says what is due otherwise.
+ const auto* game_runtime = runtime != state_.runtime_games.end() ? &runtime->second : nullptr;
+ const auto* volume = installation ? volume_of(state_, installation->volume_id) : nullptr;
+ const std::string where = volume ? " · " + volume->label : std::string();
+ if (game_runtime && (game_runtime->maintenance == MaintenanceKind::UpdateRuntime || game_runtime->maintenance == MaintenanceKind::Repair) &&
+ !game_runtime->maintenance_running && !game_runtime->maintenance_ok && !game_runtime->maintenance_message.empty()) {
+ item.subtitle = "Failed: " + game_runtime->maintenance_message;
+ item.tone = "problem";
+ } else if (const auto refused = state_.preparation_queue.refused.find(id); refused != state_.preparation_queue.refused.end()) {
+ // Listed with the reason, and it can go again: some refusals pass, such as a game that was still closing.
+ item.subtitle = "Refused: " + refused->second;
+ item.tone = "problem";
+ } else {
+ item.subtitle = (game_runtime ? game_runtime->status : std::string()) + where;
+ item.tone = "update";
+ }
} else if (const auto* stopped = updates || moves ? nullptr : uninstall_stop(id)) {
// Its uninstall stopped: the reason stays until it goes again or is dismissed in Queue.
item.subtitle = "Stopped: " + stopped->stopped;
@@ -2169,6 +2373,9 @@ void Simulation::build_manage_games_view() {
} else if (moves) {
empty.title = "Nothing to move";
empty.subtitle = "Games installed from Steam can move here. Imported games use Copy or Move into Playden.";
+ } else if (runtimes) {
+ empty.title = "Up to date";
+ empty.subtitle = "Every game is on the installed runtime kit.";
} else if (!updates && volume_of(state_, manage_uninstall_from_id_)) {
empty.title = "Nothing installed";
empty.subtitle = "No games on " + volume_of(state_, manage_uninstall_from_id_)->label + ".";
@@ -2188,15 +2395,22 @@ void Simulation::build_manage_games_view() {
const auto count = tab.selected.size();
// Uninstall always asks first; Update asks when a drive is short of room.
- const bool asks = count > 0 && (updates ? !manage_updates().short_drive.empty() : !moves);
+ const bool asks = count > 0 && !runtimes && (updates ? !manage_updates().short_drive.empty() : !moves);
auto& primary = row("manage-primary", RowKind::Action,
- std::string(updates ? "Update" : moves ? "Move" : "Uninstall") +
+ std::string(updates || runtimes ? "Update" : moves ? "Move" : "Uninstall") +
(count > 0 ? " " + std::to_string(count) : std::string()) + (asks ? "…" : ""),
- updates ? "manage-update" : moves ? "manage-move" : "manage-uninstall");
- primary.enabled = count > 0;
- primary.dangerous = !updates && !moves;
+ updates ? "manage-update" : runtimes ? "manage-runtimes" : moves ? "manage-move" : "manage-uninstall");
+ primary.enabled = count > 0 && (!runtimes || (runtime_batch_.empty() && !runtime_batch_current_));
+ primary.dangerous = current == ManageTab::Uninstall;
if (count == 0) {
- view_.footer = updates ? "Select games to update" : moves ? "Select games to move" : "Select games to uninstall";
+ view_.footer = updates || runtimes ? "Select games to update" : moves ? "Select games to move" : "Select games to uninstall";
+ } else if (runtimes) {
+ const auto* console = volume_of(state_, "internal");
+ const auto free = console ? volume_free(*console) : std::nullopt;
+ view_.footer = std::to_string(count) + " selected";
+ if (free && console)
+ view_.footer += " · " + format_bytes(*free) + " free on " + console->label + " · stops before it drops below " +
+ format_bytes(kRuntimeBatchFloorBytes);
} else if (moves) {
// "2 selected · 99.1 GB to USB Drive · 311 GB free after", or what more the drive needs.
const auto plan = manage_moves();
@@ -2226,7 +2440,7 @@ void Simulation::build_manage_games_view() {
}
}
view_.legends = {"Cross Select", "Square " + select_title,
- updates ? "Triangle Update selected" : moves ? "Triangle Move selected" : "Triangle Uninstall selected",
+ updates || runtimes ? "Triangle Update selected" : moves ? "Triangle Move selected" : "Triangle Uninstall selected",
"L1/R1 Switch tab", "Circle Close"};
}
@@ -2359,6 +2573,11 @@ void Simulation::RequestRuntimePrepare(GameId id) {
}
void Simulation::UpdatePreparationQueue(PreparationQueue queue) {
+ runtime_queue_ = queue;
+ // The batch's games wait in the model; Queue lists them after what the runtime already has.
+ for (const auto& [id, kind] : runtime_batch_)
+ if (std::find(queue.waiting.begin(), queue.waiting.end(), id) == queue.waiting.end() && queue.active != id)
+ queue.waiting.push_back(id);
// A dismissal or Prepare next the runtime has not carried out yet keeps showing as asked; once the
// runtime's list no longer has the entry, or has the game first, it is done.
std::erase_if(prepared_dismissed_, [&queue](const LiveCompletedPreparation& done) {
@@ -2394,6 +2613,10 @@ void Simulation::prepare_next(GameId id) {
const auto found = std::find(waiting.begin(), waiting.end(), id);
if (found == waiting.end() || found == waiting.begin()) return;
std::rotate(waiting.begin(), found, found + 1);
+ // A game still waiting in the Runtimes batch goes first in it too.
+ if (const auto batched = std::find_if(runtime_batch_.begin(), runtime_batch_.end(), [id](const auto& entry) { return entry.first == id; });
+ batched != runtime_batch_.end())
+ std::rotate(runtime_batch_.begin(), batched, batched + 1);
if (live()) {
pending_prepare_next_requests_.push_back(id);
prepare_next_asked_ = id;
@@ -2659,7 +2882,7 @@ void Simulation::close_game_modals() {
modals.erase(std::remove_if(modals.begin(), modals.end(), [](const ModalEntry& modal) {
return std::none_of(modal.action_keys.begin(), modal.action_keys.end(), [](const std::string& key) {
return key == "self-update-install" || key == "self-update-restart" || key == "release-notes-ok" ||
- key == "kit-install";
+ key == "kit-install" || key == "runtime-prompt-update";
});
}), modals.end());
}
@@ -2716,7 +2939,9 @@ void Simulation::UpdateRuntime(RuntimeState runtime, const std::vector<LiveRunti
if (before->second.maintenance_running && !game.maintenance_running && game.maintenance) {
const bool apply = *game.maintenance == MaintenanceKind::ApplySettings;
const bool deferred = game.maintenance_message == "Changes apply the next time Playden starts the game.";
- if (!apply || (!game.maintenance_ok && !deferred))
+ // A game in the Runtimes batch tells on its row and in the batch's own notice: a dialog each would pile up.
+ const bool batched = runtime_batch_current_ && runtime_batch_current_->first == id;
+ if (!batched && (!apply || (!game.maintenance_ok && !deferred)))
push_notice({"maintenance-" + ToKey(id), game.maintenance_ok ? title + ": done" : title + ": not done", "",
false, kLiveNoticeSeconds * (game.maintenance_ok ? 1 : 2), !game.maintenance_ok, game.maintenance_message});
}
@@ -2749,6 +2974,9 @@ void Simulation::UpdateRuntime(RuntimeState runtime, const std::vector<LiveRunti
}
show_ready_prompt();
open_settings_after_prepare();
+ runtime_batch_step();
+ show_update_ready_prompt();
+ show_runtime_prompt();
refresh_manage_games();
rebuild_view();
}
@@ -2795,6 +3023,67 @@ void Simulation::show_ready_prompt() {
open_modal(std::move(prompt));
}
+void Simulation::NotifyRuntimeUpdated(GameId id) {
+ if (!live()) return;
+ if (std::find(update_ready_prompts_.begin(), update_ready_prompts_.end(), id) == update_ready_prompts_.end())
+ update_ready_prompts_.push_back(id);
+ show_update_ready_prompt();
+ rebuild_view();
+}
+
+// "<game> is ready": the player pressed Play and the update took a while, so the dialog comes up wherever they are now,
+// once whatever is open closes.
+void Simulation::show_update_ready_prompt() {
+ if (!live() || update_ready_prompts_.empty() || !state_.navigation.modals.empty() || state_.editor.active) return;
+ const auto route = state_.navigation.route;
+ if (route == Route::Session || route == Route::Startup || route == Route::SignIn) return;
+ const auto id = update_ready_prompts_.front();
+ update_ready_prompts_.erase(update_ready_prompts_.begin());
+ const auto* game = find_game(state_, id);
+ if (!game) return;
+ update_ready_game_ = id;
+ ModalEntry prompt{"confirmation", game->title + " is ready", state_.navigation.focus_key,
+ {"update-ready-later", "update-ready-play"}, 1, false};
+ prompt.body = "Its runtime kit is up to date. Starting it now closes Playden.";
+ open_modal(std::move(prompt));
+}
+
+void Simulation::show_runtime_prompt() {
+ // Answered, whichever way it closed. Closing Playden with it open asks again next time.
+ if (runtime_prompt_open_ && state_.navigation.modals.empty()) {
+ runtime_prompt_open_ = false;
+ state_.runtime_prompt_kit = runtime_prompt_shown_kit_;
+ save_profile();
+ }
+ if (!live() || !preferences_loaded_ || state_.kit.manifest_sha256.empty() || state_.kit.manifest_sha256 == state_.runtime_prompt_kit)
+ return;
+ const auto route = state_.navigation.route;
+ if (!state_.navigation.modals.empty() || state_.editor.active || !pending_update_prompt_.empty() || route == Route::Session ||
+ route == Route::Startup || route == Route::SignIn || !runtime_batch_.empty() || runtime_batch_current_)
+ return;
+ std::size_t updates = 0, repairs = 0;
+ for (const auto id : manage_list(ManageTab::Runtimes)) {
+ if (!manage_blocker(ManageTab::Runtimes, id).empty()) continue;
+ const auto work = runtime_work(id);
+ updates += work == MaintenanceKind::UpdateRuntime ? 1 : 0;
+ repairs += work == MaintenanceKind::Repair ? 1 : 0;
+ }
+ // A repair alone isn't news about the kit. The next kit asks again; until then the tab has them.
+ if (updates == 0) return;
+ runtime_prompt_open_ = true;
+ runtime_prompt_shown_kit_ = state_.kit.manifest_sha256;
+ runtime_prompt_games_ = updates + repairs;
+ ModalEntry prompt{"confirmation", "Update games to the new runtime kit?", state_.navigation.focus_key,
+ {"ready-later", "runtime-prompt-update"}, 0, false};
+ prompt.body = std::to_string(updates) +
+ (updates == 1 ? " game uses an older version of the runtime kit" : " games use an older version of the runtime kit") +
+ (repairs ? ", and " + std::to_string(repairs) + (repairs == 1 ? " needs a repair" : " need a repair") : std::string()) +
+ ".\n\nNothing is downloaded from Steam, and saves and settings are kept. "
+ "Later leaves them on the Runtimes tab of Manage installed games.";
+ // Later has the focus: this can open just as the player presses Cross on a game.
+ open_modal(std::move(prompt));
+}
+
bool Simulation::NotifyLauncherHint(GameId id, const std::string& program) {
const auto* game = find_game(state_, id);
// Until the game and the kit's abilities are known. A kit without launcher mode has nothing to offer.
@@ -3929,7 +4218,8 @@ void Simulation::ApplyLiveDownloadServers(const LiveDownloadServers& snapshot) {
playden::Preferences Simulation::ExportPreferences() const {
return {state_.reduced_motion, state_.title_store_suffix, state_.cloud_saves_auto, state_.sign_in_password,
state_.downloads_slow_network, state_.stay_signed_in, state_.beta_updates, state_.download_server,
- state_.web_access, state_.content_language, state_.hide_run_once_help, state_.hide_launcher_help};
+ state_.web_access, state_.content_language, state_.hide_run_once_help, state_.hide_launcher_help,
+ state_.runtime_prompt_kit};
}
void Simulation::apply_organization_snapshot(const playden::OrganizationSnapshot& snapshot) {
@@ -4163,6 +4453,7 @@ bool Simulation::ApplyPreferences(PersistenceLoadToken token,
state_.content_language = loaded.preferences.content_language;
state_.hide_run_once_help = loaded.preferences.hide_run_once_help;
state_.hide_launcher_help = loaded.preferences.hide_launcher_help;
+ state_.runtime_prompt_kit = loaded.preferences.runtime_prompt_kit;
captured_preferences_ = loaded.preferences;
preferences_saved_revision_ = preferences_revision_;
}
@@ -4429,6 +4720,7 @@ bool Simulation::record_live_persistence() {
after_preferences.content_language != captured_preferences_.content_language ||
after_preferences.hide_run_once_help != captured_preferences_.hide_run_once_help ||
after_preferences.hide_launcher_help != captured_preferences_.hide_launcher_help ||
+ after_preferences.runtime_prompt_kit != captured_preferences_.runtime_prompt_kit ||
after_preferences.steam_stay_signed_in != captured_preferences_.steam_stay_signed_in);
if (organization_changed && !snapshot_within_model_bounds(after_organization)) {
@@ -4459,6 +4751,7 @@ bool Simulation::record_live_persistence() {
state_.content_language = captured_preferences_.content_language;
state_.hide_run_once_help = captured_preferences_.hide_run_once_help;
state_.hide_launcher_help = captured_preferences_.hide_launcher_help;
+ state_.runtime_prompt_kit = captured_preferences_.runtime_prompt_kit;
organization_journal_full_ = true;
force_organization_reset_ = false;
force_organization_selection_ = false;
@@ -4963,7 +5256,7 @@ bool Simulation::scenario(const std::string& name) {
// (with and without room), the Uninstall tab with a game running, and the Settings rows that open it.
static const std::set<std::string> known = {"manage-updates", "manage-updates-checking", "manage-uninstall",
"manage-updates-current", "manage-updates-unchecked", "manage-updates-failed",
- "manage-updates-no-room", "manage-settings", "manage-move",
+ "manage-updates-no-room", "manage-settings", "manage-move", "manage-runtimes", "manage-runtimes-empty",
"manage-move-no-room"};
if (!known.contains(name) || state_.games.size() < 6) return false;
manage_fixture_ = true;
@@ -5003,6 +5296,26 @@ bool Simulation::scenario(const std::string& name) {
running.play_status = "Playing";
state_.runtime_games[running.game_id] = running;
state_.update_check.checked_at = now - 2 * 3600;
+ // The Runtimes tab: two kit updates, a repair, and two it can only skip, beside the running game.
+ if (name == "manage-runtimes") {
+ const auto due = [this](std::size_t index, const char* status) {
+ LiveRuntimeGame game;
+ game.game_id = state_.games[index].id;
+ game.status = status;
+ game.prepared = game.has_title = game.can_prepare = true;
+ game.runtime_current = false;
+ game.activity = TitleActivity::Stopped;
+ state_.runtime_games[game.game_id] = game;
+ };
+ due(0, "Runtime kit update available");
+ due(1, "Needs repair");
+ due(2, "Runtime kit update available");
+ due(4, "Not prepared");
+ state_.runtime_games[state_.games[4].id].setup_other_kit = true;
+ due(5, "Runtime kit update available");
+ state_.preparation_queue.refused[state_.games[5].id] = "Playden no longer knows how to start this game.";
+ state_.runtime_games[state_.games[3].id].status = "Runtime kit update available";
+ }
// 82 GB free on the console's drive as in the mockup, or 1 GB: short of its games' 2.2 GB of updates.
if (auto* volume = find_volume(state_, "internal"); volume && volume->capacity_bytes > 82'000'000'000) {
volume->used_bytes = volume->capacity_bytes - (name == "manage-updates-no-room" ? 1'000'000'000 : 82'000'000'000);
@@ -5030,6 +5343,7 @@ bool Simulation::scenario(const std::string& name) {
state_.navigation.focus_key = "settings-game-updates";
} else {
open_manage_games(name == "manage-uninstall" ? ManageTab::Uninstall
+ : name.rfind("manage-runtimes", 0) == 0 ? ManageTab::Runtimes
: name.rfind("manage-move", 0) == 0 ? ManageTab::Move : ManageTab::Updates);
refresh_manage_games();
}
@@ -5329,6 +5643,10 @@ bool Simulation::scenario(const std::string& name) {
state_.session = name == "crash" ? SessionState::Crashed : SessionState::Failed;
state_.session_error = name == "launch-failure" ? "Simulated launch failed" : (name == "crash" ? "Game exited unexpectedly" : "Game did not stop");
state_.navigation.focus_key = name == "crash" ? "session-logs" : "session-retry";
+ } else if (name == "drive-updates") {
+ Notice notice{"drive-updates", "Updating games for the drive change", "", false, 3600, false, "12 of 37 games"};
+ notice.progress = 12.0F / 37.0F;
+ state_.notices.push_back(std::move(notice));
} else if (name == "controller-disconnected") {
state_.controller_connected = false;
state_.notices.push_back({"controller", "Controller disconnected", "controller-test", true, 0});
@@ -5746,6 +6064,8 @@ void Simulation::rebuild_view() {
for (const auto& action_key : modal.action_keys) {
auto& item = row(action_key, RowKind::Action, action_label(action_key), action_key);
item.dangerous = modal.destructive && action_key != "cancel";
+ if (action_key == "runtime-prompt-update")
+ item.title = "Update " + std::to_string(runtime_prompt_games_) + (runtime_prompt_games_ == 1 ? " game" : " games");
if (modal.id == "job-actions")
if (const auto label = move_action_label(action_key); !label.empty())
if (const auto* job = find_job(state_, action_key.substr(action_key.find('-', 4) + 1)); job && job->move)
@@ -5886,7 +6206,7 @@ void Simulation::rebuild_view() {
if (modal.id == "install" && action_key == "install-language") {
const auto id = state_.navigation.detail_id.value_or(state_.navigation.selected_game_id);
item.value = playden::steam::LanguageName(install_language(id));
- item.subtitle = install_language_.empty() ? "From Settings › Downloads" : "This game only";
+ item.subtitle = install_language_.empty() ? "From Settings, under Downloads" : "This game only";
}
// Every library filter is a toggle. Demos and Family sharing are on unless the player hid them;
// the others (Playable) narrow the library while on.
@@ -6174,19 +6494,19 @@ void Simulation::rebuild_view() {
? "Nothing else to reset. The program you chose stays; change it in the Program row."
: "Nothing to reset: the settings follow the preset.";
} else if (kind == MaintenanceKind::UpdateRuntime) {
- // What Play does first for a title on an older kit's runtime ("Kit update available"), alone.
- const bool stale = runtime && (runtime->status == "Kit update available" || runtime->status == "Update available");
- item.title = "Update runtime…";
- item.subtitle = "Moves the game to the installed kit's runtime without starting it.";
+ // What Play does first for a title on an older kit's runtime ("Runtime kit update available"), alone.
+ const bool stale = runtime && (runtime->status == "Runtime kit update available" || runtime->status == "Update available");
+ item.title = "Update runtime kit…";
+ item.subtitle = "Moves the game to the installed runtime kit without starting it.";
item.badge = "Game must be closed";
item.enabled = stale && runtime->can_prepare && closed && !busy;
- // While it runs the title is being prepared, no longer "Kit update available".
+ // While it runs the title is being prepared, no longer "Runtime kit update available".
const bool updating = busy && runtime->maintenance == MaintenanceKind::UpdateRuntime;
// A setup an earlier kit left has no title to update: it is made again.
if (!stale && !updating)
- item.subtitle = runtime && runtime->status == "No kit" ? "Needs a usable runtime kit."
+ item.subtitle = runtime && runtime->status == "No runtime kit" ? "Needs a usable runtime kit."
: runtime && runtime->setup_other_kit
- ? "Setup was started with an earlier kit. Use Recreate bottle to finish it; saves are kept."
+ ? "Setup was started with an earlier version of the runtime kit. Use Recreate bottle to finish it; saves are kept."
: "Already up to date.";
else if (!updating && !closed) item.subtitle = closed_reason;
else if (!updating && !runtime->can_prepare && !busy) item.subtitle = "Wait for the game's setup to finish.";
@@ -6803,6 +7123,14 @@ void Simulation::rebuild_view() {
status.subtitle = "Connect " + (volume ? volume->label : std::string("its storage")) + " to use this game";
status.enabled = false;
}
+ if (const auto also = state_.also_on_drives.find(game->id); installation->available && also != state_.also_on_drives.end()) {
+ const auto* here = find_volume(state_, installation->volume_id);
+ const auto* other = find_volume(state_, also->second);
+ auto& status = row("details-also-on", RowKind::Status, "On two drives", "");
+ status.subtitle = "Playden uses the copy on " + (here ? here->label : std::string("this drive")) + ". Delete the one on " +
+ (other ? other->label : std::string("the other drive")) + " so the PS5 can't mix them up.";
+ status.enabled = false;
+ }
if (installation->available) {
// The primary action says what pressing does; setup facts and a single
// player-facing hint carry its state without repeating technical diagnostics.
@@ -6810,8 +7138,8 @@ void Simulation::rebuild_view() {
const auto play_game = state_.runtime_games.find(game->id);
if (play_game != state_.runtime_games.end()) {
const auto& value = play_game->second;
- const bool kit_update = value.status == "Kit update available" || value.status == "Update available";
- const bool no_kit = value.status == "No kit";
+ const bool kit_update = value.status == "Runtime kit update available" || value.status == "Update available";
+ const bool no_kit = value.status == "No runtime kit";
const bool prepares_first = !value.ready && value.can_prepare &&
(value.status == "Not prepared" || kit_update || value.status == "Needs repair");
const bool recovery = value.status == "Needs recovery" || value.status == "Failed";
@@ -6837,7 +7165,7 @@ void Simulation::rebuild_view() {
: queued_uninstall ? "Uninstalling…"
: value.awaiting_registration ? "Quits to Home"
: !value.play_status.empty() ? value.play_status
- : prepares_first ? (kit_update ? "Kit update first" : value.status == "Needs repair" ? "Repairs first" : "Sets up first")
+ : prepares_first ? (kit_update ? "Updates runtime kit first" : value.status == "Needs repair" ? "Repairs first" : "Sets up first")
// Only the step's number, if it has one: Setup says what it does, and the button keeps its width.
: value.status == "Preparing" ? (value.detail.find(" · ") == std::string::npos
? std::string{} : value.detail.substr(0, value.detail.find(" · ")))
@@ -6992,11 +7320,11 @@ void Simulation::rebuild_view() {
runtime->status != "Removal incomplete";
const std::string status = !installation->available ? "Unavailable"
: runtime_uninstalling ? "Removing"
- : runtime ? runtime->status : !live() ? (installation->runtime_ready ? "Ready" : "No kit") : "Checking";
+ : runtime ? runtime->status : !live() ? (installation->runtime_ready ? "Ready" : "No runtime kit") : "Checking";
const bool waiting = runtime && runtime->awaiting_registration && installation->available && !runtime_uninstalling;
- const bool kit_update = status == "Kit update available" || status == "Update available";
+ const bool kit_update = status == "Runtime kit update available" || status == "Update available";
const std::string tone = waiting || kit_update ? "busy" : status == "Ready" ? "good"
- : status == "Failed" || status == "No kit" ? "problem"
+ : status == "Failed" || status == "No runtime kit" ? "problem"
: status == "Needs repair" || status == "Needs recovery" || status == "Registration pending" ||
status == "Removal incomplete" ? "attention" : "quiet";
// The game right ahead of this one in the preparation queue (the one being set up now when
@@ -7017,7 +7345,7 @@ void Simulation::rebuild_view() {
// Once setup has finished, when Play can start the game and adding the installer would help.
const bool physx_message = runtime && runtime->physx_needed && status == "Ready" && runtime->play_work.empty();
auto& setup = row("details-setup", RowKind::Status, "Setup", "");
- setup.value = waiting ? "Waiting for the PS5" : kit_update ? "Kit update available"
+ setup.value = waiting ? "Waiting for the PS5" : kit_update ? "Runtime kit update available"
: status == "Not prepared" ? "Not set up" : status == "Needs recovery" ? "Interrupted"
: status == "Registration pending" ? "Not confirmed" : status == "Removal incomplete" ? "Removing"
: status == "Preparing" && runtime && !runtime->detail.empty() ? runtime->detail : status;
@@ -7047,14 +7375,14 @@ void Simulation::rebuild_view() {
else if (status == "Registration pending") hint = "The PS5 hasn't confirmed " + game->title + " yet.";
else if (status == "Removal incomplete") hint = "Removing " + game->title + " from the PS5 Home screen stopped partway.";
else if (status == "Needs repair") hint = "Some of " + game->title + "'s setup files changed.";
- else if (status == "No kit") hint = "Playden needs its runtime kit to set up games.";
+ else if (status == "No runtime kit") hint = "Playden needs its runtime kit to set up games.";
else if (physx_message) {
const auto& version = *runtime->physx_needed;
hint = version.empty() ? "This game needs PhysX. Add its installer to the game's _Redist folder, then press Play."
: "This game needs PhysX " + version + ". Add its installer to the game's _Redist folder, then press Play.";
}
else if (runtime && runtime->setup_other_kit)
- hint = "Setup started with an earlier kit. Recreate bottle makes it again; saves and settings are kept.";
+ hint = "Setup started with an earlier version of the runtime kit. Recreate bottle makes it again; saves and settings are kept.";
else if (runtime && (status == "Needs recovery" || status == "Failed")) {
const bool stopped = status == "Needs recovery";
if (runtime->failure_code.rfind("kit-", 0) == 0 ||
@@ -7461,11 +7789,11 @@ void Simulation::rebuild_view() {
auto& kit = add("settings-kit", RowKind::Action, "Runtime kit", "kit");
if (phase == "available") {
kit.value = "Download";
- kit.subtitle = update.kit_replaces ? "The installed kit isn't the one this version was made for"
+ kit.subtitle = update.kit_replaces ? "The installed runtime kit isn't the one this version was made for"
: "Needed to prepare and play games";
} else if (phase == "checking") {
kit.value = "Checking…";
- kit.subtitle = "Looking for this version's kit on GitHub";
+ kit.subtitle = "Looking for this version's runtime kit on GitHub";
} else if (phase == "failed") {
kit.value = "Try again";
kit.subtitle = update.kit_error;
@@ -9445,7 +9773,17 @@ void Simulation::activate() {
wait.body = "Playden quits to the PS5 Home screen once this game's saves are in step with Steam Cloud.";
open_modal(std::move(wait));
}
- } else if (action_name == "ready-later" || action_name == "alert-ok" || action_name == "launcher-hint-later") {
+ } else if (action_name == "update-ready-play") {
+ const auto game = update_ready_game_;
+ close_modal();
+ update_ready_game_ = {};
+ if (game.valid() && find_game(state_, game) && !update_locked(game)) {
+ if (auto previous = state_.runtime_games.find(game); previous != state_.runtime_games.end())
+ previous->second.play_detail.clear();
+ pending_runtime_play_requests_.push_back(game);
+ }
+ } else if (action_name == "ready-later" || action_name == "alert-ok" || action_name == "launcher-hint-later" ||
+ action_name == "update-ready-later") {
close_modal();
} else if (action_name == "launcher-hint-on") {
const auto game = alert_settings_game_;
@@ -9491,6 +9829,18 @@ void Simulation::activate() {
ask_manage_uninstall();
} else if (action_name == "manage-update") {
queue_manage_updates();
+ } else if (action_name == "manage-runtimes") {
+ start_runtime_batch();
+ } else if (action_name == "runtime-prompt-update") {
+ close_modal();
+ auto& tab = manage_tabs_[ManageTab::Runtimes];
+ tab.selected.clear();
+ for (const auto id : manage_list(ManageTab::Runtimes))
+ if (manage_blocker(ManageTab::Runtimes, id).empty()) tab.selected.insert(id);
+ start_runtime_batch();
+ } else if (action_name == "runtime-batch-free") {
+ close_modal();
+ open_manage_games(ManageTab::Uninstall);
} else if (action_name == "manage-move") {
queue_manage_moves();
} else if (action_name == "manage-move-to") {
@@ -9876,7 +10226,7 @@ void Simulation::activate() {
heading = "Reset settings?";
body = "Your changes to " + title + "'s settings are removed. The chosen preset and program stay; saves are not touched.";
} else if (action_name == "maintenance-update") {
- heading = "Update the runtime?";
+ heading = "Update the runtime kit?";
body = title + " moves to the installed runtime kit, and settings that need it apply. "
"The game doesn't start; saves are not touched.";
} else if (action_name == "maintenance-repair") {
@@ -10527,6 +10877,7 @@ bool Simulation::action(const std::string& logical_action) {
// Triangle runs the open tab's action from anywhere on the screen; the dialog returns to the row.
if (state_.navigation.manage_tab == ManageTab::Uninstall) ask_manage_uninstall();
else if (state_.navigation.manage_tab == ManageTab::Move) queue_manage_moves();
+ else if (state_.navigation.manage_tab == ManageTab::Runtimes) start_runtime_batch();
else queue_manage_updates();
}
else if (logical_action == "triangle" && !state_.editor.active && !state_.navigation.modals.empty() &&
@@ -10693,7 +11044,9 @@ bool Simulation::action(const std::string& logical_action) {
}
else { last_error_ = "Unknown action: " + logical_action; return false; }
show_ready_prompt(); // a ready-to-play prompt waits for the player to close what was open
+ show_update_ready_prompt();
show_alert_prompt();
+ show_runtime_prompt();
rebuild_view();
if (live() || state_.persistence_available) save_profile();
return true;
@@ -11243,7 +11596,7 @@ void Simulation::request_maintenance(GameId id, MaintenanceKind kind) {
: kind == MaintenanceKind::Repair ? "Repaired"
: kind == MaintenanceKind::BackupSaves ? "Saves backed up"
: kind == MaintenanceKind::RecreateBottle ? "Bottle recreated"
- : kind == MaintenanceKind::UpdateRuntime ? "Runtime updated" : "Settings applied";
+ : kind == MaintenanceKind::UpdateRuntime ? "Runtime kit updated" : "Settings applied";
push_notice({"maintenance-" + ToKey(id), words, "", false, kLiveNoticeSeconds, false, "Simulated"});
return;
}
diff --git a/src/homebrew/simulation.hpp b/src/homebrew/simulation.hpp
index 5b99adf..d744108 100644
--- a/src/homebrew/simulation.hpp
+++ b/src/homebrew/simulation.hpp
@@ -27,7 +27,7 @@ using GameId = playden::GameId;
enum class Route { Startup, SignIn, Home, Library, Downloads, Settings, Details, Session, Saves, SaveDetails, ManageGames };
// Manage installed games: one tab per batch action. Each has its own list and selection.
-enum class ManageTab { Updates, Move, Uninstall };
+enum class ManageTab { Updates, Runtimes, Move, Uninstall };
enum class ModelMode { Simulation, Live };
// UsePassword/UseQr switch the sign-in screen's method; BeginPassword and SubmitCode carry the form's
// secrets, which the controller takes with TakeSignInCredentials and TakeGuardCode.
@@ -247,6 +247,8 @@ struct LiveRuntimeGame {
// Its setup stopped before Ready and left a PS5 title or bottle made with an earlier kit: Try again
// can't finish it, Recreate bottle does (RuntimeInstallView::setup_other_kit).
bool setup_other_kit = false;
+ // A move stopped part way: "Needs repair", but only Play finishes it.
+ bool moving = false;
// Has a prepared title (Ready, perhaps with an update or repair to make): its Game
// settings and maintenance apply to it.
bool prepared = false;
@@ -775,6 +777,7 @@ struct Notice {
bool failure = false; // drawn with the failure tone
std::string detail; // second line; when empty the action key is shown, as fixtures expect
bool alert = true; // a live failure waits in a dialog for OK; false keeps it a corner notification
+ float progress = -1.0F; // 0 to 1: a corner notification draws a bar; below 0 it has none
};
struct ControllerState {
@@ -823,6 +826,7 @@ struct State {
std::vector<LiveLeftoverDelete> leftover_deletions;
std::vector<LiveKeptBottle> kept_bottles; // live: saves kept from uninstalled games
std::vector<LiveExternalGame> external_games; // live: games playing in place (imported)
+ std::map<GameId, std::string> also_on_drives; // live: a game's folder is on this USB volume too
std::vector<LiveImportCandidate> import_candidates; // live: folders on the drives that could be imported
bool import_scanning = false; // live: Playden is looking for games to import
LiveSavesJob saves_job; // live: the Saves tab's running check or Sync all
@@ -861,6 +865,7 @@ struct State {
// the chosen provider's stable identifier.
std::string download_server;
bool hide_run_once_help = false; // "Don't show again" on Run launcher or setup's dialog
+ std::string runtime_prompt_kit; // the kit whose runtime kit prompt was answered (its manifest SHA-256)
bool hide_launcher_help = false; // ...and on the one for turning on Start through a launcher
bool web_access = true; // Settings › Web access: the logs and game files page on the local network (on by default)
std::string web_pairing_code; // live: a browser asked to pair; shown in a corner over every screen
@@ -1029,6 +1034,9 @@ public:
[[nodiscard]] std::vector<std::string> TakeLeftoverDeleteRequests();
// Live mode: games playing in place, and what the drives offer to import.
void UpdateExternalGames(std::vector<LiveExternalGame> games);
+ void UpdateAlsoOnDrives(std::map<GameId, std::string> drives);
+ // Games being published again in the background after a USB drive changed places.
+ void UpdateDriveUpdates(std::size_t done, std::size_t total, std::size_t failed = 0);
void UpdateImportCandidates(std::vector<LiveImportCandidate> candidates, bool scanning);
// Live mode: requests for the Local store (the Import sheet, the dev request file).
void RequestImport(ImportRequest request);
@@ -1053,6 +1061,8 @@ public:
void NotifyUninstallFinished(GameId id);
// Play prepared the game first and that ended without a playable title.
void NotifyPlayStopped(GameId id, const std::string& reason);
+ // Play updated the game's title to the installed kit's runtime and left it there: asks whether to start it.
+ void NotifyRuntimeUpdated(GameId id);
// The game's last run tried to start this program and couldn't: offers launcher mode.
// False until the game is known, so the caller tells it again.
bool NotifyLauncherHint(GameId id, const std::string& program);
@@ -1208,6 +1218,7 @@ private:
bool download_server_cancel_pending_ = false;
bool download_server_test_requested_ = false;
bool download_server_fixture_ = false;
+ std::size_t drive_updates_done_ = 0, drive_updates_total_ = 0; // what the corner notification last said
bool manage_fixture_ = false; // a Manage installed games scenario: Settings shows its rows in the fixture
void refresh_download_servers(const std::string& focus = {});
[[nodiscard]] std::string best_tested_download_server() const;
@@ -1345,7 +1356,17 @@ private:
std::filesystem::path log_directory_;
std::vector<CloudRequest> pending_cloud_requests_;
std::map<GameId, CloudStatus> settled_cloud_; // each game's last settled Cloud state, for notices
+ // The Runtimes tab's batch: the games still to send, in order, and the one at work. One at a time, so free space
+ // is checked before each. Not kept across runs: what didn't finish stays listed on the tab.
+ std::vector<std::pair<GameId, MaintenanceKind>> runtime_batch_;
+ std::optional<std::pair<GameId, MaintenanceKind>> runtime_batch_current_;
+ std::int64_t runtime_batch_sent_at_ = 0;
+ std::size_t runtime_batch_total_ = 0;
+ std::size_t runtime_batch_failed_ = 0;
+ PreparationQueue runtime_queue_; // the runtime's own queue, before the batch's waiting games are added to it
GameId ready_prompt_game_; // the game the "ready to play" dialog is about
+ std::vector<GameId> update_ready_prompts_; // games Play updated, whose "is ready" dialog hasn't opened yet
+ GameId update_ready_game_; // the game the open "is ready" dialog is about
GameId quit_sync_game_; // Play quits to Home once this game's saves are in step
std::string quit_wait_title_; // the dialog a quit to Home waits in while a game is prepared
std::string live_log_topic_;
@@ -1525,6 +1546,13 @@ private:
[[nodiscard]] std::string installed_blocker(GameId id) const;
// On Updates also a game whose drive is disconnected or read-only.
[[nodiscard]] std::string manage_blocker(ManageTab tab, GameId id) const;
+ // What the Runtimes tab would do for a game: update its runtime or repair it; nothing when it is current.
+ [[nodiscard]] std::optional<MaintenanceKind> runtime_work(GameId id) const;
+ void start_runtime_batch();
+ // Sends the batch's next game once the last one is done and nothing else is being prepared. Stops first if
+ // console storage is too low to go on.
+ void runtime_batch_step();
+ void stop_runtime_batch();
void refresh_manage_games();
void open_manage_games(ManageTab tab);
void close_manage_games();
@@ -1618,6 +1646,12 @@ private:
void apply_live_volume_usage();
void push_notice(Notice notice);
void show_ready_prompt();
+ void show_update_ready_prompt();
+ // The runtime kit prompt: once per kit, when games wait for its runtime, after What's new.
+ void show_runtime_prompt();
+ std::size_t runtime_prompt_games_ = 0; // what its button starts: kit updates and repairs
+ bool runtime_prompt_open_ = false;
+ std::string runtime_prompt_shown_kit_;
void show_alert(std::string title, std::string body, GameId settings_game = {});
void open_game_settings();
void show_alert_prompt();
diff --git a/src/homebrew/view.cpp b/src/homebrew/view.cpp
index 3056759..6f73699 100644
--- a/src/homebrew/view.cpp
+++ b/src/homebrew/view.cpp
@@ -2766,9 +2766,10 @@ class Render::Impl
void draw_manage_games(const ViewData &view, const State &state)
{
const auto shown = state.navigation.manage_tab;
+ const bool runtimes = shown == ManageTab::Runtimes;
const bool updates = shown == ManageTab::Updates;
const bool moves = shown == ManageTab::Move;
- const gfx::Color tone = updates ? kBlue : moves ? kAmber : kRed;
+ const gfx::Color tone = updates || runtimes ? kBlue : moves ? kAmber : kRed;
const auto focused_key = [&]() -> std::string {
if (view.focused_row < 0 || static_cast<std::size_t>(view.focused_row) >= view.rows.size()) return {};
return view.rows[static_cast<std::size_t>(view.focused_row)].key;
@@ -2884,9 +2885,9 @@ class Render::Impl
{
heading("GAME", name_x, gfx::Align::left);
heading("LAST PLAYED", played_x, gfx::Align::left);
- heading(updates ? "DOWNLOAD" : "SIZE", size_right, gfx::Align::right);
+ heading(updates ? "DOWNLOAD" : runtimes ? "WHAT CHANGES" : "SIZE", size_right, gfx::Align::right);
}
- const std::string list_key = "manage-" + std::string(updates ? "updates" : moves ? "move" : "uninstall");
+ const std::string list_key = "manage-" + std::string(updates ? "updates" : runtimes ? "runtimes" : moves ? "move" : "uninstall");
int focus_index = 0;
bool on_game = false;
for (std::size_t index = 0; index < games.size(); ++index)
@@ -2974,9 +2975,9 @@ class Render::Impl
focus_glow(scene_, button, amount);
scene_.rounded_rect(button, 8.0F, kBackground);
scene_.bordered_rect(button, 8.0F, kText.with_alpha(0.04F), 2.0F,
- primary->enabled ? tone.with_alpha(updates ? 0.65F : moves ? 0.60F : 0.55F) : kText.with_alpha(0.12F));
+ primary->enabled ? tone.with_alpha(updates || runtimes ? 0.65F : moves ? 0.60F : 0.55F) : kText.with_alpha(0.12F));
ui::text(scene_, fonts_.display, primary->title, button.cx(), button.cy() + 10.0F, 27.0F,
- !primary->enabled ? kMuted : updates || moves ? kText : kRed, gfx::Align::center);
+ !primary->enabled ? kMuted : updates || runtimes || moves ? kText : kRed, gfx::Align::center);
focus_ring(scene_, button, amount);
}
ui::text(scene_, fonts_.regular, fit(fonts_.regular, view.footer, 24.0F, summary_w), kSafeX, 935.0F, 24.0F, kSecondary);
@@ -3637,6 +3638,19 @@ class Render::Impl
if (!second.empty())
ui::text(overlay_, fonts_.regular, fit(fonts_.regular, second, 18.0F, 460.0F), 1342.0F, y + 62.0F,
18.0F, notice.detail.empty() ? kAccent : kSecondary);
+ if (notice.progress >= 0.0F)
+ {
+ ui::ProgressBar bar;
+ bar.style.theme = theme_;
+ bar.style.height = 6.0F;
+ bar.style.placement = ui::LabelPlacement::none;
+ bar.style.status = ui::Status::accent;
+ bar.style.finish_flash = false;
+ bar.set_bounds({1342.0F, y + 70.0F, 460.0F, 6.0F});
+ bar.set_value(std::clamp(notice.progress, 0.0F, 1.0F), true);
+ ui::Canvas canvas{overlay_, fonts_, renderer_.glass_texture(), clock_};
+ bar.draw(canvas);
+ }
y += 98.0F;
}
}
diff --git a/src/installs/game_move.cpp b/src/installs/game_move.cpp
index 3a443bb..f449ae0 100644
--- a/src/installs/game_move.cpp
+++ b/src/installs/game_move.cpp
@@ -3,6 +3,7 @@
#include "installs/install_record.h"
#include "steam/backend/depot_installer.h"
+#include "platform/usb_mount.h"
#include "stores/local/copy_plan.h"
#include "stores/local/source_walk.h"
@@ -410,7 +411,8 @@ InstallRunner::Result GameMover::Copy(const GameId& id, const std::string& from,
!steam::RemoveManagedInstall(to, &why) || !Missing(to))
return fail("A folder on the destination is in the way of the move.", to + " is in the way " + why);
}
- } else if (saved->source != from) {
+ } else if (platform::WithoutUsbMountNumber(saved->source) != platform::WithoutUsbMountNumber(from)) {
+ // (Drives may have changed places since the plan was saved: that's still a copy of this folder.)
// A partial copy of another folder goes with Cancel; one with an install record is an install.
if (Exists(to + "/" + kInstallRecordName))
return fail("A folder on the destination is in the way of the move.", to + " has a record, plan source " + saved->source);
@@ -420,7 +422,8 @@ InstallRunner::Result GameMover::Copy(const GameId& id, const std::string& from,
// play from the copy, and if it doesn't, the switch checks the copy against the game again with the title
// stopped. Walking the game and comparing it first would only do that twice. The copy is still checked
// (every planned file at its size): one that lost files since goes the whole way again.
- bool at_switch = switching && saved && saved->source == from;
+ bool at_switch = switching && saved &&
+ platform::WithoutUsbMountNumber(saved->source) == platform::WithoutUsbMountNumber(from);
if (at_switch) {
if (step) step(InstallStep::kVerifying);
for (std::size_t index = 0; index < saved->files.size(); ++index) {
diff --git a/src/installs/install_service.cpp b/src/installs/install_service.cpp
index 622d520..ff75c54 100644
--- a/src/installs/install_service.cpp
+++ b/src/installs/install_service.cpp
@@ -1,4 +1,5 @@
#include "installs/install_service.h"
+#include "platform/usb_mount.h"
#include "steam/install_volumes.h"
#include <fcntl.h>
@@ -232,6 +233,7 @@ struct RegistryEntry {
InstallOptions options; // a job's "lang=<code>", "branch=<name>" and "nodlc=<app>,<app>" fields
std::optional<std::uint64_t> estimated_bytes; // a job's "est=<bytes>": what it reserves on its drive
std::int64_t finished_at = 0; // "finished=<unix seconds>": a moved game's install time, older than its record
+ std::string also_on; // not stored: another USB drive holding the same folder (FollowUsbDrives)
};
// One line per game: "<key>" (legacy, primary volume) or "<key>\t<volume id>\t<install bytes>",
@@ -378,6 +380,93 @@ std::string InstallService::RootFor(GameId id) {
return LockedRootFor(id);
}
+namespace {
+// The console can mount USB drives the other way round, or on another port, so a line's USB volume is only the
+// mount the game had: its folder says where it is now. Returns whether a line changed. Only an available USB
+// volume counts, and a game on console storage or an M.2 drive never follows. Two drives holding the same folder
+// can't be told apart: the recorded one stays, and a game that isn't there stays where it is too.
+bool FollowUsbDrives(std::vector<RegistryEntry>& entries, const std::vector<InstallVolume>& volumes) {
+ std::vector<const InstallVolume*> usb;
+ for (const auto& volume : volumes)
+ if (platform::IsUsbVolumeId(volume.id) && volume.available) usb.push_back(&volume);
+ if (usb.empty()) return false;
+ const auto holders = [&usb](GameId id, const char* inside, const std::string& except = {}) {
+ std::vector<std::string> found;
+ for (const auto* volume : usb) {
+ if (volume->id == except) continue;
+ auto path = volume->games_root + "/" + ToKey(id);
+ if (inside) path += std::string("/") + inside;
+ if (Exists(path)) found.push_back(volume->id);
+ }
+ return found;
+ };
+ const auto contains = [](const std::vector<std::string>& list, const std::string& id) {
+ return std::find(list.begin(), list.end(), id) != list.end();
+ };
+ bool changed = false;
+ for (auto& entry : entries) {
+ if (!entry.move_to.empty()) {
+ const auto to = entry.move_to;
+ const auto from = entry.move_from.empty() ? entry.volume_id : entry.move_from;
+ if (!platform::IsUsbVolumeId(to) && !platform::IsUsbVolumeId(from)) continue;
+ auto new_to = to, new_from = from;
+ // The copy holds the journal until the old folder is gone: that drive is the destination.
+ const auto journals = platform::IsUsbVolumeId(to) ? holders(entry.id, kMoveJournal) : std::vector<std::string>{};
+ const bool journal_known = journals.size() == 1;
+ if (journal_known) new_to = journals.front();
+ // No journal, and the game was already on its destination: the move ended, only its line is left.
+ if (journals.empty() && entry.volume_id == to && platform::IsUsbVolumeId(to) && !contains(holders(entry.id, kRecord), to)) {
+ const auto records = holders(entry.id, kRecord);
+ if (records.size() == 1) {
+ entry.volume_id = records.front();
+ entry.move_to.clear();
+ entry.move_from.clear();
+ changed = true;
+ }
+ continue;
+ }
+ // Past the switch with no journal, the old folder is simply gone: nothing to find.
+ if (platform::IsUsbVolumeId(from) && (journal_known || entry.volume_id != to)) {
+ const auto left = holders(entry.id, nullptr, journal_known ? new_to : std::string());
+ if (!contains(left, from) || new_to == from) {
+ if (left.size() == 1) {
+ new_from = left.front();
+ // Nothing copied yet, and the game is now on the drive it was going to.
+ if (!journal_known && new_from == to) new_to = from;
+ } else if (new_to == from) {
+ new_from = to; // the old folder's drive isn't connected
+ }
+ }
+ }
+ if (new_to == to && new_from == from) continue;
+ entry.volume_id = entry.volume_id == to ? new_to : new_from;
+ entry.move_to = new_to;
+ entry.move_from = new_from;
+ changed = true;
+ continue;
+ }
+ if (!platform::IsUsbVolumeId(entry.volume_id)) continue;
+ const auto present = [&](const std::string& except) {
+ auto found = holders(entry.id, kRecord, except);
+ for (auto& other : holders(entry.id, kJournal, except))
+ if (!contains(found, other)) found.push_back(std::move(other));
+ if (entry.removing)
+ for (auto& other : holders(entry.id, nullptr, except))
+ if (!contains(found, other)) found.push_back(std::move(other));
+ return found;
+ };
+ const auto everywhere = present({});
+ if (contains(everywhere, entry.volume_id)) {
+ if (const auto others = present(entry.volume_id); !others.empty()) entry.also_on = others.front();
+ } else if (everywhere.size() == 1) {
+ entry.volume_id = everywhere.front();
+ changed = true;
+ }
+ }
+ return changed;
+}
+} // namespace
+
// The primary volume keeps a registry of app IDs Playden manages and the volume of each;
// directory listing is avoided because the console's readdir did not return entries reliably.
void InstallService::Scan() {
@@ -403,6 +492,7 @@ void InstallService::Scan() {
}
std::fclose(registry);
}
+ const bool followed = FollowUsbDrives(entries, volumes_);
if (FILE* file = std::fopen((primary + "/" + kDefaultVolume).c_str(), "r")) {
char line[64] = {};
if (std::fgets(line, sizeof(line), file)) {
@@ -479,6 +569,7 @@ void InstallService::Scan() {
entry.finished_at > 0 ? entry.finished_at : RecordTime(root + "/" + kRecord),
ReadInstallRecord(root + "/" + kRecord)});
installed_.back().finished_kept = entry.finished_at > 0;
+ installed_.back().also_on = entry.also_on;
if (!entry.move_to.empty()) {
restore_move(entry);
} else if ((update || entry.update) && jobs_.size() < kMaxJobs) {
@@ -547,6 +638,8 @@ void InstallService::Scan() {
}
std::fclose(file);
}
+ // Saved now: anything that acts on these folders reads the volumes from here on.
+ if (followed) SaveRegistry(true);
++revision_;
}
diff --git a/src/installs/install_service.h b/src/installs/install_service.h
index 29aa00c..408cbc1 100644
--- a/src/installs/install_service.h
+++ b/src/installs/install_service.h
@@ -127,6 +127,8 @@ struct InstalledGame {
std::uint64_t update_bytes = 0;
// `finished_at` is older than the record: a move copied the record, and the registry keeps the time.
bool finished_kept = false;
+ // Another USB drive that holds the same folder too (a copy, or a move that stopped); empty when none.
+ std::string also_on;
};
// A recent finished download that Downloads lists after the queue until the player dismisses it.
diff --git a/src/installs/installed_location.h b/src/installs/installed_location.h
index b3d1004..5d718e1 100644
--- a/src/installs/installed_location.h
+++ b/src/installs/installed_location.h
@@ -22,13 +22,16 @@ struct InstalledLocation {
Ownership ownership = Ownership::kManaged;
// Why an available drive's folder still can't be played from (a name the PS5 can't open); empty otherwise.
std::string reason;
+ // Another USB drive that holds the same folder too; empty when none.
+ std::string also_on;
bool managed() const { return ownership == Ownership::kManaged; }
};
inline bool operator==(const InstalledLocation& left, const InstalledLocation& right) {
return left.game == right.game && left.root == right.root && left.volume_id == right.volume_id &&
- left.available == right.available && left.ownership == right.ownership && left.reason == right.reason;
+ left.available == right.available && left.ownership == right.ownership && left.reason == right.reason &&
+ left.also_on == right.also_on;
}
inline bool operator!=(const InstalledLocation& left, const InstalledLocation& right) { return !(left == right); }
@@ -38,7 +41,7 @@ inline std::vector<InstalledLocation> ProjectInstalledLocations(const std::vecto
const std::vector<InstalledLocation>& external) {
std::vector<InstalledLocation> locations;
for (const auto& game : managed)
- locations.push_back({game.id, game.root, game.volume_id, game.available, InstalledLocation::Ownership::kManaged, {}});
+ locations.push_back({game.id, game.root, game.volume_id, game.available, InstalledLocation::Ownership::kManaged, {}, game.also_on});
for (const auto& location : external) {
if (!location.game.valid() || location.root.empty()) continue;
if (std::any_of(locations.begin(), locations.end(), [&](const InstalledLocation& known) { return known.game == location.game; }))
diff --git a/src/platform/usb_mount.h b/src/platform/usb_mount.h
new file mode 100644
index 0000000..ba2a783
--- /dev/null
+++ b/src/platform/usb_mount.h
@@ -0,0 +1,48 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+#pragma once
+// The console can mount USB drives the other way round, or on another port, so /mnt/usb<N> names a place and not a
+// drive. These say when two paths are one folder on whichever mount its drive is on.
+#include <string>
+#include <string_view>
+
+namespace playden::platform {
+
+inline constexpr int kUsbMounts = 8; // /mnt/usb0 to /mnt/usb7
+
+// An install volume ID of a USB mount: "usb0" to "usb7".
+inline bool IsUsbVolumeId(std::string_view id) {
+ return id.size() == 4 && id.substr(0, 3) == "usb" && id[3] >= '0' && id[3] < '0' + kUsbMounts;
+}
+
+// path with its USB mount's number left out (/mnt/usb1/playden/games/730 is /mnt/usb/playden/games/730), or as it
+// is when it isn't on one. Two paths with the same answer are one folder.
+inline std::string WithoutUsbMountNumber(const std::string& path) {
+ constexpr std::string_view kMount = "/mnt/usb";
+ if (path.size() <= kMount.size() || path.compare(0, kMount.size(), kMount) != 0 || path[kMount.size()] < '0' ||
+ path[kMount.size()] >= '0' + kUsbMounts || (path.size() > kMount.size() + 1 && path[kMount.size() + 1] != '/'))
+ return path;
+ return std::string(kMount) + path.substr(kMount.size() + 1);
+}
+
+// The same folder on USB mount `number`; path has to be on a USB mount.
+inline std::string OnUsbMount(const std::string& path, int number) {
+ constexpr std::string_view kMount = "/mnt/usb";
+ return std::string(kMount) + std::to_string(number) + WithoutUsbMountNumber(path).substr(kMount.size());
+}
+
+// A path in the form a title searches the USB mounts for: /mnt/usb/<folder>, which is never a mount itself.
+inline bool IsUsbSearchPath(const std::string& path) { return path.rfind("/mnt/usb/", 0) == 0; }
+
+// The USB mount path is on (/mnt/usb1), or nothing when it isn't on one.
+inline std::string UsbMountOf(const std::string& path) {
+ return WithoutUsbMountNumber(path) == path ? std::string() : path.substr(0, std::string_view("/mnt/usb0").size());
+}
+
+// Where a published path really is for a game at install_path: its mount in place of the search form.
+inline std::string OnGameMount(const std::string& published, const std::string& install_path) {
+ const auto mount = UsbMountOf(install_path);
+ if (!IsUsbSearchPath(published) || mount.empty()) return published;
+ return mount + published.substr(std::string_view("/mnt/usb").size());
+}
+
+} // namespace playden::platform
diff --git a/src/runtime/game_probe.cpp b/src/runtime/game_probe.cpp
index 715e9b9..4e1dd04 100644
--- a/src/runtime/game_probe.cpp
+++ b/src/runtime/game_probe.cpp
@@ -671,7 +671,7 @@ GameDefaults DefaultsFor(const GameProbe& probe, const RuntimeAbilities& runtime
if (probe.shared_section && !runtime.shared_sections)
soft = "This game's program needs a shared memory section the PS5 can't map yet.";
else if (probe.dotnet && !runtime.wine_mono)
- soft = "This game needs .NET, which Playden's runtime doesn't include yet.";
+ soft = "This game needs .NET, which Playden's runtime kit doesn't include yet.";
if (probe.steam_stub && !probe.steam_stub_supported) {
out.refusal = "This game's program has Steam DRM in a form Playden can't unpack yet.";
} else if (probe.engine == "nwjs") {
diff --git a/src/runtime/game_settings.cpp b/src/runtime/game_settings.cpp
index 07d5644..083df71 100644
--- a/src/runtime/game_settings.cpp
+++ b/src/runtime/game_settings.cpp
@@ -525,7 +525,7 @@ std::string Unavailable(const SettingDefinition& definition, const std::string&
if (id == "frame_limit" && !dxvk && graphics == "opengl" && kit.display_120hz_needs_update)
return kAppliesAfterKitUpdate;
if (!dxvk) return "Only available with DXVK.";
- if (!kit.dxvk_config) return "Needs a runtime that reads dxvk.conf.";
+ if (!kit.dxvk_config) return "Needs a runtime kit that reads dxvk.conf.";
// Checked on the console (results/20261005-dxvk-conf-probe): the cap works, DXVK applies
// latency and VRAM, VSync off does not change the display's pacing.
if (id == "vsync" && !kit.dxvk_present) return "The PS5 display always waits for the TV; VSync cannot be turned off yet.";
@@ -535,16 +535,16 @@ std::string Unavailable(const SettingDefinition& definition, const std::string&
// A Zink kit's runtime (upstream prospero-win) reads MESA_, DXVK_, RADV_ and the like as [debug] env.
// Pixel shaders is an environment variable for the driver, so it goes where Environment variables go.
if ((id == "environment" || id == "pixel_shader_waves") && !kit.environment && !kit.opengl_zink)
- return "Needs a prospero-win update that reads [environment].";
- if (id == "wheel_stick" && !kit.input_wheel) return "Needs a prospero-win update that turns the mouse wheel.";
- if (id == "volume" && !kit.audio_volume) return "Needs a prospero-win update with per-game volume.";
+ return "Needs a newer runtime kit that reads [environment].";
+ if (id == "wheel_stick" && !kit.input_wheel) return "Needs a newer runtime kit that turns the mouse wheel.";
+ if (id == "volume" && !kit.audio_volume) return "Needs a newer runtime kit with per-game volume.";
// Rumble alone (input-rumble) or with the rest of controller tuning.
if (id == "rumble" && !kit.input_tuning && !kit.input_rumble) {
if (kit.input_rumble_needs_update) return kAppliesAfterKitUpdate;
return "Needs a runtime kit with rumble control.";
}
if (id == "stick_deadzone" || id == "rumble" || id == "trigger_deadzone") {
- if (!kit.input_tuning && id != "rumble") return "Needs a prospero-win update with controller tuning.";
+ if (!kit.input_tuning && id != "rumble") return "Needs a newer runtime kit with controller tuning.";
const auto controller = values.find("controller");
const std::string mode = controller == values.end() ? std::string() : controller->second.value;
// The title scales the game's rumble the same way for both controllers; the dead zones are XInput's.
@@ -552,14 +552,14 @@ std::string Unavailable(const SettingDefinition& definition, const std::string&
if (id != "rumble" && mode != "xinput") return "Only with the Xbox controller.";
}
// Rows whose runtime or Playden side is not built yet: listed so players see what is coming.
- if (id == "invert_stick") return "Needs a prospero-win update that inverts sticks.";
+ if (id == "invert_stick") return "Needs a newer runtime kit that inverts sticks.";
// Wine sets the user locale from the Unix locale (LANG, LC_ALL) at start and only mirrors it into
// Control Panel\International, so a registry value alone would be overwritten.
- if (id == "locale") return "Needs a prospero-win update that sets the game's language (LANG).";
+ if (id == "locale") return "Needs a newer runtime kit that sets the game's language (LANG).";
// The title publication carries only the two registry values it owns (Windows version, text scale).
- if (id == "registry_dll_overrides") return "Needs a prospero-win update that lets Playden write more registry values.";
+ if (id == "registry_dll_overrides") return "Needs a newer runtime kit that lets Playden write more registry values.";
// Wine reads WINE_CPU_TOPOLOGY from the [environment] section; [debug] env does not take WINE_ names.
- if (id == "cpu_topology" && !kit.environment) return "Needs a prospero-win update that reads [environment].";
+ if (id == "cpu_topology" && !kit.environment) return "Needs a newer runtime kit that reads [environment].";
if (id == "start_through_launcher" || id == "launcher_controller_preset") {
if (kit.launcher_mode_needs_update) return kAppliesAfterKitUpdate;
if (!kit.launcher_mode) return "Needs a runtime kit with launcher mode.";
@@ -580,7 +580,7 @@ std::string Unavailable(const SettingDefinition& definition, const std::string&
return kit.display_fps_counter ? "Direct3D 12 games show only the frame rate." : "Not shown for Direct3D 12 games.";
if (id == "overlay_detail") {
if (!dxvk) return "Only available with DXVK.";
- if (!kit.dxvk_config) return "Needs a runtime that reads dxvk.conf.";
+ if (!kit.dxvk_config) return "Needs a runtime kit that reads dxvk.conf.";
const auto overlay = values.find("performance_overlay");
if (overlay == values.end() || overlay->second.value != "on") return "Turn the performance overlay on first.";
}
@@ -1100,7 +1100,7 @@ bool RenderProsperoProfile(const GameRecipe& recipe, const EffectiveSettings& se
return false;
};
if (!settings.launch) return fail("no launch option");
- const auto root = ProsperoWindowsPath(target.install_root);
+ const auto root = ProsperoWindowsPath(target.published_root.empty() ? target.install_root : target.published_root);
if (!root) return fail("install folder cannot be mapped for Wine");
const auto executable = steam::RelativeGamePath(settings.launch->executable);
if (!executable) return fail("launch executable is not a game path");
@@ -3338,6 +3338,7 @@ KitCapabilities KitCapabilitiesFromManifest(const std::vector<std::string>& capa
kit.wine_mono = has(kKitWineMono);
kit.vkd3d_proton = has(kKitVkd3dProton);
kit.driver_threads = has(kKitDriverThreads);
+ kit.game_root_usb_search = has(kKitGameRootUsbSearch);
kit.display_120hz = has(kKitDisplay120Hz);
kit.profile_version_2 = has(kKitProfileVersion2);
kit.input_rumble = has(kKitInputRumble);
@@ -3350,6 +3351,8 @@ KitCapabilities KitCapabilitiesFromManifest(const std::vector<std::string>& capa
}
KitCapabilities KitForTitleRuntime(KitCapabilities kit, bool title_runtime_current) {
+ // An older title refuses the search form outright, and nothing the player chose waits on it.
+ if (!title_runtime_current) kit.game_root_usb_search = false;
if (!title_runtime_current && kit.display_120hz) {
kit.display_120hz = false;
kit.display_120hz_needs_update = true;
diff --git a/src/runtime/game_settings.h b/src/runtime/game_settings.h
index 855aae5..06e7143 100644
--- a/src/runtime/game_settings.h
+++ b/src/runtime/game_settings.h
@@ -56,6 +56,8 @@ struct KitCapabilities {
bool audio_volume = false; // prospero-win [audio] volume (U4, not released)
bool shared_sections = false; // Wine maps unaligned shared PE sections as private copies (patch 0602)
bool title_any_id = false; // one title shell for every game; no fixed set of titles
+ // The title finds a USB game's drive when it starts, so it can be published naming no mount.
+ bool game_root_usb_search = false;
bool game_root_unowned = false; // games start from drives that record no file owners (exFAT)
bool bottle_profile_shared = false; // the bottle's 4 folders to its user profile may be 0711
bool opengl_zink = false; // OpenGL games draw through Mesa's Zink, not the PS5 OpenGL SDK
@@ -316,6 +318,8 @@ bool ValidateSettingValue(const GameRecipe& recipe, std::string_view id, std::st
struct ProfileTarget {
std::string id; // prospero profile id, also the file stem
std::string install_root; // console path of the game files
+ // What the profile names instead, when not that: a USB game's search form (/mnt/usb/<folder>).
+ std::string published_root;
};
// The full prospero profile: [application], [display], [input] and [debug].
@@ -579,6 +583,7 @@ inline constexpr const char* kKitVkd3dProton = "vkd3d-proton";
// Runtime ability: threads that start in ntoskrnl.exe or a driver skip DLL_THREAD_ATTACH and TLS callbacks, as Windows'
// system threads do, so a game's TLS callback can't stop its start in Xbox controller mode (NW.js).
inline constexpr const char* kKitDriverThreads = "wine-driver-threads";
+inline constexpr const char* kKitGameRootUsbSearch = "game-root-usb-search";
// The runtime honors [display] refresh = 60|120 on every graphics path (Wine reports the rate it asked for) and
// [display] frame_rate = 0|120|60|40|30, which the display paces. Runtimes without it refuse a profile with frame_rate.
inline constexpr const char* kKitDisplay120Hz = "display-120hz";
diff --git a/src/runtime/install_service.h b/src/runtime/install_service.h
index 5203087..f693a12 100644
--- a/src/runtime/install_service.h
+++ b/src/runtime/install_service.h
@@ -9,6 +9,14 @@
namespace playden::runtime {
+inline constexpr const char* kAdmissionDriveMissing = "drive-missing";
+inline constexpr const char* kAdmissionDriveAmbiguous = "drive-ambiguous";
+// An admission that a Repair could change: not "ok", and not only about the game's USB drive.
+inline bool AdmissionNeedsRepair(const std::string& admission) {
+ return admission != "ok" && admission != kAdmissionDriveMissing && admission != kAdmissionDriveAmbiguous;
+}
+
+
struct RecordUpdateResult {
bool ok = false;
std::string code;
@@ -74,6 +82,7 @@ public:
virtual PackageActionResult PublishProfile(const RuntimeInstall &record) = 0;
// Runs the wrapper's publication admission over the installed title and
// returns "ok" or its refusal text (diagnostics only).
+ // Besides "ok" and a reason, AdmissionDiagnostic can answer that the title is fine and only its USB drive is the matter.
virtual std::string AdmissionDiagnostic(const RuntimeInstall &) { return "unsupported"; }
// A cheap form for start-up: only what a game run changes and RepairBottle fixes
// (the bottle registry file's mode). "ok" or the refusal text.
diff --git a/src/runtime/kit_trust.cpp b/src/runtime/kit_trust.cpp
index 2857bc7..b95263f 100644
--- a/src/runtime/kit_trust.cpp
+++ b/src/runtime/kit_trust.cpp
@@ -16,7 +16,7 @@ KitAdmissionConfig DevelopmentKitAdmission() {
kKitInputWheel, kKitEnvironment, kKitWineMono, kKitVkd3dProton,
kKitDisplay120Hz, kKitProfileVersion2, kKitInputRumble,
kKitDisplayFramegen, kKitDisplayFpsCounter, kKitLauncherMode,
- kKitInputPlaystation, kKitDriverThreads};
+ kKitInputPlaystation, kKitDriverThreads, kKitGameRootUsbSearch};
std::sort(config.known_capabilities.begin(), config.known_capabilities.end());
return config;
}
diff --git a/src/runtime/package_installer.cpp b/src/runtime/package_installer.cpp
index 78d4681..256b25e 100644
--- a/src/runtime/package_installer.cpp
+++ b/src/runtime/package_installer.cpp
@@ -2,6 +2,7 @@
#include "runtime/kit_trust.h"
#include "runtime/private_directories.h"
#include "platform/managed_directory.h"
+#include "platform/usb_mount.h"
#include "pw_title_publication_native.h"
#include "pw_title_publication.h"
@@ -394,9 +395,12 @@ bool DescriptorMatches(const RuntimeInstall& record, std::string_view bytes) {
if (parsed->object().size() != 11 ||
record.install_path != "/data/homebrew/" + record.title_id + "/games/" + std::to_string(record.runtime_number))
return false;
- } else if (version == 2) {
+ } else if (version == 2 || version == 3) {
const auto* game_root = Required(*parsed, "game_root", Type::kString);
- if (parsed->object().size() != 12 || !game_root || game_root->text() != record.install_path) return false;
+ if (parsed->object().size() != 12 || !game_root ||
+ game_root->text() != (version == 3 ? platform::WithoutUsbMountNumber(record.install_path) : record.install_path) ||
+ (version == 3 && !platform::IsUsbSearchPath(game_root->text())))
+ return false;
} else {
return false;
}
@@ -860,6 +864,9 @@ std::string FilesystemPackageInstaller::AdmissionDiagnostic(const RuntimeInstall
&descriptor, error, sizeof(error)) != PW_OK) return std::string("descriptor: ") + error;
PwTitlePublicationLease lease{}; pw_title_publication_lease_init(&lease);
const int status = pw_title_publication_open(&descriptor, &platform, &lease, error, sizeof(error));
+ // Nothing is wrong with the title: Repair can't help, and the game's page says what is.
+ if (status == PW_TITLE_PUBLICATION_ADMISSION_DRIVE_MISSING) return kAdmissionDriveMissing;
+ if (status == PW_TITLE_PUBLICATION_ADMISSION_DRIVE_AMBIGUOUS) return kAdmissionDriveAmbiguous;
if (status != PW_OK) return "admission status=" + std::to_string(status) + ": " + error;
pw_title_publication_close(&lease);
return "ok";
@@ -983,6 +990,9 @@ bool FilesystemPackageInstaller::PublicationMatches(
PwTitlePublicationDescriptor descriptor{}; char error[256]{};
if (pw_title_publication_read_descriptor(canonical.c_str(), record.title_id.c_str(), &platform,
&descriptor, error, sizeof(error)) != PW_OK) return false;
+ // The record says where the game is; a copy on another drive doesn't change what was published.
+ const auto mount = platform::UsbMountOf(record.install_path);
+ platform.known_game_mount = mount.empty() ? nullptr : mount.c_str();
const auto& launch = descriptor.launch;
if (launch.install_id != record.install_id || launch.title_id != record.title_id || launch.app_id != record.runtime_number ||
launch.data_root != record.data_root || launch.default_profile_id != record.default_profile_id ||
diff --git a/src/runtime/settings_publication.cpp b/src/runtime/settings_publication.cpp
index 45f5150..a7dd927 100644
--- a/src/runtime/settings_publication.cpp
+++ b/src/runtime/settings_publication.cpp
@@ -1,4 +1,6 @@
#include "runtime/settings_publication.h"
+
+#include "platform/usb_mount.h"
#include "runtime/publication_contract.h"
#include "runtime/artifact_hash.h"
extern "C" {
@@ -6,6 +8,7 @@ extern "C" {
#include "pw_wine_launch.h"
}
#include "platform/managed_file_lock.h"
+#include "platform/usb_mount.h"
#include <cerrno>
#include <atomic>
#include <charconv>
@@ -145,7 +148,7 @@ std::optional<std::string> LiveGameRoot(const std::string& title_id, const std::
bool NamesMovedRoot(const GameRootMove* moved, const std::string& title_id, const std::filesystem::path& prefix) {
if (!moved) return false;
const auto root = LiveGameRoot(title_id, prefix);
- return root && *root == moved->from;
+ return root && (*root == moved->from || *root == platform::WithoutUsbMountNumber(moved->from));
}
// An owned publication (schema 2) that an unowned one replaces. The player may have opened the
// game folder since (mods over FTP), which the owned rule refuses, so it is checked as a folder
@@ -190,6 +193,9 @@ std::optional<bool> PublishedGameRootUnowned(const RuntimeInstall& r, const std:
return std::nullopt;
return m.game_root_unowned != 0;
}
+std::optional<std::string> PublishedGameRoot(const RuntimeInstall& r, const std::filesystem::path& prefix) {
+ return LiveGameRoot(r.title_id, prefix);
+}
std::optional<std::string> PublishedProfileDigest(const RuntimeInstall& r, const std::filesystem::path& prefix) {
if (!prefix.empty() && (!prefix.is_absolute() || prefix != prefix.lexically_normal())) return std::nullopt;
auto profiles = ManagedDirectory::Open(Map(prefix, r.data_root + "/library/profiles"), DirectoryPolicy::kPrivate);
@@ -223,13 +229,18 @@ PackageActionResult VerifyMovedPublication(const RuntimeInstall& r, const GameRo
const auto host = prefix.string(); PwTitlePublicationPlatform platform{};
platform.host_root = host.empty() ? nullptr : host.c_str(); platform.owner_uid = geteuid();
PwTitlePublicationDescriptor descriptor{}; char error[256]{};
+ // Published naming no mount, the old folder is its search form too.
+ const auto published_from = [&] {
+ const auto root = LiveGameRoot(r.title_id, prefix);
+ return root && platform::IsUsbSearchPath(*root) ? platform::WithoutUsbMountNumber(move.from) : move.from;
+ }();
const auto descriptor_digest = [&] {
return HashArtifactBytes(std::string_view(reinterpret_cast<const char*>(descriptor.bytes), descriptor.length));
};
if (pw_title_publication_read_descriptor(("/data/homebrew/" + r.title_id + "/game-launch.json").c_str(), r.title_id.c_str(),
&platform, &descriptor, error, sizeof(error)) != PW_OK ||
descriptor.launch.app_id != r.runtime_number || descriptor.launch.install_id != r.install_id ||
- descriptor.launch.data_root != r.data_root || descriptor.launch.game_root != move.from ||
+ descriptor.launch.data_root != r.data_root || descriptor.launch.game_root != published_from ||
descriptor_digest() != std::optional<std::string>(m.descriptor_sha256))
return refuse("The moved game's descriptor does not match its publication.");
// Profile and catalog live in the private data root, which did not move.
@@ -248,9 +259,9 @@ PackageActionResult VerifyMovedPublication(const RuntimeInstall& r, const GameRo
if (pw_wine_launch_host_dir(bottle.c_str(), profile.app.working_directory, working, sizeof(working)) ||
pw_wine_launch_host_dir(bottle.c_str(), profile.app.executable, executable, sizeof(executable)) ||
std::string(m.dxvk_path) != std::string(working) + "/dxvk.conf" ||
- !RebaseInstallPath(executable, move.from, move.to))
+ !RebaseInstallPath(executable, published_from, move.to))
return refuse("The moved game's profile names a program outside its game folder.");
- const auto moved_working = RebaseInstallPath(working, move.from, move.to);
+ const auto moved_working = RebaseInstallPath(working, published_from, move.to);
struct stat info{};
if (!moved_working || lstat(Map(prefix, *moved_working).c_str(), &info) != 0 ||
!OwnedGameDirectory(info, unowned || m.game_root_unowned != 0))
@@ -300,9 +311,17 @@ PackageActionResult PublishSettingsOperation(const SettingsPublicationOperation&
Map(deps.host_namespace_prefix, "/data/homebrew/" + previous.install.title_id + "/game-launch.json"),
Map(deps.host_namespace_prefix, profile_root + ".playden-publication")};
// A journal left by a game folder that moved names the old folder, which no longer exists.
- if (deps.moved_root && previous.install.install_path == deps.moved_root->from)
+ // Compared without the USB mount's number: published naming no mount, the drive may have changed places first.
+ if (deps.moved_root && platform::WithoutUsbMountNumber(previous.install.install_path) ==
+ platform::WithoutUsbMountNumber(deps.moved_root->from))
result = VerifyMovedPublication(o.install, *deps.moved_root, previous.committed_receipt_bytes, previous.metadata_bytes,
deps.host_namespace_prefix, PublishesUnowned(o));
+ // Published naming no mount: its drive changed places since, with nothing published, and the journal names the old one.
+ else if (previous.install.install_path != o.install.install_path &&
+ platform::WithoutUsbMountNumber(previous.install.install_path) == platform::WithoutUsbMountNumber(o.install.install_path))
+ result = VerifyMovedPublication(o.install, GameRootMove{previous.install.install_path, o.install.install_path},
+ previous.committed_receipt_bytes, previous.metadata_bytes, deps.host_namespace_prefix,
+ PublishesUnowned(o));
else if (OwnedReplacedByUnowned(previous.metadata_bytes, PublishesUnowned(o)))
result = VerifyMovedPublication(o.install, InPlace(o.install), previous.committed_receipt_bytes,
previous.metadata_bytes, deps.host_namespace_prefix, true);
@@ -390,6 +409,8 @@ PackageActionResult VerifySettingsPublicationFiles(const SettingsPublicationOper
if (!digest) return Failure("publication-hash", "Metadata hashing is unavailable.");
const auto host = prefix.string(); PwTitlePublicationPlatform platform{};
platform.host_root = host.empty() ? nullptr : host.c_str(); platform.owner_uid = geteuid();
+ const auto mount = platform::UsbMountOf(o.install.install_path);
+ platform.known_game_mount = mount.empty() ? nullptr : mount.c_str();
const auto& receipt = committed ? o.committed_receipt_bytes : o.pending_receipt_bytes;
PwTitlePublicationContents contents{};
if (pw_title_publication_verify_locked(&descriptor, &platform, borrowed,
@@ -474,7 +495,7 @@ PackageActionResult ApplyPendingPublicationDxvk(const SettingsPublicationOperati
if (pw_title_publication_metadata_parse(reinterpret_cast<const uint8_t*>(o.metadata_bytes.data()),
o.metadata_bytes.size(), &metadata) != PW_OK)
return Failure("publication-invalid", "Frozen DXVK metadata is invalid.");
- const auto target = Map(prefix, metadata.dxvk_path);
+ const auto target = Map(prefix, platform::OnGameMount(metadata.dxvk_path, o.install.install_path));
const bool unowned = metadata.game_root_unowned != 0;
auto game = ManagedDirectory::Open(target.parent_path(), GameDirectoryPolicy(unowned));
struct stat game_info{};
@@ -549,7 +570,7 @@ PackageActionResult ApplyPendingPublicationFiles(const SettingsPublicationOperat
pw_title_publication_metadata_parse(reinterpret_cast<const uint8_t*>(o.previous_metadata_bytes.data()),
o.previous_metadata_bytes.size(), &previous) != PW_OK))
return Failure("publication-invalid", "Frozen publication metadata is invalid.");
- if (!checkpoint(Map(prefix, current.dxvk_path))) return Failure("publication-interrupted", "DXVK effect requires fresh recovery.");
+ if (!checkpoint(Map(prefix, platform::OnGameMount(current.dxvk_path, o.install.install_path)))) return Failure("publication-interrupted", "DXVK effect requires fresh recovery.");
auto library = ManagedDirectory::Open(Map(prefix, o.install.data_root + "/library"), DirectoryPolicy::kPrivateTraversable);
if (!library) return Failure("publication-directory", "Owned private library is unavailable.");
auto profiles = library->OpenChild("profiles", DirectoryPolicy::kPrivate, true);
@@ -644,6 +665,8 @@ PackageActionResult PreflightSettingsPublication(const SettingsPublicationOperat
} else if (!initial) {
const auto host = prefix.string(); PwTitlePublicationPlatform platform{};
platform.host_root = host.empty() ? nullptr : host.c_str(); platform.owner_uid = geteuid();
+ const auto mount = platform::UsbMountOf(o.install.install_path);
+ platform.known_game_mount = mount.empty() ? nullptr : mount.c_str();
PwTitlePublicationDescriptor descriptor{}; PwTitlePublicationContents contents{}; char error[256]{};
auto hash = HashArtifactBytes(o.previous_metadata_bytes);
if (!hash || pw_title_publication_metadata_parse(reinterpret_cast<const uint8_t*>(o.previous_metadata_bytes.data()),
@@ -656,7 +679,7 @@ PackageActionResult PreflightSettingsPublication(const SettingsPublicationOperat
hash->c_str(), &contents, error, sizeof(error)) != PW_OK)
return {PackageActionState::kFailed, "publication-preflight-previous", error[0] ? error : "Previous complete publication is invalid."};
}
- const auto dxvk = Map(prefix, desired.dxvk_path);
+ const auto dxvk = Map(prefix, platform::OnGameMount(desired.dxvk_path, o.install.install_path));
const bool unowned = desired.game_root_unowned != 0;
auto game = ManagedDirectory::Open(dxvk.parent_path(), GameDirectoryPolicy(unowned));
struct stat game_info{};
@@ -700,8 +723,14 @@ Result<SettingsPublicationOperation> CaptureSettingsPublicationOperation(const R
SettingsPublicationOperation o; o.install = r; o.plan = plan; o.kit_id = kit_id;
o.transaction_id = transaction; o.registry_unix_time = unix_time;
o.catalog_bytes = plan.profile_id + ".profile\n";
- // Schema 2 binds the recorded download root, which is independent of the native title.
- o.descriptor_bytes = "{\"schema_version\":2,\"app_id\":" + std::to_string(r.runtime_number) +
+ // Schema 2 binds the recorded download root, which is independent of the native title. Schema 3 binds a USB
+ // game's folder on no mount in particular: the plan's profile says which this is.
+ PwGameProfile planned{}; char planned_working[1024]{};
+ const auto planned_bottle = r.data_root + "/library/prefixes/game";
+ const bool searches_usb = pw_game_profile_parse(reinterpret_cast<const uint8_t*>(plan.profile_bytes.data()), plan.profile_bytes.size(), &planned) == PW_OK &&
+ !pw_wine_launch_host_dir(planned_bottle.c_str(), planned.app.working_directory, planned_working, sizeof(planned_working)) &&
+ platform::IsUsbSearchPath(planned_working);
+ o.descriptor_bytes = std::string("{\"schema_version\":") + (searches_usb ? "3" : "2") + ",\"app_id\":" + std::to_string(r.runtime_number) +
",\"settings_revision\":" + std::to_string(plan.settings_revision);
auto field = [&](const char* name, const std::string& value) {
o.descriptor_bytes += ",\""; o.descriptor_bytes += name; o.descriptor_bytes += "\":\"";
@@ -715,7 +744,7 @@ Result<SettingsPublicationOperation> CaptureSettingsPublicationOperation(const R
if (!field("title_id", r.title_id) || !field("install_id", r.install_id) || !field("data_root", r.data_root) ||
!field("default_profile_id", plan.profile_id) || !field("runtime_bundle_id", r.runtime_bundle_id) ||
!field("recipe_id", plan.recipe_id) || !field("recipe_version", plan.recipe_version) || !field("exit_policy", r.exit_policy) ||
- !field("game_root", r.install_path))
+ !field("game_root", searches_usb ? platform::WithoutUsbMountNumber(r.install_path) : r.install_path))
return fail("Descriptor identities cannot be represented safely.");
o.descriptor_bytes += "}\n";
PwGameProfile profile{}; char working[1024]{};
@@ -733,7 +762,7 @@ Result<SettingsPublicationOperation> CaptureSettingsPublicationOperation(const R
// Schema 3 (game_root_unowned) lets the kit's launch admission accept a game folder of any
// owner and mode: every folder when the kit can, else one on a drive that records no owner
// or permissions (exFAT).
- bool unowned = unowned_game_roots;
+ bool unowned = unowned_game_roots || searches_usb;
if (!unowned) {
const auto records_ownership = platform::RecordsOwnership(Map(prefix, working));
if (!records_ownership) return fail("The game's working directory cannot be checked.");
@@ -811,17 +840,19 @@ Result<SettingsPublicationOperation> CaptureSettingsPublicationOperation(const R
if (!Complete(checked) || pw_title_publication_parse(reinterpret_cast<const uint8_t*>(receipt.bytes.data()),
receipt.bytes.size(), &parsed) != PW_OK)
return fail("Before state is not the verified publication of this game folder: " + checked.message);
- } else if (pw_title_publication_parse(reinterpret_cast<const uint8_t*>(receipt.bytes.data()), receipt.bytes.size(), &parsed) != PW_OK ||
+ } else if (const auto known_mount = platform::UsbMountOf(r.install_path);
+ pw_title_publication_parse(reinterpret_cast<const uint8_t*>(receipt.bytes.data()), receipt.bytes.size(), &parsed) != PW_OK ||
parsed.phase != PW_TITLE_PUBLICATION_COMMITTED || !prior || !prior->present ||
pw_title_publication_read_descriptor(("/data/homebrew/" + r.title_id + "/game-launch.json").c_str(), r.title_id.c_str(),
&platform, &descriptor, error, sizeof(error)) != PW_OK || descriptor.launch.app_id != r.runtime_number ||
+ (platform.known_game_mount = known_mount.empty() ? nullptr : known_mount.c_str(), false) ||
pw_title_publication_verify_locked(&descriptor, &platform, borrowed,
reinterpret_cast<const uint8_t*>(receipt.bytes.data()), receipt.bytes.size(), parsed.publication_sha256,
&contents, error, sizeof(error)) != PW_OK)
return fail("Before state is not a verified committed complete publication.");
o.previous_revision = parsed.settings_revision; o.previous_receipt_bytes = receipt.bytes; o.previous_metadata_bytes = prior->bytes;
}
- auto game = ManagedDirectory::Open(Map(prefix, working), GameDirectoryPolicy(m.game_root_unowned != 0));
+ auto game = ManagedDirectory::Open(Map(prefix, platform::OnGameMount(working, r.install_path)), GameDirectoryPolicy(m.game_root_unowned != 0));
auto dxvk = game ? ReadPublicationFile(*game, "dxvk.conf", 256 * 1024) : std::nullopt;
if (!dxvk) return fail("Before DXVK snapshot cannot be verified.");
o.dxvk_before = *dxvk;
diff --git a/src/runtime/settings_publication.h b/src/runtime/settings_publication.h
index 05e4358..32c09c7 100644
--- a/src/runtime/settings_publication.h
+++ b/src/runtime/settings_publication.h
@@ -49,6 +49,8 @@ PackageActionResult VerifyCommittedPublicationReceipt(const RuntimeInstall& reco
const std::filesystem::path& host_namespace_prefix = {});
// Whether the game's committed publication (its .playden-publication) admits the game folder
// unowned (metadata schema 3); nothing when there is none or it can't be read.
+// The folder the game's descriptor names now: /mnt/usb/<folder> for a USB game published naming no mount.
+std::optional<std::string> PublishedGameRoot(const RuntimeInstall& record, const std::filesystem::path& prefix);
std::optional<bool> PublishedGameRootUnowned(const RuntimeInstall& record,
const std::filesystem::path& host_namespace_prefix = {});
// The SHA-256 of the profile the game's committed publication wrote (its .playden-publication);
diff --git a/src/runtime/settings_publication_journal.cpp b/src/runtime/settings_publication_journal.cpp
index 30d3ea8..ad7c6a8 100644
--- a/src/runtime/settings_publication_journal.cpp
+++ b/src/runtime/settings_publication_journal.cpp
@@ -2,6 +2,7 @@
#include "runtime/artifact_hash.h"
#include "runtime/publication_contract.h"
#include "platform/managed_directory.h"
+#include "platform/usb_mount.h"
#include <cerrno>
#include <unistd.h>
extern "C" {
@@ -194,7 +195,8 @@ bool BaseValid(const SettingsPublicationOperation& o, std::string* reason) {
launch.app_id != r.runtime_number || launch.settings_revision != p.settings_revision || launch.install_id != r.install_id ||
launch.data_root != r.data_root || launch.default_profile_id != p.profile_id ||
launch.runtime_bundle_id != r.runtime_bundle_id || launch.recipe_id != p.recipe_id || launch.recipe_version != p.recipe_version ||
- launch.exit_policy != r.exit_policy || launch.game_root != r.install_path)
+ launch.exit_policy != r.exit_policy ||
+ launch.game_root != (launch.schema_version == 3 ? platform::WithoutUsbMountNumber(r.install_path) : r.install_path))
return Reject(reason, "Frozen descriptor does not match the OWNER record.");
PwGameProfile profile{};
if (pw_game_profile_parse(reinterpret_cast<const uint8_t*>(p.profile_bytes.data()), p.profile_bytes.size(), &profile) != PW_OK ||
@@ -206,8 +208,10 @@ bool BaseValid(const SettingsPublicationOperation& o, std::string* reason) {
pw_wine_launch_host_dir(prefix, profile.app.executable, executable, sizeof(executable)) ||
pw_wine_launch_host_dir(prefix, profile.app.working_directory, working, sizeof(working)))
return Reject(reason, "Frozen profile cannot form a Wine launch.");
- std::string expected_exe = r.install_path + "/" + NormalRelative(r.launch_path);
- std::string expected_working = r.install_path;
+ // A USB game published naming no mount: its profile and dxvk.conf name the same form as its descriptor.
+ const std::string published_root = launch.schema_version == 3 ? platform::WithoutUsbMountNumber(r.install_path) : r.install_path;
+ std::string expected_exe = published_root + "/" + NormalRelative(r.launch_path);
+ std::string expected_working = published_root;
if (!r.launch_working_directory.empty()) expected_working += "/" + NormalRelative(r.launch_working_directory);
else if (r.launch_in_install_root) {}
else if (expected_exe.find_last_of('/') != std::string::npos) expected_working = expected_exe.substr(0, expected_exe.find_last_of('/'));
diff --git a/src/runtime/settings_publication_owner.cpp b/src/runtime/settings_publication_owner.cpp
index ba24ba8..5fd2606 100644
--- a/src/runtime/settings_publication_owner.cpp
+++ b/src/runtime/settings_publication_owner.cpp
@@ -1,4 +1,5 @@
#include "runtime/settings_publication_owner.h"
+#include "platform/usb_mount.h"
#include "runtime/publication_contract.h"
#include "runtime/artifact_hash.h"
#include "platform/managed_file_lock.h"
@@ -539,8 +540,12 @@ PackageActionResult SettingsPublicationOwner::AuthorizeRetirement(const Settings
// once, by Block, before this apply changes anything.
// The journal of a game folder that moved names the old folder.
auto earlier = previous.install;
- if (const auto moved = record ? GameRootMoveOf(*record) : std::nullopt; moved && earlier.install_path == moved->from)
+ if (const auto moved = record ? GameRootMoveOf(*record) : std::nullopt;
+ moved && platform::WithoutUsbMountNumber(earlier.install_path) == platform::WithoutUsbMountNumber(moved->from))
earlier.install_path = moved->to;
+ // A game published naming no mount: its drive may have changed places since, with nothing published.
+ else if (record && platform::WithoutUsbMountNumber(earlier.install_path) == platform::WithoutUsbMountNumber(record->install_path))
+ earlier.install_path = record->install_path;
if (!record || !SameRuntimeInstallIdentity(*record, earlier) || !SameRuntimeInstallIdentity(*record, next.install) ||
!ReadyCaptureAllowed(*record, next.transaction_id) ||
record->settings_revision != previous.plan.settings_revision)
diff --git a/src/runtime/steamworks.cpp b/src/runtime/steamworks.cpp
index 74a7cfc..9ce7b1b 100644
--- a/src/runtime/steamworks.cpp
+++ b/src/runtime/steamworks.cpp
@@ -386,7 +386,7 @@ SteamworksResult ProvideLegacySteam(const std::string& install_root, const std::
stub = ReadFile(fs::path(emulator_dir) / "steam.dll", kMaxDllBytes);
const auto digest = stub ? HashArtifactBytes(*stub) : std::nullopt;
if (!digest || *digest != kLegacySteamSha256) {
- result.message = "Playden's runtime is missing its steam.dll; reinstall Playden.";
+ result.message = "Playden's runtime kit is missing its steam.dll; reinstall Playden.";
return result;
}
}
diff --git a/src/stores/local/copy_runner.cpp b/src/stores/local/copy_runner.cpp
index 46ca35a..def0e32 100644
--- a/src/stores/local/copy_runner.cpp
+++ b/src/stores/local/copy_runner.cpp
@@ -4,6 +4,7 @@
#include "steam/backend/depot_installer.h"
#include "stores/local/drop_folder_access.h"
#include "stores/local/scanner.h"
+#include "platform/usb_mount.h"
#include "stores/local/source_walk.h"
#include <algorithm>
@@ -347,6 +348,13 @@ installs::InstallRunner::Result LocalCopyRunner::Install(
}
auto plan = LoadCopyPlan(root);
if (!plan) return Abandon(*entry, root, kCopyStoppedFailure);
+ // The drive may have changed places since the copy began: the plan names the mount it had.
+ if (const auto source = "/mnt/" + entry->volume + "/" + entry->folder;
+ platform::IsUsbVolumeId(entry->volume) && plan->source != source &&
+ platform::WithoutUsbMountNumber(plan->source) == platform::WithoutUsbMountNumber(source)) {
+ Log("import copy follows its drive id=" + entry->id + " from=" + plan->source + " to=" + source);
+ plan->source = source;
+ }
// What a resume already has: files at their final name and planned size.
std::vector<char> done(plan->files.size(), 0);
diff --git a/src/stores/local/import_store.cpp b/src/stores/local/import_store.cpp
index 09f1552..abb6cef 100644
--- a/src/stores/local/import_store.cpp
+++ b/src/stores/local/import_store.cpp
@@ -1,5 +1,7 @@
#include "stores/local/import_store.h"
+#include "platform/usb_mount.h"
+
#include "platform/random_id.h"
#include "steam/backend/json.h"
#include "stores/local/scanner.h"
@@ -126,6 +128,13 @@ bool SameFolder(const std::string& volume_a, const std::string& folder_a, const
return volume_a == volume_b && folder_a == folder_b;
}
+// A removed game keeps its ID for its folder, on whichever mount its USB drive is now.
+bool SameRemovedFolder(const std::string& volume_a, const std::string& folder_a, const std::string& volume_b,
+ const std::string& folder_b) {
+ return SameFolder(volume_a, folder_a, volume_b, folder_b) ||
+ (platform::IsUsbVolumeId(volume_a) && platform::IsUsbVolumeId(volume_b) && SameFolder(volume_a, folder_a, volume_a, folder_b));
+}
+
} // namespace
const char* ImportStateKey(ImportState state) {
@@ -298,7 +307,7 @@ std::optional<RemovedImport> ImportStore::FindRemoved(const std::string& volume,
std::lock_guard<std::mutex> lock(mutex_);
if (!loaded_) return std::nullopt;
for (const auto& entry : removed_)
- if (SameFolder(entry.volume, entry.folder, volume, folder)) return entry;
+ if (SameRemovedFolder(entry.volume, entry.folder, volume, folder)) return entry;
return std::nullopt;
}
@@ -314,13 +323,33 @@ void ImportStore::MoveToRemoved(std::size_t index) {
removed_.erase(std::remove_if(removed_.begin(), removed_.end(),
[&](const auto& entry) {
return entry.id == game.id ||
- SameFolder(entry.volume, entry.folder, game.volume, game.folder);
+ SameRemovedFolder(entry.volume, entry.folder, game.volume, game.folder);
}),
removed_.end());
removed_.push_back({game.id, game.volume, game.folder, game.program});
while (removed_.size() > kMaxRemoved) removed_.erase(removed_.begin());
}
+ImportResult<ImportEntry> ImportStore::SetVolume(const std::string& id, const std::string& volume) {
+ std::lock_guard<std::mutex> lock(mutex_);
+ if (!loaded_) return FailureOf<ImportEntry>(ImportError::kNotLoaded, "imports are not loaded");
+ if (!ValidVolume(volume)) return FailureOf<ImportEntry>(ImportError::kInvalid, "the game's drive is invalid");
+ auto* game = Mutable(id);
+ if (!game) return FailureOf<ImportEntry>(ImportError::kNotFound, "the game is not in the library");
+ if (game->volume == volume) return ImportResult<ImportEntry>::Success(*game);
+ for (const auto& other : games_)
+ if (other.id != id && SameFolder(other.volume, other.folder, volume, game->folder))
+ return FailureOf<ImportEntry>(ImportError::kDuplicate, "this folder is already in the library");
+ const auto previous = game->volume;
+ game->volume = volume;
+ const auto persisted = Persist();
+ if (!persisted.ok()) {
+ game->volume = previous;
+ return FailureOf<ImportEntry>(persisted.error(), persisted.message());
+ }
+ return ImportResult<ImportEntry>::Success(*game);
+}
+
ImportResult<ImportEntry> ImportStore::Add(const std::string& volume, const std::string& folder,
const std::string& title, const std::string& program) {
std::lock_guard<std::mutex> lock(mutex_);
@@ -332,7 +361,7 @@ ImportResult<ImportEntry> ImportStore::Add(const std::string& volume, const std:
return FailureOf<ImportEntry>(ImportError::kDuplicate, "this folder is already in the library");
if (games_.size() >= kMaxGames) return FailureOf<ImportEntry>(ImportError::kBounds, "too many imported games");
const auto removed = std::find_if(removed_.begin(), removed_.end(), [&](const auto& entry) {
- return SameFolder(entry.volume, entry.folder, volume, folder);
+ return SameRemovedFolder(entry.volume, entry.folder, volume, folder);
});
std::string id;
if (removed != removed_.end()) {
diff --git a/src/stores/local/import_store.h b/src/stores/local/import_store.h
index 425a09c..22619d7 100644
--- a/src/stores/local/import_store.h
+++ b/src/stores/local/import_store.h
@@ -129,10 +129,13 @@ class ImportStore {
std::optional<ImportEntry> FindByFolder(const std::string& volume, const std::string& folder) const;
std::optional<RemovedImport> FindRemoved(const std::string& volume, const std::string& folder) const;
- // Adds a folder, playing in place. A folder on the removed list gets its old ID back; one already
- // in the library is refused (kDuplicate).
+ // Adds a folder, playing in place. A folder on the removed list gets its old ID back, also when its USB
+ // drive has changed places since; one already in the library is refused (kDuplicate).
ImportResult<ImportEntry> Add(const std::string& volume, const std::string& folder, const std::string& title,
const std::string& program);
+ // The drive a game was found on: USB drives can change places. Refused (kDuplicate) when that folder is
+ // another game's already.
+ ImportResult<ImportEntry> SetVolume(const std::string& id, const std::string& volume);
// The program Game settings chose (a program check precedes it).
ImportResult<ImportEntry> SetProgram(const std::string& id, const std::string& program);
diff --git a/src/stores/local/library_source.cpp b/src/stores/local/library_source.cpp
index 32ce323..b697e95 100644
--- a/src/stores/local/library_source.cpp
+++ b/src/stores/local/library_source.cpp
@@ -1,5 +1,7 @@
#include "stores/local/library_source.h"
+#include "platform/usb_mount.h"
+
#include "stores/local/copy_plan.h"
#include <cerrno>
@@ -540,9 +542,34 @@ bool LocalLibrarySource::CheckPresence() {
for (const auto& volume : present) line += volume + ",";
Log(line);
present_ = std::move(present);
+ FollowUsbDrives();
return true;
}
+// As InstallService does for installs: a game whose folder and program aren't on its USB mount follows them when
+// exactly one other holds them. Two copies can't be told apart, so the recorded one stays. A copied game plays
+// from Playden's own folder and has nothing to follow.
+void LocalLibrarySource::FollowUsbDrives() {
+ also_on_.clear();
+ for (const auto& game : store_.Games()) {
+ if (game.state == ImportState::kCopied || !platform::IsUsbVolumeId(game.volume)) continue;
+ std::vector<std::string> holders;
+ for (const auto& volume : config_.volumes) {
+ if (!platform::IsUsbVolumeId(volume.volume) || !present_.count(volume.volume)) continue;
+ const auto check = CheckProgram(HostPath(Join(volume.mount, game.folder)), game.program);
+ if (check == ProgramCheck::kOk) holders.push_back(volume.volume);
+ }
+ if (std::find(holders.begin(), holders.end(), game.volume) != holders.end()) {
+ for (const auto& other : holders)
+ if (other != game.volume) also_on_[game.id] = other;
+ } else if (holders.size() == 1) {
+ const auto moved = store_.SetVolume(game.id, holders.front());
+ Log("import follows its drive id=" + game.id + " from=" + game.volume + " to=" + holders.front() +
+ (moved.ok() ? std::string() : " failed: " + moved.message()));
+ }
+ }
+}
+
void LocalLibrarySource::Scan() {
std::vector<ImportCandidate> candidates;
for (const auto& volume : config_.volumes) {
@@ -594,6 +621,7 @@ void LocalLibrarySource::Project() {
location.volume_id = game.volume;
location.ownership = installs::InstalledLocation::Ownership::kExternal;
location.available = present_.count(game.volume) && IsFolder(HostPath(location.root));
+ if (const auto other = also_on_.find(game.id); other != also_on_.end()) location.also_on = other->second;
if (location.available && !IsPrintableAscii(location.root)) {
location.available = false;
location.reason = kNotAsciiReason;
diff --git a/src/stores/local/library_source.h b/src/stores/local/library_source.h
index 5d26732..75f14cd 100644
--- a/src/stores/local/library_source.h
+++ b/src/stores/local/library_source.h
@@ -14,6 +14,7 @@
#include <cstdint>
#include <deque>
#include <functional>
+#include <map>
#include <memory>
#include <mutex>
#include <set>
@@ -198,6 +199,7 @@ class LocalLibrarySource final : public LibrarySource {
void WarmRuntimeNumber(const std::function<std::uint32_t(const GameId&)>& given, const std::string& id);
void EnsureLoaded();
bool CheckPresence(); // true when the present volumes changed
+ void FollowUsbDrives(); // games on a USB drive that changed places: their folder says where they are now
void Scan();
void Project();
void Outcome(const Job& job, bool ok, std::string id, std::string message);
@@ -213,6 +215,7 @@ class LocalLibrarySource final : public LibrarySource {
bool load_tried_ = false;
std::string load_error_;
std::set<std::string> present_;
+ std::map<std::string, std::string> also_on_; // a game's ID: another USB drive with the same folder
std::vector<ImportCandidate> candidates_;
std::vector<ImportOutcome> outcomes_;
std::uint64_t games_revision_ = 0;
diff --git a/src/update/update_service.cpp b/src/update/update_service.cpp
index d172c1a..922f4e7 100644
--- a/src/update/update_service.cpp
+++ b/src/update/update_service.cpp
@@ -737,7 +737,7 @@ bool UpdateService::StageKit(const ReleaseAsset& asset, const KitPart& kit, bool
cancelled();
return false;
}
- fail("The kit download failed.", download.error);
+ fail("The runtime kit download failed.", download.error);
return false;
}
step(true, 0);
@@ -750,7 +750,7 @@ bool UpdateService::StageKit(const ReleaseAsset& asset, const KitPart& kit, bool
return MakeFolders(staging) && chmod(staging.c_str(), 0777) == 0;
});
if (!IsFolder(staging) || access(staging.c_str(), W_OK) != 0) {
- fail("Playden could not create the kit folder.", staging);
+ fail("Playden could not create the runtime kit folder.", staging);
return false;
}
ZipExtractOptions unzip;
@@ -773,7 +773,7 @@ bool UpdateService::StageKit(const ReleaseAsset& asset, const KitPart& kit, bool
cancelled();
return false;
}
- fail("The kit could not be unpacked.", unpacked.error);
+ fail("The runtime kit could not be unpacked.", unpacked.error);
return false;
}
Log("kit unpacked: " + std::to_string(unpacked.files) + " files, " + std::to_string(unpacked.rewritten) +
@@ -781,7 +781,7 @@ bool UpdateService::StageKit(const ReleaseAsset& asset, const KitPart& kit, bool
const auto sha = config_.verify_kit ? config_.verify_kit(staging) : std::nullopt;
if (!sha || *sha != kit.manifest_sha256) {
RemoveOwnedTree(staging);
- fail("The new kit did not pass its check.", sha ? "manifest " + *sha : "not a complete kit");
+ fail("The new runtime kit did not pass its check.", sha ? "manifest " + *sha : "not a complete kit");
return false;
}
// Ready next to the installed kit; it replaces it when Playden quits for the update.
@@ -794,7 +794,7 @@ bool UpdateService::StageKit(const ReleaseAsset& asset, const KitPart& kit, bool
RemoveOwnedTree(replaced);
if (!moved) {
RemoveOwnedTree(staging);
- fail("Playden could not put the new kit in place.", final_folder);
+ fail("Playden could not put the new runtime kit in place.", final_folder);
return false;
}
if (!local) unlink(zip.c_str());
@@ -891,9 +891,9 @@ void UpdateService::DoCheckKit() {
} else {
error = std::string("cannot read ") + kUpdateManifestAsset;
}
- if (!manifest_text) return FailKit("Playden could not read the kit information.", error);
+ if (!manifest_text) return FailKit("Playden could not read the runtime kit information.", error);
const auto manifest = ParseUpdateManifest(*manifest_text, &error);
- if (!manifest) return FailKit("The kit information of " + own->tag + " is not valid.", error);
+ if (!manifest) return FailKit("The runtime kit information of " + own->tag + " is not valid.", error);
if (manifest->kit.kit_id != config_.kit_id || manifest->kit.manifest_sha256 != config_.kit_manifest_sha256)
return unavailable("release " + own->tag + " names kit " + manifest->kit.kit_id + " " + manifest->kit.manifest_sha256);
// Only a missing or older kit is replaced: one as new or newer (a development kit, or the same version
@@ -916,7 +916,7 @@ void UpdateService::DoCheckKit() {
if ((zip = release.Find(manifest->kit.asset))) source = &release;
}
if (!zip) return unavailable("no release has " + manifest->kit.asset);
- if (zip->sha256.empty()) return FailKit("The kit on GitHub has no checksum. Install it by hand.", source->tag);
+ if (zip->sha256.empty()) return FailKit("The runtime kit on GitHub has no checksum. Install it by hand.", source->tag);
const bool staged = !ReadyKit(manifest->kit).empty();
kit_asset_ = *zip;
kit_part_ = manifest->kit;
@@ -947,12 +947,12 @@ void UpdateService::DoInstallKit() {
if (config_.free_bytes) {
const auto free = config_.free_bytes(config_.work_root);
if (free && *free < needed)
- return FailKit("The kit needs " + Gigabytes(needed) + " of free space; " + Gigabytes(*free) + " is free.",
+ return FailKit("The runtime kit needs " + Gigabytes(needed) + " of free space; " + Gigabytes(*free) + " is free.",
"free space");
}
if (!StageKit(*kit_asset_, kit, true)) return;
folder = ReadyKit(kit);
- if (folder.empty()) return FailKit("The new kit did not pass its check.", "not ready after unpacking");
+ if (folder.empty()) return FailKit("The new runtime kit did not pass its check.", "not ready after unpacking");
}
if (folder != installed) {
// No game can use the kit in place (none was admitted), so it is swapped now; the one it
@@ -964,7 +964,7 @@ void UpdateService::DoInstallKit() {
if (Exists(aside)) rename(aside.c_str(), installed.c_str());
return false;
});
- if (!moved) return FailKit("Playden could not put the kit in place.", installed);
+ if (!moved) return FailKit("Playden could not put the runtime kit in place.", installed);
}
Log("kit " + kit.kit_id + " " + kit.revision + " installed");
Set([](UpdateSnapshot& s) {
diff --git a/tests/homebrew_installed_locations_test.cpp b/tests/homebrew_installed_locations_test.cpp
index 8a74f7b..86c13ca 100644
--- a/tests/homebrew_installed_locations_test.cpp
+++ b/tests/homebrew_installed_locations_test.cpp
@@ -915,7 +915,7 @@ void ImportedGamePlaysInPlace() {
tick_until([&] {
const auto* runtime = runtime_of();
const auto snapshot = host.Snapshot();
- return game_of(model, game) && runtime && runtime->status == "Kit update available" && !runtime->runtime_current &&
+ return game_of(model, game) && runtime && runtime->status == "Runtime kit update available" && !runtime->runtime_current &&
(!snapshot.launch || (snapshot.launch->state != LaunchState::kLaunching &&
snapshot.launch->state != LaunchState::kRunning));
});
@@ -968,16 +968,80 @@ void ImportedGamePlaysInPlace() {
{
const auto& updated = *runtime_of();
if (!updated.maintenance_ok) std::fprintf(stderr, "Update runtime: %s\n", updated.maintenance_message.c_str());
- CHECK(updated.maintenance_ok && updated.maintenance_message == "Runtime updated.");
- CHECK(updated.runtime_current && updated.status != "Kit update available");
+ CHECK(updated.maintenance_ok && updated.maintenance_message == "Runtime kit updated.");
+ CHECK(updated.runtime_current && updated.status != "Runtime kit update available");
}
CHECK(Read(profile).find("\nrefresh = 120\nframe_rate = 120\n") != std::string::npos);
const auto* update = row_of(model, "maintenance-update");
- CHECK(update && !update->enabled && update->subtitle == "Runtime updated.");
+ CHECK(update && !update->enabled && update->subtitle == "Runtime kit updated.");
// The game does not start.
for (int i = 0; i < 50; ++i) { controller.Tick(); std::this_thread::sleep_for(std::chrono::milliseconds(2)); }
CHECK(launched.size() == plays_before);
});
+
+ // Play on a title a newer kit left behind updates it and stops on a dialog: the player chooses to start the game.
+ const auto stale_game = [&](hb::Simulation& model, local::LocalLibrarySource& source, RuntimeHost& host,
+ const std::function<void(const std::function<bool()>&)>& tick_until) {
+ std::string sky_id;
+ for (const auto& imported : source.Snapshot()->games)
+ if (imported.volume == "internal") sky_id = imported.id;
+ CHECK(!sky_id.empty());
+ const auto game = GameId::Local(sky_id);
+ tick_until([&] {
+ const auto found = model.state().runtime_games.find(game);
+ const auto snapshot = host.Snapshot();
+ return game_of(model, game) && found != model.state().runtime_games.end() &&
+ found->second.status == "Runtime kit update available" &&
+ (!snapshot.launch || (snapshot.launch->state != LaunchState::kLaunching &&
+ snapshot.launch->state != LaunchState::kRunning));
+ });
+ return game;
+ };
+ // The fake launch never reports a running game, so the last start ends in "Can't play"; the dialog waits behind it.
+ const auto ready_dialog = [](hb::Simulation& model) {
+ const auto& modals = model.state().navigation.modals;
+ if (!modals.empty() && modals.back().title == "Can't play") CHECK(model.action("focus:alert-ok") && model.action("cross"));
+ return !model.state().navigation.modals.empty() && model.state().navigation.modals.back().title == "Sky is ready";
+ };
+ const auto close_cant_play = [](hb::Simulation& model) {
+ const auto& modals = model.state().navigation.modals;
+ if (!modals.empty() && modals.back().title == "Can't play") CHECK(model.action("focus:alert-ok") && model.action("cross"));
+ };
+ kit = SyntheticKit(fixture.root / "kit-not-now", "native-2", "kit-1", 'd');
+ run(false, [&](hb::Simulation& model, hb::Controller& controller, RuntimeHost& host, local::LocalLibrarySource& source,
+ const std::function<void(const std::function<bool()>&)>& tick_until) {
+ const auto game = stale_game(model, source, host, tick_until);
+ const auto plays_before = launched.size();
+ close_cant_play(model);
+ open_details(model, game);
+ CHECK(model.action("focus:details-play") && model.action("cross"));
+ tick_until([&] { return ready_dialog(model); });
+ for (int i = 0; i < 50; ++i) { controller.Tick(); std::this_thread::sleep_for(std::chrono::milliseconds(2)); }
+ CHECK(launched.size() == plays_before);
+ CHECK(model.state().runtime_games.at(game).runtime_current);
+ CHECK(model.action("focus:update-ready-later") && model.action("cross"));
+ CHECK(model.state().navigation.modals.empty());
+ for (int i = 0; i < 50; ++i) { controller.Tick(); std::this_thread::sleep_for(std::chrono::milliseconds(2)); }
+ CHECK(launched.size() == plays_before);
+ // Up to date now: Play starts it, with no dialog.
+ CHECK(model.action("focus:details-play") && model.action("cross"));
+ tick_until([&] { return launched.size() > plays_before; });
+ CHECK(!ready_dialog(model));
+ });
+ kit = SyntheticKit(fixture.root / "kit-play", "native-2", "kit-1", 'e');
+ run(false, [&](hb::Simulation& model, hb::Controller& controller, RuntimeHost& host, local::LocalLibrarySource& source,
+ const std::function<void(const std::function<bool()>&)>& tick_until) {
+ const auto game = stale_game(model, source, host, tick_until);
+ const auto plays_before = launched.size();
+ close_cant_play(model);
+ open_details(model, game);
+ CHECK(model.action("focus:details-play") && model.action("cross"));
+ tick_until([&] { return ready_dialog(model); });
+ CHECK(model.action("focus:update-ready-play") && model.action("cross"));
+ CHECK(model.state().navigation.modals.empty());
+ tick_until([&] { return launched.size() > plays_before; });
+ (void)controller;
+ });
}
namespace {
diff --git a/tests/homebrew_library_graphical_test.cpp b/tests/homebrew_library_graphical_test.cpp
index c18500a..a1e55b5 100644
--- a/tests/homebrew_library_graphical_test.cpp
+++ b/tests/homebrew_library_graphical_test.cpp
@@ -259,12 +259,12 @@ int main(int argc,char** argv) {
}
// The details state gallery covers button widths, hint colours and the seventh fact.
for (const auto& [status, filename] : std::vector<std::pair<std::string, std::string>>{
- {"Not prepared", "details-not-prepared.png"}, {"Kit update available", "details-kit-update.png"},
+ {"Not prepared", "details-not-prepared.png"}, {"Runtime kit update available", "details-kit-update.png"},
{"Needs repair", "details-needs-repair.png"}, {"Needs recovery", "details-interrupted.png"},
{"Failed", "details-failed.png"}, {"Registration pending", "details-not-confirmed.png"},
- {"Removal incomplete", "details-removing.png"}, {"No kit", "details-no-kit.png"}}) {
+ {"Removal incomplete", "details-removing.png"}, {"No runtime kit", "details-no-kit.png"}}) {
LiveRuntimeGame state; state.game_id= SteamId(42); state.status=status;
- state.can_prepare=status!="No kit"; state.has_title=status!="No kit" && status!="Not prepared";
+ state.can_prepare=status!="No runtime kit"; state.has_title=status!="No runtime kit" && status!="Not prepared";
if (status=="Needs recovery" || status=="Failed") state.detail="insufficient verified free space for package copy";
live.UpdateRuntime(RuntimeState::Ready, {state});
capture_live(filename.c_str());
diff --git a/tests/homebrew_library_model_test.cpp b/tests/homebrew_library_model_test.cpp
index 9c15d2d..5a9f4bd 100644
--- a/tests/homebrew_library_model_test.cpp
+++ b/tests/homebrew_library_model_test.cpp
@@ -435,6 +435,30 @@ void live_install_volumes() {
check(model.action("details:42"), "installed game opens");
const auto* installed = find_row(model, "details-installed");
check(!installed, "installed size and location are shown only in facts");
+ check(!find_row(model, "details-also-on"), "one copy says nothing about drives");
+ model.UpdateAlsoOnDrives({{SteamId(42), "usb0"}});
+ const auto* also_on = find_row(model, "details-also-on");
+ check(also_on && also_on->title == "On two drives" && also_on->subtitle.find("USB drive") != std::string::npos,
+ "a game on two USB drives says so and names the other one");
+ model.UpdateAlsoOnDrives({});
+ check(!find_row(model, "details-also-on"), "and stops saying so when the copy has gone");
+ const auto drive_notice = [&model]() -> decltype(&model.state().notices.front()) {
+ for (const auto& notice : model.state().notices)
+ if (notice.id == "drive-updates") return &notice;
+ return nullptr;
+ };
+ model.UpdateDriveUpdates(0, 0);
+ check(!drive_notice(), "no drive change: nothing to say");
+ model.UpdateDriveUpdates(12, 37);
+ check(drive_notice() && !drive_notice()->persistent && drive_notice()->detail == "12 of 37 games" &&
+ drive_notice()->progress > 0.3F && drive_notice()->progress < 0.35F, "the job shows how far it is");
+ model.UpdateDriveUpdates(37, 37);
+ check(drive_notice() && drive_notice()->detail == "37 games" && drive_notice()->progress < 0.0F &&
+ drive_notice()->remaining_ticks < 60, "and says when it ends, then leaves");
+ model.UpdateDriveUpdates(12, 37);
+ model.UpdateDriveUpdates(37, 37, 1);
+ check(drive_notice() && drive_notice()->message == "Drive change updated with problems" &&
+ drive_notice()->detail == "36 of 37 games · the others may not start from Home", "a failure isn't reported as done");
check(model.action("details:44"), "game on an absent drive opens");
installed = find_row(model, "details-installed");
check(installed && installed->title == "Storage disconnected" && installed->subtitle == "Connect USB drive to use this game",
@@ -868,7 +892,7 @@ void live_install_language_row() {
check(model.view().surface == "install" && model.TakeInstallRequests().empty(),
"a game in several languages opens the install sheet");
const auto* row = find_row(model, "install-language");
- check(row && row->title == "Language" && row->value == "English" && row->subtitle == "From Settings › Downloads",
+ check(row && row->title == "Language" && row->value == "English" && row->subtitle == "From Settings, under Downloads",
"the Language row shows the language the Settings one resolves to");
activate(model, "install-language");
check(model.view().surface == "install-language", "the row opens the game's languages");
@@ -2545,21 +2569,21 @@ void live_play_does_the_next_useful_thing() {
const std::vector<Case> cases{
{"Ready", "Play", "", "", "Ready", "good", "runtime-play"},
{"Not prepared", "Play", "Sets up first", "", "Not set up", "quiet", "runtime-play"},
- {"Kit update available", "Play", "Kit update first", "", "Kit update available", "busy", "runtime-play"},
+ {"Runtime kit update available", "Play", "Updates runtime kit first", "", "Runtime kit update available", "busy", "runtime-play"},
{"Needs repair", "Play", "Repairs first", "Some of Synthetic's setup files changed.", "Needs repair", "attention", "runtime-play"},
{"Needs recovery", "Finish setup", "", "Setup stopped early.", "Interrupted", "attention", "runtime-prepare"},
{"Waiting for the PS5", "Finish setup", "Quits to Home", "Quit Playden and Synthetic appears on the PS5 Home screen.", "Waiting for the PS5", "busy", "quit-to-home"},
{"Failed", "Finish setup", "", "Setup failed.", "Failed", "problem", "runtime-prepare"},
{"Registration pending", "Check again", "", "The PS5 hasn't confirmed Synthetic yet.", "Not confirmed", "attention", "runtime-prepare"},
{"Removal incomplete", "Finish removing", "", "Removing Synthetic from the PS5 Home screen stopped partway.", "Removing", "attention", "runtime-remove-retry"},
- {"No kit", "Open Settings", "", "Playden needs its runtime kit to set up games.", "No kit", "problem", ""},
+ {"No runtime kit", "Open Settings", "", "Playden needs its runtime kit to set up games.", "No runtime kit", "problem", ""},
};
for (const auto& expected : cases) {
LiveRuntimeGame state; state.game_id = SteamId(42); state.status = expected.status;
state.detail = "raw technical detail for bug reports";
state.ready = state.status == "Ready"; state.can_play = state.ready;
- state.can_prepare = !state.ready && state.status != "No kit";
- state.has_title = state.status != "No kit" && state.status != "Not prepared";
+ state.can_prepare = !state.ready && state.status != "No runtime kit";
+ state.has_title = state.status != "No runtime kit" && state.status != "Not prepared";
state.awaiting_registration = state.status == "Waiting for the PS5";
model.UpdateRuntime(RuntimeState::Ready, {state});
check(model.action("details:42"), "details open");
@@ -2576,7 +2600,7 @@ void live_play_does_the_next_useful_thing() {
(state.status + ": setup fact states readiness").c_str());
check(!has_row(model, "details-runtime") && !has_row(model, "details-installed") &&
!has_row(model, "details-update-runtime"), "details avoid duplicated facts and separate kit update action");
- if (state.status == "No kit") {
+ if (state.status == "No runtime kit") {
activate(model, "details-play");
check(model.state().navigation.route == Route::Settings, "missing kit opens Settings");
check(model.TakeRuntimePlayRequests().empty() && model.TakeRuntimePrepareRequests().empty(),
@@ -3601,7 +3625,7 @@ void live_setup_from_an_earlier_kit_offers_recreate() {
check(model.UpdateLibrary({{game(SteamId(34), "Spire"), game(SteamId(35), "Broke")}, false, {}, false, false, {}}),
"library loaded");
model.UpdateInstalls({}, {{SteamId(34), 600'000'000}, {SteamId(35), 600'000'000}});
- const std::string words = "Started with an earlier kit · Recreate the bottle to finish (saves are kept)";
+ const std::string words = "Started with an earlier version of the runtime kit · Recreate the bottle to finish (saves are kept)";
LiveRuntimeGame spire; spire.game_id = SteamId(34); spire.status = "Needs recovery"; spire.has_title = true;
spire.can_prepare = true; spire.setup_other_kit = true; spire.detail = words;
LiveRuntimeGame broke; broke.game_id = SteamId(35); broke.status = "Failed"; broke.has_title = true;
@@ -3643,7 +3667,7 @@ void live_setup_from_an_earlier_kit_offers_recreate() {
"the game page offers Recreate bottle instead of Finish setup");
check(find_row(model, "details-hint") &&
find_row(model, "details-hint")->title ==
- "Setup started with an earlier kit. Recreate bottle makes it again; saves and settings are kept.",
+ "Setup started with an earlier version of the runtime kit. Recreate bottle makes it again; saves and settings are kept.",
"the hint says why");
activate(model, "details-play");
activate(model, "confirm-destructive");
@@ -3660,7 +3684,7 @@ void live_setup_from_an_earlier_kit_offers_recreate() {
model.UpdateRuntime(RuntimeState::Ready, {spire, broke});
const auto* update = find_row(model, "maintenance-update");
check(update && !update->enabled &&
- update->subtitle == "Setup was started with an earlier kit. Use Recreate bottle to finish it; saves are kept.",
+ update->subtitle == "Setup was started with an earlier version of the runtime kit. Use Recreate bottle to finish it; saves are kept.",
"Update runtime points to Recreate bottle");
const auto* recreate = find_row(model, "maintenance-recreate");
check(recreate && recreate->enabled, "Recreate bottle is there to use");
diff --git a/tests/homebrew_live_model_test.cpp b/tests/homebrew_live_model_test.cpp
index 07d8dd3..ec114dc 100644
--- a/tests/homebrew_live_model_test.cpp
+++ b/tests/homebrew_live_model_test.cpp
@@ -237,7 +237,7 @@ void live_120hz_waits_for_the_title_update(const std::filesystem::path& base) {
model.UpdateInstalls({}, {{SteamId(220), 1024, "internal", true}});
playden::homebrew::LiveRuntimeGame runtime;
runtime.game_id = SteamId(220);
- runtime.status = "Kit update available";
+ runtime.status = "Runtime kit update available";
runtime.prepared = runtime.has_title = true;
runtime.runtime_current = false;
runtime.launch_entry_id = "game";
@@ -330,7 +330,7 @@ void live_120hz_waits_for_the_title_update(const std::filesystem::path& base) {
"resetting Refresh rate sets a cap of 40 back to Off");
// Reset takes the waiting choices back.
- runtime.status = "Kit update available";
+ runtime.status = "Runtime kit update available";
runtime.ready = false;
runtime.runtime_current = false;
model.UpdateRuntime(playden::homebrew::RuntimeState::Ready, {runtime});
@@ -396,7 +396,7 @@ void live_update_runtime_from_maintenance(const std::filesystem::path& base) {
model.UpdateInstalls({}, {{SteamId(220), 1024, "internal", true}});
playden::homebrew::LiveRuntimeGame runtime;
runtime.game_id = SteamId(220);
- runtime.status = "Kit update available";
+ runtime.status = "Runtime kit update available";
runtime.prepared = runtime.has_title = runtime.can_prepare = true;
runtime.runtime_current = false;
runtime.launch_entry_id = "game";
@@ -409,8 +409,8 @@ void live_update_runtime_from_maintenance(const std::filesystem::path& base) {
model.TakeActivityRequests();
model.UpdateRuntime(playden::homebrew::RuntimeState::Ready, {runtime});
const auto* update = find_row(model, "maintenance-update");
- check(update && update->enabled && update->title == "Update runtime…" &&
- update->subtitle == "Moves the game to the installed kit's runtime without starting it." &&
+ check(update && update->enabled && update->title == "Update runtime kit…" &&
+ update->subtitle == "Moves the game to the installed runtime kit without starting it." &&
update->badge == "Game must be closed",
"Update runtime is offered for a closed game whose title waits for its kit update");
@@ -432,7 +432,7 @@ void live_update_runtime_from_maintenance(const std::filesystem::path& base) {
model.UpdateRuntime(playden::homebrew::RuntimeState::Ready, {runtime});
activate(model, "maintenance-update");
- check(model.state().navigation.modals.back().title == "Update the runtime?", "Update runtime asks first");
+ check(model.state().navigation.modals.back().title == "Update the runtime kit?", "Update runtime asks first");
activate(model, "confirm-destructive");
check(model.TakeMaintenanceRequests() == Requests{{SteamId(220), MaintenanceKind::UpdateRuntime}},
"a confirmed Update runtime goes to the runtime");
@@ -446,19 +446,19 @@ void live_update_runtime_from_maintenance(const std::filesystem::path& base) {
model.UpdateRuntime(playden::homebrew::RuntimeState::Ready, {runtime});
update = find_row(model, "maintenance-update");
check(update && !update->enabled && update->value == "Working…" &&
- update->subtitle == "Moves the game to the installed kit's runtime without starting it.",
+ update->subtitle == "Moves the game to the installed runtime kit without starting it.",
"the running update keeps saying what it does");
runtime.can_prepare = true;
runtime.maintenance_running = false;
runtime.maintenance_ok = true;
- runtime.maintenance_message = "Runtime updated.";
+ runtime.maintenance_message = "Runtime kit updated.";
runtime.status = "Ready";
runtime.ready = true;
runtime.runtime_current = true;
model.UpdateRuntime(playden::homebrew::RuntimeState::Ready, {runtime});
check(has_notice(model, "maintenance-220"), "the finished update reports its outcome");
update = find_row(model, "maintenance-update");
- check(update && !update->enabled && update->subtitle == "Runtime updated.", "the row shows the outcome");
+ check(update && !update->enabled && update->subtitle == "Runtime kit updated.", "the row shows the outcome");
runtime.maintenance.reset();
model.UpdateRuntime(playden::homebrew::RuntimeState::Ready, {runtime});
update = find_row(model, "maintenance-update");
@@ -992,7 +992,7 @@ void live_kit_install(const std::filesystem::path& base) {
replace.kit_phase = "downloading";
other.UpdateSelfUpdate(replace);
replace.kit_phase = "failed";
- replace.kit_error = "The kit download failed.";
+ replace.kit_error = "The runtime kit download failed.";
other.UpdateSelfUpdate(replace);
// Like every alert, it waits for sign-in.
other.UpdateAccount({AuthState::SignedIn, "account", "Owner", {}, {}, false});
@@ -1242,11 +1242,11 @@ void live_self_update(const std::filesystem::path& base) {
step.phase = "downloading";
failing.UpdateSelfUpdate(step);
step.phase = "failed";
- step.error = "The kit download failed.";
+ step.error = "The runtime kit download failed.";
failing.UpdateSelfUpdate(step);
check(!failing.state().navigation.modals.empty() &&
failing.state().navigation.modals.back().title == "Playden update stopped" &&
- failing.state().navigation.modals.back().body == "The kit download failed.",
+ failing.state().navigation.modals.back().body == "The runtime kit download failed.",
"update: a failed install is reported");
check(failing.action("cross") && failing.state().navigation.modals.empty(), "update: OK closes the report");
step.phase = "idle";
@@ -1684,9 +1684,9 @@ void live_manage_games_tabs(const std::filesystem::path& base) {
for (const auto& item : model.view().tabs) if (item.key == key) return item;
return playden::homebrew::ViewRow{};
};
- check(model.view().tabs.size() == 3 && model.view().tabs[1].key == "manage-tab-move" && tab("manage-tab-updates").value == "2" &&
- tab("manage-tab-uninstall").selected,
- "manage: three tabs, Move in the middle, Updates counts its games");
+ check(model.view().tabs.size() == 4 && model.view().tabs[1].key == "manage-tab-runtimes" && model.view().tabs[2].key == "manage-tab-move" &&
+ tab("manage-tab-updates").value == "2" && tab("manage-tab-uninstall").selected,
+ "manage: four tabs, Runtimes after Updates, Updates counts its games");
check(model.view().aside == "Console storage 500.0 GB free", "manage: each drive's free space");
activate(model, "manage-toggle-30");
check(find_row(model, "manage-toggle-30")->selected && model.view().footer == "1 selected · frees 30.0 GB",
@@ -1724,11 +1724,13 @@ void live_manage_games_tabs(const std::filesystem::path& base) {
check(navigation.focus_key == "manage-toggle-20", "manage: Updates comes back on its row");
// With one drive there is nowhere to move to: the Move tab stays and says so.
model.action("r1");
+ model.action("r1");
const auto* only = find_row(model, "manage-empty");
check(navigation.manage_tab == ManageTab::Move && only && only->title == "Only one drive" && !find_row(model, "manage-toggle-10") &&
!find_row(model, "manage-move-to")->enabled && navigation.focus_key == "manage-sort",
"manage: Move with a single drive explains why it is empty, and the focus is on a button that works");
model.action("l1");
+ model.action("l1");
// Check for updates: the button waits while Steam answers, games show up checked as they do.
activate(model, "manage-check");
@@ -1903,6 +1905,274 @@ void live_manage_update_selected(const std::filesystem::path& base) {
// Settings: Storage's Manage installed games counts the saved check's updates and opens on Uninstall; Updates'
// Game updates says how the check stands and opens on Updates. Both read the saved result without asking Steam.
+// The Runtimes tab: what is due, what it skips and why, and a batch that goes one game at a time and stops before
+// console storage runs too low.
+void live_manage_runtimes(const std::filesystem::path& base) {
+ using playden::homebrew::LiveRuntimeGame;
+ using playden::homebrew::MaintenanceKind;
+ using playden::homebrew::TitleActivity;
+ constexpr std::int64_t kNow = 1'800'000'000;
+ constexpr std::uint64_t gb = 1'000'000'000;
+ auto model = make_live(base);
+ model.SetWallClock(kNow);
+ model.UpdateAccount({AuthState::SignedIn, "76561198000000002", "Owner", {}, {}, false});
+ check(model.UpdateLibrary({{{SteamId(10), "Ten", "", "", ""}, {SteamId(20), "Twenty", "", "", ""}, {SteamId(30), "Thirty", "", "", ""},
+ {SteamId(40), "Forty", "", "", ""}, {SteamId(50), "Fifty", "", "", ""}, {SteamId(60), "Sixty", "", "", ""},
+ {SteamId(70), "Seventy", "", "", ""}, {SteamId(80), "Eighty", "", "", ""}},
+ false, {}, false, true, kNow}),
+ "runtimes: library delivered");
+ model.UpdateVolumes({{"internal", "Console storage", true, 800 * gb, 500 * gb}, {"usb", "USB Drive", false, 800 * gb, 500 * gb}}, "internal");
+ model.UpdateInstalls({}, {{SteamId(10), 40 * gb, "internal", true}, {SteamId(20), 30 * gb, "internal", true},
+ {SteamId(30), 20 * gb, "internal", true}, {SteamId(40), 10 * gb, "internal", true},
+ {SteamId(50), 9 * gb, "internal", true}, {SteamId(60), 8 * gb, "usb", false},
+ {SteamId(70), 7 * gb, "internal", true}, {SteamId(80), 6 * gb, "internal", true}});
+ const auto game = [](int id, const char* status) {
+ LiveRuntimeGame runtime;
+ runtime.game_id = SteamId(id);
+ runtime.status = status;
+ runtime.prepared = runtime.has_title = runtime.can_prepare = true;
+ runtime.activity = TitleActivity::Stopped;
+ return runtime;
+ };
+ auto stale = game(10, "Runtime kit update available");
+ auto repair = game(20, "Needs repair");
+ auto later = game(30, "Runtime kit update available");
+ auto current = game(40, "Ready");
+ current.ready = true;
+ auto recreate = game(50, "Not prepared");
+ recreate.setup_other_kit = true;
+ auto unplugged = game(60, "Runtime kit update available");
+ auto moving = game(70, "Needs repair");
+ moving.moving = true;
+ auto playing = game(80, "Runtime kit update available");
+ playing.activity = TitleActivity::Running;
+ const auto all = [&] { return std::vector<LiveRuntimeGame>{stale, repair, later, current, recreate, unplugged, moving, playing}; };
+ model.UpdateRuntime(playden::homebrew::RuntimeState::Ready, all());
+ for (int i = 0; i < 6 && model.state().navigation.route != playden::homebrew::Route::Settings; ++i) model.action("r1");
+ activate(model, "settings-installed");
+ check(model.state().navigation.route == playden::homebrew::Route::ManageGames, "Manage installed games opens");
+ while (model.state().navigation.manage_tab != playden::homebrew::ManageTab::Runtimes) check(model.action("r1"), "tabs go round");
+ check(model.view().title == "Update to the new runtime kit", "the tab is Runtimes");
+
+ const auto toggle = [&](int id) { return find_row(model, "manage-toggle-" + playden::ToKey(SteamId(id))); };
+ check(toggle(10) && toggle(10)->enabled && toggle(10)->selected && toggle(10)->value == "Runtime kit" &&
+ toggle(10)->subtitle == "Runtime kit update available · Console storage",
+ "a stale title is listed, chosen, and says what changes");
+ check(toggle(20) && toggle(20)->enabled && toggle(20)->selected && toggle(20)->value == "Repair", "a repair is listed too");
+ check(!toggle(40), "a current game isn't listed");
+ check(toggle(50) && !toggle(50)->enabled && toggle(50)->value == "Skipped" && toggle(50)->subtitle.find("Recreate") != std::string::npos,
+ "only Recreate can fix this one, and the batch doesn't run it");
+ check(toggle(60) && !toggle(60)->enabled && toggle(60)->subtitle.find("Drive disconnected") == 0, "an unplugged drive is skipped");
+ check(toggle(70) && !toggle(70)->enabled && toggle(70)->subtitle.find("Moving") == 0, "a stopped move isn't repaired");
+ check(toggle(80) && !toggle(80)->enabled && toggle(80)->subtitle == "Playing: close it to update", "a running game is skipped");
+ const auto primary = find_row(model, "manage-primary");
+ check(primary && primary->enabled && primary->title == "Update 3" && primary->action == "manage-runtimes", "Update counts the three");
+
+ // Triangle runs this tab's Update, not the Updates tab's downloads. These aren't install jobs, so the Queue's
+ // limit doesn't apply either.
+ model.TakeMaintenanceRequests();
+ check(model.action("triangle"), "Triangle starts it");
+ check(model.TakeInstallRequests().empty(), "Triangle asks for no downloads");
+ check(model.state().navigation.route == playden::homebrew::Route::Downloads, "it goes to Queue");
+ auto sent = model.TakeMaintenanceRequests();
+ check(sent.size() == 1 && sent[0].first == SteamId(10) && sent[0].second == MaintenanceKind::UpdateRuntime, "one game at a time");
+ const auto& waiting = model.state().preparation_queue.waiting;
+ check(std::find(waiting.begin(), waiting.end(), SteamId(20)) != waiting.end() &&
+ std::find(waiting.begin(), waiting.end(), SteamId(30)) != waiting.end(),
+ "Queue lists the games still to come");
+ check(model.TakeMaintenanceRequests().empty(), "nothing else goes while it works");
+ stale.status = "Preparing";
+ stale.maintenance = MaintenanceKind::UpdateRuntime;
+ stale.maintenance_running = true;
+ model.UpdateRuntime(playden::homebrew::RuntimeState::Ready, all());
+ check(model.TakeMaintenanceRequests().empty(), "nothing else goes while it prepares");
+
+ stale.status = "Ready";
+ stale.ready = true;
+ stale.maintenance_running = false;
+ stale.maintenance_ok = true;
+ stale.maintenance_message = "Runtime kit updated.";
+ model.UpdateRuntime(playden::homebrew::RuntimeState::Ready, all());
+ sent = model.TakeMaintenanceRequests();
+ check(sent.size() == 1 && sent[0].first == SteamId(20) && sent[0].second == MaintenanceKind::Repair, "the repair is next");
+
+ // Room runs short: the next game could cross the floor, so the rest stay as they are and the player can free some.
+ repair.status = "Ready";
+ repair.ready = true;
+ repair.maintenance = MaintenanceKind::Repair;
+ repair.maintenance_ok = true;
+ repair.maintenance_message = "Repaired.";
+ model.UpdateVolumes({{"internal", "Console storage", true, 800 * gb, 9 * gb}, {"usb", "USB Drive", false, 800 * gb, 500 * gb}}, "internal");
+ model.UpdateRuntime(playden::homebrew::RuntimeState::Ready, all());
+ check(model.TakeMaintenanceRequests().empty(), "below the floor no other game starts");
+ check(!model.state().navigation.modals.empty() && model.state().navigation.modals.back().title == "Runtime kit update stopped",
+ "the player is told why it stopped");
+ check(model.state().navigation.modals.back().body.find("2 of 3 games are done") != std::string::npos, "and how far it got");
+ const auto& after = model.state().preparation_queue.waiting;
+ check(std::find(after.begin(), after.end(), SteamId(30)) == after.end(), "Queue no longer lists the rest");
+ activate(model, "runtime-batch-free");
+ check(model.state().navigation.manage_tab == playden::homebrew::ManageTab::Uninstall, "Free up space opens Uninstall");
+
+ // Room again: a game left over can be sent, and a failure says why and can go again.
+ model.UpdateVolumes({{"internal", "Console storage", true, 800 * gb, 50 * gb}, {"usb", "USB Drive", false, 800 * gb, 500 * gb}}, "internal");
+ model.UpdateRuntime(playden::homebrew::RuntimeState::Ready, all());
+ while (model.state().navigation.manage_tab != playden::homebrew::ManageTab::Runtimes) check(model.action("r1"), "tabs go round");
+ check(toggle(30) && toggle(30)->enabled && !toggle(10) && !toggle(20), "only what is still due is listed");
+ if (!toggle(30)->selected) activate(model, "manage-toggle-" + playden::ToKey(SteamId(30)));
+ activate(model, "manage-primary");
+ sent = model.TakeMaintenanceRequests();
+ check(sent.size() == 1 && sent[0].first == SteamId(30), "the last one goes");
+ later.maintenance = MaintenanceKind::UpdateRuntime;
+ later.maintenance_message = "The runtime kit could not be updated.";
+ model.UpdateRuntime(playden::homebrew::RuntimeState::Ready, all());
+ const auto notice = std::find_if(model.state().notices.begin(), model.state().notices.end(),
+ [](const auto& item) { return item.id == "runtime-batch"; });
+ check(notice != model.state().notices.end() && notice->message == "Runtime kit updated with problems", "the end says it wasn't all good");
+ for (int i = 0; i < 6 && model.state().navigation.route != playden::homebrew::Route::Settings; ++i) model.action("r1");
+ activate(model, "settings-installed");
+ while (model.state().navigation.manage_tab != playden::homebrew::ManageTab::Runtimes) check(model.action("r1"), "tabs go round");
+ check(toggle(30) && toggle(30)->enabled && toggle(30)->tone == "problem" &&
+ toggle(30)->subtitle == "Failed: The runtime kit could not be updated.",
+ "the failure stays on its row, ready to try again");
+
+ // A refusal may pass (a game still closing), so it says why and can go again.
+ later.maintenance.reset();
+ later.maintenance_message.clear();
+ model.UpdateRuntime(playden::homebrew::RuntimeState::Ready, all());
+ playden::homebrew::PreparationQueue refusing;
+ refusing.refused[SteamId(30)] = "Close the game first.";
+ model.UpdatePreparationQueue(refusing);
+ check(toggle(30) && toggle(30)->enabled && toggle(30)->value == "Runtime kit" && toggle(30)->subtitle == "Refused: Close the game first.",
+ "a refused game can be chosen again");
+ model.UpdatePreparationQueue({});
+
+ // Waiting games are looked at again when their turn comes: one that has since started stays on the tab.
+ auto second = game(40, "Runtime kit update available");
+ current = second;
+ model.UpdateRuntime(playden::homebrew::RuntimeState::Ready, all());
+ if (!toggle(30)->selected) activate(model, "manage-toggle-" + playden::ToKey(SteamId(30)));
+ if (!toggle(40)->selected) activate(model, "manage-toggle-" + playden::ToKey(SteamId(40)));
+ model.TakeMaintenanceRequests();
+ check(model.action("triangle"), "Update goes again");
+ sent = model.TakeMaintenanceRequests();
+ check(sent.size() == 1, "one goes first");
+ auto& first = sent[0].first == SteamId(30) ? later : current;
+ auto& waiting_one = sent[0].first == SteamId(30) ? current : later;
+ waiting_one.activity = TitleActivity::Running;
+ first.status = "Ready";
+ first.ready = true;
+ first.maintenance = MaintenanceKind::UpdateRuntime;
+ first.maintenance_running = false;
+ first.maintenance_ok = true;
+ first.maintenance_message = "Runtime kit updated.";
+ model.UpdateRuntime(playden::homebrew::RuntimeState::Ready, all());
+ check(model.TakeMaintenanceRequests().empty(), "the game that started isn't sent");
+}
+
+// The runtime kit prompt: once per kit, only when a kit update is due, and never over What's new or another dialog.
+void live_runtime_prompt(const std::filesystem::path& base) {
+ using playden::homebrew::LiveRuntimeGame;
+ using playden::homebrew::MaintenanceKind;
+ using playden::homebrew::TitleActivity;
+ constexpr std::int64_t kNow = 1'800'000'000;
+ constexpr std::uint64_t gb = 1'000'000'000;
+ auto model = make_live(base);
+ check(model.ApplyPreferences(model.BeginPreferencesLoad(), {playden::Preferences{}, playden::PreferencesLoadStatus::kDefaultMissing, ""}),
+ "prompt: preferences loaded");
+ model.SetWallClock(kNow);
+ model.UpdateAccount({AuthState::SignedIn, "76561198000000002", "Owner", {}, {}, false});
+ check(model.UpdateLibrary({{{SteamId(10), "Ten", "", "", ""}, {SteamId(20), "Twenty", "", "", ""}}, false, {}, false, true, kNow}), "prompt: library");
+ model.UpdateVolumes({{"internal", "Console storage", true, 800 * gb, 500 * gb}}, "internal");
+ model.UpdateInstalls({}, {{SteamId(10), 40 * gb, "internal", true}, {SteamId(20), 30 * gb, "internal", true}});
+ const auto game = [](int id, const char* status) {
+ LiveRuntimeGame runtime;
+ runtime.game_id = SteamId(id);
+ runtime.status = status;
+ runtime.prepared = runtime.has_title = runtime.can_prepare = true;
+ runtime.activity = TitleActivity::Stopped;
+ return runtime;
+ };
+ const auto open_title = [&]() {
+ const auto& modals = model.state().navigation.modals;
+ return modals.empty() ? std::string() : modals.back().title;
+ };
+ const std::string kit_a(64, 'a'), kit_b(64, 'b');
+ playden::homebrew::LiveKitInfo kit;
+ kit.manifest_sha256 = kit_a;
+ model.SetKitInfo(kit);
+
+ // A repair alone says nothing about the kit.
+ model.UpdateRuntime(playden::homebrew::RuntimeState::Ready, {game(10, "Needs repair"), game(20, "Ready")});
+ check(open_title().empty(), "a repair alone doesn't ask");
+ check(model.ExportPreferences().runtime_prompt_kit.empty(), "and isn't recorded as asked");
+
+ model.UpdateRuntime(playden::homebrew::RuntimeState::Ready, {game(10, "Needs repair"), game(20, "Runtime kit update available")});
+ check(open_title() == "Update games to the new runtime kit?", "a kit update asks");
+ {
+ const auto* button = find_row(model, "runtime-prompt-update");
+ check(button && button->title == "Update 2 games", "the prompt's button counts the kit update and the repair");
+ check(model.state().navigation.modals.back().body.find("Nothing is downloaded from Steam") != std::string::npos,
+ "the prompt says this isn't a Steam update");
+ }
+ check(model.state().navigation.modals.back().body.find("1 game uses an older version of the runtime kit, and 1 needs a repair") == 0, "with what is due");
+ check(model.state().navigation.modals.back().body.find("USB games") == std::string::npos, "and no promise about USB drives");
+ check(model.state().navigation.modals.back().focused_action == 0, "Later has the focus: a stray Cross starts nothing");
+ check(model.ExportPreferences().runtime_prompt_kit.empty(), "not recorded until it is answered: closing Playden asks again");
+ activate(model, "ready-later");
+ check(open_title().empty() && model.TakeMaintenanceRequests().empty(), "Later changes nothing");
+ check(model.ExportPreferences().runtime_prompt_kit == kit_a, "Later records the kit");
+ model.UpdateRuntime(playden::homebrew::RuntimeState::Ready, {game(10, "Needs repair"), game(20, "Runtime kit update available")});
+ check(open_title().empty(), "once per kit");
+
+ // The next kit asks again; its button takes every game that can go, and says how many.
+ kit.manifest_sha256 = kit_b;
+ model.SetKitInfo(kit);
+ model.UpdateRuntime(playden::homebrew::RuntimeState::Ready, {game(10, "Runtime kit update available"), game(20, "Runtime kit update available")});
+ check(open_title() == "Update games to the new runtime kit?", "a new kit asks again");
+ // Circle answers it too, and a kit the player answered doesn't ask again.
+ check(model.action("circle"), "Circle closes the prompt");
+ check(open_title().empty() && model.ExportPreferences().runtime_prompt_kit == kit_b, "Circle records the kit");
+ const std::string kit_c(64, 'c');
+ kit.manifest_sha256 = kit_c;
+ model.SetKitInfo(kit);
+ model.UpdateRuntime(playden::homebrew::RuntimeState::Ready, {game(10, "Runtime kit update available"), game(20, "Runtime kit update available")});
+ check(open_title() == "Update games to the new runtime kit?", "the next kit asks");
+ activate(model, "runtime-prompt-update");
+ check(model.ExportPreferences().runtime_prompt_kit == kit_c, "Update records the kit");
+ const auto sent = model.TakeMaintenanceRequests();
+ check(sent.size() == 1 && sent[0].second == MaintenanceKind::UpdateRuntime, "Update all starts the batch");
+ check(model.state().navigation.route == playden::homebrew::Route::Downloads, "and goes to Queue");
+}
+
+void live_runtime_prompt_survives_library(const std::filesystem::path& base) {
+ using playden::homebrew::LiveRuntimeGame;
+ using playden::homebrew::TitleActivity;
+ constexpr std::int64_t kNow = 1'800'000'000;
+ constexpr std::uint64_t gb = 1'000'000'000;
+ auto model = make_live(base);
+ check(model.ApplyPreferences(model.BeginPreferencesLoad(), {playden::Preferences{}, playden::PreferencesLoadStatus::kDefaultMissing, ""}),
+ "library prompt: preferences loaded");
+ model.SetWallClock(kNow);
+ model.UpdateAccount({AuthState::SignedIn, "76561198000000002", "Owner", {}, {}, false});
+ check(model.UpdateLibrary({{{SteamId(10), "Ten", "", "", ""}, {SteamId(20), "Twenty", "", "", ""}}, false, {}, false, true, kNow}), "library prompt: library");
+ model.UpdateVolumes({{"internal", "Console storage", true, 800 * gb, 500 * gb}}, "internal");
+ model.UpdateInstalls({}, {{SteamId(10), 40 * gb, "internal", true}, {SteamId(20), 30 * gb, "internal", true}});
+ playden::homebrew::LiveKitInfo kit;
+ kit.manifest_sha256 = std::string(64, 'a');
+ model.SetKitInfo(kit);
+ LiveRuntimeGame runtime;
+ runtime.game_id = SteamId(10);
+ runtime.status = "Runtime kit update available";
+ runtime.prepared = runtime.has_title = runtime.can_prepare = true;
+ runtime.activity = TitleActivity::Stopped;
+ model.UpdateRuntime(playden::homebrew::RuntimeState::Ready, {runtime});
+ const auto& modals = model.state().navigation.modals;
+ check(!modals.empty() && modals.back().title == "Update games to the new runtime kit?", "library prompt: asks");
+ check(model.UpdateLibrary({{{SteamId(30), "Thirty", "", "", ""}}, false, {}, false, true, kNow}), "library prompt: replaced");
+ check(!modals.empty() && modals.back().title == "Update games to the new runtime kit?", "a library refresh leaves the prompt open");
+ check(model.ExportPreferences().runtime_prompt_kit.empty(), "and doesn't answer it");
+}
+
void live_settings_manage_rows(const std::filesystem::path& base) {
using playden::homebrew::ManageTab;
constexpr std::int64_t kNow = 1'800'000'000;
@@ -2287,6 +2557,7 @@ void live_manage_queue_full(const std::filesystem::path& base) {
// Moves count the same way, with what was asked for and not yet queued.
model.action("r1");
+ model.action("r1");
check(navigation.manage_tab == ManageTab::Move, "queue full: Move open");
check(find_row(model, "manage-move-to")->value == "USB Drive", "queue full: Move picks the drive with the most free space");
model.action("square");
@@ -2328,6 +2599,9 @@ int main() {
live_update_check(base / "update-check");
live_manage_games_tabs(base / "manage-games");
live_manage_update_selected(base / "update-selected");
+ live_manage_runtimes(base / "manage-runtimes");
+ live_runtime_prompt(base / "runtime-prompt");
+ live_runtime_prompt_survives_library(base / "runtime-prompt");
live_manage_move(base / "manage-move");
live_manage_uninstall_drive(base / "manage-uninstall-drive");
live_manage_queue_full(base / "queue-full");
diff --git a/tests/homebrew_runtime_host_test.cpp b/tests/homebrew_runtime_host_test.cpp
index 8d1d0ce..735fdc3 100644
--- a/tests/homebrew_runtime_host_test.cpp
+++ b/tests/homebrew_runtime_host_test.cpp
@@ -624,14 +624,10 @@ void PreparesExistingDownloadToReady() {
struct stat info{};
CHECK(stat((fixture.root / "data/playden/games/steam-220/library/prefixes/game").c_str(), &info) == 0 &&
(info.st_mode & 0777) == 0700);
- // The finished publication's request is no longer named by any journal: an
- // explicit cleanup removes it.
+ // The finished publication's request is no longer named by any journal, so it goes with it.
const auto request = fixture.root / "data/runtime-state/requests/settings-request-00000000-0000-4000-8000-000000000001.v1";
- CHECK(fs::is_regular_file(request));
- CHECK(WaitFor(host, [](const RuntimeSnapshot& s) { return s.leftover_requests == 1; }).leftover_requests == 1);
- host.CleanUpRequests();
- WaitFor(host, [](const RuntimeSnapshot& s) { return s.leftover_requests == 0; });
CHECK(!fs::exists(request));
+ CHECK(WaitFor(host, [](const RuntimeSnapshot& s) { return s.leftover_requests == 0; }).leftover_requests == 0);
// A second request does not redo anything.
host.Prepare(Hl2());
const auto again = WaitFor(host, [](const RuntimeSnapshot& s) { return s.refusals.count(220) != 0; });
@@ -4964,6 +4960,362 @@ void StuckMovedGameOffersRecreateBottle() {
host.Shutdown();
}
+// The console mounts a USB drive somewhere else: the record follows the game's folder, its old publication is
+// replaced at startup, and the title stays. Back on its first mount, nothing is left to publish.
+// A kit whose title finds a USB game's drive: the game is published naming no mount, so nothing needs publishing
+// when drives change places, a copy on another drive pins it, and an older title never gets the form it would refuse.
+void UsbGameNamesNoMount() {
+ Fixture fixture;
+ GamesMove move;
+ auto kit = SyntheticKit(fixture.root / "kit");
+ kit.capabilities.push_back("game-root-usb-search");
+ std::sort(kit.capabilities.begin(), kit.capabilities.end());
+ unsigned uuids = 0;
+ auto config = MoveConfig(fixture, kit, &uuids, move);
+ int unregistered = 0;
+ config.unregister_title = [&unregistered](const std::string&, const std::string&) {
+ ++unregistered;
+ return TitleRemoverResult{true, 0, "answered"};
+ };
+ const auto usb0 = fixture.root / "mnt/usb0/playden/games/220";
+ Write(usb0 / "hl2.exe", "existing-game", 0644);
+ for (const auto& folder : {fixture.root / "mnt", fixture.root / "mnt/usb0", fixture.root / "mnt/usb0/playden",
+ fixture.root / "mnt/usb0/playden/games", usb0})
+ CHECK(chmod(folder.c_str(), 0755) == 0);
+ fs::create_directories(fixture.root / "mnt/usb1");
+ CHECK(chmod((fixture.root / "mnt/usb1").c_str(), 0755) == 0);
+ auto game = Hl2();
+ game.install_path = "/mnt/usb0/playden/games/220";
+ game.volume_id = "usb0";
+ std::string title;
+ {
+ RuntimeHost host(config);
+ CHECK(host.Start());
+ CHECK(WaitFor(host, Started).kit_available);
+ host.Prepare(game);
+ const auto ready = WaitFor(host, [](const RuntimeSnapshot& s) {
+ return !s.preparing_app && (s.refusals.count(220) || (!s.installs.empty() && s.installs[0].state == PreparationState::kReady));
+ }, 60);
+ if (ready.refusals.count(220)) std::fprintf(stderr, "Prepare refused: %s\n", ready.refusals.at(220).c_str());
+ CHECK(!ready.refusals.count(220));
+ title = ready.installs[0].title_id;
+ CHECK(ready.installs[0].admission == "ok");
+ host.Shutdown();
+ }
+ const auto descriptor = fixture.root / "data/homebrew" / title / "game-launch.json";
+ const auto profile = fixture.root / "data/playden/games/steam-220/library/profiles/playden-steam-220.profile";
+ const auto published = Read(descriptor);
+ CHECK(published.find("\"schema_version\":3") != std::string::npos);
+ CHECK(published.find("\"game_root\":\"/mnt/usb/playden/games/220\"") != std::string::npos);
+ CHECK(Read(profile).find("Z:\\mnt\\usb\\playden\\games\\220\\hl2.exe") != std::string::npos);
+ const auto receipt = fixture.root / "data/playden/games/steam-220/.playden-control/publication-state.v1";
+ const auto receipt_before = Read(receipt);
+
+ // Drives change places: only the record follows.
+ fs::rename(fixture.root / "mnt/usb0/playden", fixture.root / "mnt/usb1/playden");
+ game.install_path = "/mnt/usb1/playden/games/220";
+ game.volume_id = "usb1";
+ {
+ RuntimeHost host(config);
+ CHECK(host.Start());
+ const auto started = WaitFor(host, Started);
+ CHECK(started.installs.size() == 1 && started.installs[0].install_path == "/mnt/usb1/playden/games/220");
+ CHECK(started.installs[0].title_id == title && !started.installs[0].republish_pending);
+ CHECK(started.drive_updates_total == 0);
+ CHECK(Read(descriptor) == published && Read(receipt) == receipt_before);
+ host.Shutdown();
+ }
+ CHECK(unregistered == 0);
+
+ // A copy on the other drive: the title would refuse, so the game is published naming this one. This publication
+ // also starts from the journal the old mount left.
+ Write(usb0 / "hl2.exe", "a-copy", 0644);
+ for (const auto& folder : {fixture.root / "mnt/usb0", fixture.root / "mnt/usb0/playden", fixture.root / "mnt/usb0/playden/games", usb0})
+ CHECK(chmod(folder.c_str(), 0755) == 0);
+ {
+ RuntimeHost host(config);
+ CHECK(host.Start());
+ const auto started = WaitFor(host, Started);
+ CHECK(started.drive_updates_total == 1);
+ const auto pinned = WaitFor(host, [](const RuntimeSnapshot& s) { return s.drive_updates_done == 1; }, 30);
+ CHECK(pinned.installs[0].install_path == "/mnt/usb1/playden/games/220" && !pinned.installs[0].republish_pending);
+ const auto named = Read(descriptor);
+ CHECK(named.find("\"schema_version\":2") != std::string::npos);
+ CHECK(named.find("\"game_root\":\"/mnt/usb1/playden/games/220\"") != std::string::npos);
+ CHECK(Read(profile).find("Z:\\mnt\\usb1\\playden\\games\\220\\hl2.exe") != std::string::npos);
+ host.Shutdown();
+ }
+ // The copy goes: back to naming no mount.
+ fs::remove_all(fixture.root / "mnt/usb0/playden");
+ {
+ RuntimeHost host(config);
+ CHECK(host.Start());
+ CHECK(WaitFor(host, Started).drive_updates_total == 1);
+ WaitFor(host, [](const RuntimeSnapshot& s) { return s.drive_updates_done == 1; }, 30);
+ CHECK(Read(descriptor).find("\"game_root\":\"/mnt/usb/playden/games/220\"") != std::string::npos);
+ host.Shutdown();
+ }
+ // Unplugged: nothing is published, and it doesn't read as needing a repair.
+ const auto away = fixture.root / "unplugged";
+ fs::rename(fixture.root / "mnt/usb1/playden", away);
+ const auto before_unplug = Read(descriptor);
+ {
+ RuntimeHost host(config);
+ CHECK(host.Start());
+ const auto started = WaitFor(host, Started);
+ CHECK(started.installs[0].install_path == "/mnt/usb1/playden/games/220" && started.drive_updates_total == 0);
+ CHECK(!playden::runtime::AdmissionNeedsRepair(started.installs[0].admission));
+ CHECK(Read(descriptor) == before_unplug);
+ host.Shutdown();
+ }
+ CHECK(playden::runtime::AdmissionNeedsRepair("admission status=-1: x") && !playden::runtime::AdmissionNeedsRepair(playden::runtime::kAdmissionDriveMissing) &&
+ !playden::runtime::AdmissionNeedsRepair(playden::runtime::kAdmissionDriveAmbiguous) && !playden::runtime::AdmissionNeedsRepair("ok"));
+ fs::rename(away, fixture.root / "mnt/usb1/playden");
+ CHECK(unregistered == 0);
+}
+
+// A title on an older runtime refuses the search form: it stays with its mount until Update runtime, which brings both.
+void OlderTitleKeepsItsMount() {
+ Fixture fixture;
+ GamesMove move;
+ auto kit = SyntheticKit(fixture.root / "kit");
+ unsigned uuids = 0;
+ auto config = MoveConfig(fixture, kit, &uuids, move);
+ const auto usb0 = fixture.root / "mnt/usb0/playden/games/220";
+ Write(usb0 / "hl2.exe", "existing-game", 0644);
+ for (const auto& folder : {fixture.root / "mnt", fixture.root / "mnt/usb0", fixture.root / "mnt/usb0/playden",
+ fixture.root / "mnt/usb0/playden/games", usb0})
+ CHECK(chmod(folder.c_str(), 0755) == 0);
+ auto game = Hl2();
+ game.install_path = "/mnt/usb0/playden/games/220";
+ game.volume_id = "usb0";
+ std::string title;
+ {
+ RuntimeHost host(config);
+ CHECK(host.Start());
+ CHECK(WaitFor(host, Started).kit_available);
+ host.Prepare(game);
+ const auto ready = WaitFor(host, [](const RuntimeSnapshot& s) {
+ return !s.preparing_app && !s.installs.empty() && s.installs[0].state == PreparationState::kReady;
+ }, 60);
+ title = ready.installs[0].title_id;
+ host.Shutdown();
+ }
+ const auto descriptor = fixture.root / "data/homebrew" / title / "game-launch.json";
+ CHECK(Read(descriptor).find("\"game_root\":\"/mnt/usb0/playden/games/220\"") != std::string::npos);
+ // The new kit arrives: the title is on the old runtime, so starting Playden publishes nothing.
+ auto newer = SyntheticKit(fixture.root / "kit-newer", "native-2", "kit-1", 'c');
+ newer.capabilities.push_back("game-root-usb-search");
+ std::sort(newer.capabilities.begin(), newer.capabilities.end());
+ config.admit_kit = [newer](std::string*) { return std::optional<RuntimeKit>(newer); };
+ RuntimeHost host(config);
+ CHECK(host.Start());
+ const auto started = WaitFor(host, Started);
+ CHECK(!started.installs[0].title_current && started.drive_updates_total == 0);
+ CHECK(Read(descriptor).find("\"game_root\":\"/mnt/usb0/playden/games/220\"") != std::string::npos);
+ // Update runtime brings the runtime, then the form the title can now read.
+ host.Prepare(game);
+ const auto updated = WaitFor(host, [](const RuntimeSnapshot& s) {
+ return !s.preparing_app && !s.installs.empty() && (s.installs[0].title_current || s.refusals.count(220));
+ }, 60);
+ if (updated.refusals.count(220)) std::fprintf(stderr, "Update refused: %s\n", updated.refusals.at(220).c_str());
+ CHECK(!updated.refusals.count(220) && updated.installs[0].admission == "ok");
+ const auto after = Read(descriptor);
+ CHECK(after.find("\"schema_version\":3") != std::string::npos && after.find("\"game_root\":\"/mnt/usb/playden/games/220\"") != std::string::npos);
+ host.Shutdown();
+ // The next kit makes this title older too, but it already reads the form: it isn't pinned to a mount again.
+ auto next = SyntheticKit(fixture.root / "kit-next", "native-3", "kit-1", 'd');
+ next.capabilities.push_back("game-root-usb-search");
+ std::sort(next.capabilities.begin(), next.capabilities.end());
+ config.admit_kit = [next](std::string*) { return std::optional<RuntimeKit>(next); };
+ RuntimeHost later(config);
+ CHECK(later.Start());
+ const auto restarted = WaitFor(later, Started);
+ CHECK(!restarted.installs[0].title_current && restarted.drive_updates_total == 0);
+ CHECK(Read(descriptor) == after);
+ later.Shutdown();
+}
+
+// A game that is running holds only itself back: the others are updated for the drive change meanwhile.
+void DriveUpdateSkipsABusyGame() {
+ Fixture fixture;
+ GamesMove move;
+ const auto kit = AnyTitleKit(fixture.root / "kit");
+ unsigned uuids = 0;
+ auto config = MoveConfig(fixture, kit, &uuids, move);
+ config.write_title_allow_list = [](const std::string&, std::string*) { return true; };
+ // Two titles, so the registry knows each by the ID in its request.
+ auto registered = std::make_shared<std::set<std::string>>();
+ config.native.database = [registered](const std::string& title) {
+ if (!registered->count(title)) return TitleDatabaseObservation{TitleAvailability::kFree, {}};
+ return TitleDatabaseObservation{TitleAvailability::kOccupied,
+ InstalledTitleIdentity{title, "UP9000-" + title + "_00-PROSPEROWIN00001", "/user/app/" + title + "/sce_sys"}};
+ };
+ config.registry_transport = [registered](const std::string& route, const std::string& body) -> std::optional<std::string> {
+ if (route != "/api/v1/games") {
+ const auto at = body.find("FAKE78");
+ if (at != std::string::npos) registered->insert(body.substr(at, 9));
+ return R"({"status":0})";
+ }
+ std::string games;
+ for (const auto& title : *registered)
+ games += (games.empty() ? "" : ",") + std::string(R"({"title_id":")") + title +
+ R"(","installed":true,"managed":true,"source_available":true,"source_type":"folder","path":"/data/homebrew/)" + title + R"("})";
+ return R"({"status":0,"games":[)" + games + "]}";
+ };
+ std::vector<std::string> titles;
+ auto busy = std::make_shared<std::string>();
+ config.native.activity = [busy](const std::string& title) { return title == *busy ? NativeActivity::kActive : NativeActivity::kStopped; };
+ auto game = [](std::uint32_t app, int mount) {
+ auto request = Hl2();
+ request.runtime_number = app;
+ request.install_path = "/mnt/usb" + std::to_string(mount) + "/playden/games/" + std::to_string(app);
+ request.volume_id = "usb" + std::to_string(mount);
+ if (app != 220) request.launches = {{"", "", "bin\\game.exe", "", ""}};
+ return request;
+ };
+ CHECK(chmod(fixture.root.c_str(), 0755) == 0);
+ for (const std::uint32_t app : {220u, 221u}) {
+ const auto folder = fixture.root / "mnt/usb0/playden/games" / std::to_string(app);
+ if (app == 220) Write(folder / "hl2.exe", "existing-game", 0644);
+ else {
+ // A 64-bit PE header is all the generator reads.
+ std::string pe(0x80 + 26, '\0');
+ pe[0] = 'M'; pe[1] = 'Z'; pe[0x3c] = 0x40; pe[0x40] = 'P'; pe[0x41] = 'E';
+ pe[0x44] = 0x64; pe[0x45] = static_cast<char>(0x86); pe[0x40 + 24] = 0x0b; pe[0x40 + 25] = 0x02;
+ Write(folder / "Bin/Game.exe", pe, 0644);
+ CHECK(chmod((folder / "Bin").c_str(), 0755) == 0);
+ }
+ for (const auto& part : {fixture.root / "mnt", fixture.root / "mnt/usb0", fixture.root / "mnt/usb0/playden",
+ fixture.root / "mnt/usb0/playden/games", folder})
+ CHECK(chmod(part.c_str(), 0755) == 0);
+ }
+ {
+ RuntimeHost host(config);
+ CHECK(host.Start());
+ CHECK(WaitFor(host, Started).kit_available);
+ for (const std::uint32_t app : {220u, 221u}) {
+ host.Prepare(game(app, 0));
+ const auto ready = WaitFor(host, [app](const RuntimeSnapshot& s) {
+ if (s.preparing_app || s.refusals.count(app)) return !s.preparing_app;
+ return std::any_of(s.installs.begin(), s.installs.end(), [app](const auto& install) {
+ return install.runtime_number == app && install.state == PreparationState::kReady; });
+ }, 60);
+ if (ready.refusals.count(app)) std::fprintf(stderr, "Prepare refused: %s\n", ready.refusals.at(app).c_str());
+ CHECK(!ready.refusals.count(app));
+ }
+ const auto installed = host.Snapshot();
+ for (const auto& install : installed.installs) titles.push_back(install.title_id);
+ host.Shutdown();
+ }
+ CHECK(titles.size() == 2);
+ // The drive comes back on another mount with the first game's title running.
+ fs::rename(fixture.root / "mnt/usb0", fixture.root / "mnt/usb1");
+ fs::create_directories(fixture.root / "mnt/usb0");
+ *busy = titles[0];
+ RuntimeHost host(config);
+ CHECK(host.Start());
+ const auto started = WaitFor(host, Started);
+ CHECK(started.drive_updates_total == 2);
+ const auto partly = WaitFor(host, [](const RuntimeSnapshot& s) { return s.drive_updates_done >= 1; }, 10);
+ CHECK(partly.drive_updates_done == 1);
+ busy->clear();
+ const auto all = WaitFor(host, [](const RuntimeSnapshot& s) { return s.drive_updates_done == 2; }, 30);
+ CHECK(all.drive_updates_done == 2 && all.drive_updates_failed == 0);
+ host.Shutdown();
+}
+
+void UsbDriveChangesPlaces() {
+ Fixture fixture;
+ GamesMove move;
+ const auto kit = SyntheticKit(fixture.root / "kit");
+ unsigned uuids = 0;
+ auto config = MoveConfig(fixture, kit, &uuids, move);
+ config.cloud_saves_root = "/data/playden-games/.playden-saves";
+ int unregistered = 0;
+ config.unregister_title = [&unregistered](const std::string&, const std::string&) {
+ ++unregistered;
+ return TitleRemoverResult{true, 0, "answered"};
+ };
+ const auto usb0 = fixture.root / "mnt/usb0/playden/games/220";
+ const auto usb1 = fixture.root / "mnt/usb1/playden/games/220";
+ Write(usb0 / "hl2.exe", "existing-game", 0644);
+ for (const auto& folder : {fixture.root / "mnt", fixture.root / "mnt/usb0", fixture.root / "mnt/usb0/playden",
+ fixture.root / "mnt/usb0/playden/games", usb0})
+ CHECK(chmod(folder.c_str(), 0755) == 0);
+ auto game = Hl2();
+ game.install_path = "/mnt/usb0/playden/games/220";
+ game.volume_id = "usb0";
+ std::string title;
+ {
+ RuntimeHost host(config);
+ CHECK(host.Start());
+ CHECK(WaitFor(host, Started).kit_available);
+ host.Prepare(game);
+ const auto ready = WaitFor(host, [](const RuntimeSnapshot& s) {
+ return !s.preparing_app && (s.refusals.count(220) || (!s.installs.empty() && s.installs[0].state == PreparationState::kReady));
+ }, 60);
+ if (ready.refusals.count(220)) std::fprintf(stderr, "Prepare refused: %s\n", ready.refusals.at(220).c_str());
+ CHECK(!ready.refusals.count(220));
+ title = ready.installs[0].title_id;
+ host.Shutdown();
+ }
+ const auto descriptor = fixture.root / "data/homebrew" / title / "game-launch.json";
+ CHECK(Read(descriptor).find("/mnt/usb0/playden/games/220") != std::string::npos);
+ Write(fixture.root / "data/playden-games/.playden-saves/220/cloud-index.txt",
+ "version=1\naccount=a\nchange=7\ngame_root=/mnt/usb0/playden/games/220\nprefix_root=/data/x\n", 0644);
+ fs::create_directories(fixture.root / "mnt/usb1");
+ CHECK(chmod((fixture.root / "mnt/usb1").c_str(), 0755) == 0);
+ fs::rename(fixture.root / "mnt/usb0/playden", fixture.root / "mnt/usb1/playden");
+ {
+ RuntimeHost host(config);
+ CHECK(host.Start());
+ // Playden is ready with the old publication: it goes in the background, and the job counts it.
+ const auto started = WaitFor(host, Started);
+ CHECK(started.installs.size() == 1 && started.installs[0].install_path == "/mnt/usb1/playden/games/220");
+ CHECK(started.installs[0].title_id == title && started.installs[0].state == PreparationState::kReady);
+ CHECK(started.drive_updates_total == 1);
+ CHECK(!move.Logged("startup moved app=220"));
+ const auto updated = WaitFor(host, [](const RuntimeSnapshot& s) { return s.drive_updates_done == 1; }, 30);
+ CHECK(updated.drive_updates_total == 1 && !updated.installs[0].republish_pending);
+ CHECK(move.Logged("drive update app=220 republished"));
+ CHECK(Read(descriptor).find("/mnt/usb1/playden/games/220") != std::string::npos);
+ CHECK(Read(fixture.root / "data/playden-games/.playden-saves/220/cloud-index.txt").find("game_root=/mnt/usb1/") != std::string::npos);
+ // A Prepare naming the other mount (the drive moved while Playden was open) never removes the title.
+ host.Shutdown();
+ }
+ CHECK(unregistered == 0);
+ // Moved back with the title busy, as after a Play Playden hasn't closed yet: the job waits instead of giving up,
+ // and carries on when the title stops.
+ fs::rename(fixture.root / "mnt/usb1/playden", fixture.root / "mnt/usb0/playden");
+ fixture.activity->store(static_cast<int>(NativeActivity::kActive));
+ {
+ RuntimeHost host(config);
+ CHECK(host.Start());
+ const auto started = WaitFor(host, Started);
+ CHECK(started.installs[0].install_path == "/mnt/usb0/playden/games/220" && started.installs[0].title_id == title);
+ CHECK(started.drive_updates_total == 1 && started.drive_updates_done == 0);
+ std::this_thread::sleep_for(std::chrono::milliseconds(500));
+ CHECK(host.Snapshot().drive_updates_done == 0 && host.Snapshot().installs[0].republish_pending);
+ fixture.activity->store(static_cast<int>(NativeActivity::kStopped));
+ const auto caught_up = WaitFor(host, [](const RuntimeSnapshot& s) { return s.drive_updates_done == 1; }, 30);
+ CHECK(!caught_up.installs[0].republish_pending);
+ CHECK(Read(descriptor).find("/mnt/usb0/playden/games/220") != std::string::npos);
+ // Prepare with the record on one mount and the request on another: the record only follows.
+ fs::rename(fixture.root / "mnt/usb0/playden", fixture.root / "mnt/usb1/playden");
+ auto other = game;
+ other.install_path = "/mnt/usb1/playden/games/220";
+ other.volume_id = "usb1";
+ host.Prepare(other);
+ const auto followed = WaitFor(host, [](const RuntimeSnapshot& s) {
+ return !s.preparing_app && !s.installs.empty() && s.installs[0].install_path == "/mnt/usb1/playden/games/220";
+ }, 60);
+ CHECK(followed.installs[0].title_id == title && !move.Logged("moved install app=220"));
+ host.Shutdown();
+ }
+ CHECK(unregistered == 0);
+}
+
// A moved game whose title was busy at startup is republished by Play first, which says so.
void PlayBeforeRepublishRepublishesFirst() {
Fixture fixture;
@@ -5629,7 +5981,7 @@ void UnownedUpgradeAfterCommittedSettingsUpdates(int scenario) {
CHECK(logged("unowned upgrade request 00000000-0000-4000-8000-000000000006 dropped: "));
CHECK(logged("startup unowned app=220 deferred: "));
CHECK(!journaled() && Read(metadata) == owned);
- CHECK(restarted.Snapshot().leftover_requests == 4);
+ CHECK(restarted.Snapshot().leftover_requests == 0);
} else {
CHECK(logged("startup unowned app=220 republished"));
CHECK(!journaled() && unowned_published());
@@ -5692,9 +6044,8 @@ void UnownedUpgradeAfterCommittedSettingsUpdates(int scenario) {
CHECK(logged("unowned upgrade request 00000000-0000-4000-8000-000000000005 dropped: "));
CHECK(logged("startup unowned app=220 deferred: "));
CHECK(!journaled() && !fs::exists(request) && Read(metadata) == owned);
- // The preparation's and the committed updates' requests are the usual leftovers; the dropped
- // one is gone.
- CHECK(host.Snapshot().leftover_requests == 4 && !host.Snapshot().installs[0].recovery_pending);
+ // Finished publications leave no requests, and the dropped one is gone.
+ CHECK(host.Snapshot().leftover_requests == 0 && !host.Snapshot().installs[0].recovery_pending);
// Play tries the upgrade again, drops its request again, and starts the game as before.
play(host);
CHECK(logged("unowned upgrade request 00000000-0000-4000-8000-000000000006 dropped: "));
@@ -5821,6 +6172,40 @@ RuntimeRelocationResult RelocateNow(RuntimeHost& host, std::uint32_t number, std
return host.Relocate(std::move(request), std::chrono::seconds(60));
}
+// Published naming no mount, the drive changes places, and then the game moves off it: the journal still names the
+// mount it was published on, and the record another one.
+void MoveAfterUsbSwap() {
+ Fixture fixture;
+ GamesMove move;
+ auto kit = SyntheticKit(fixture.root / "kit");
+ kit.capabilities.push_back("game-root-usb-search");
+ std::sort(kit.capabilities.begin(), kit.capabilities.end());
+ unsigned uuids = 0;
+ const auto config = MoveConfig(fixture, kit, &uuids, move);
+ const auto imported = PrepareImported(fixture, config, "/mnt/usb0/playden/import/Imported");
+ const auto descriptor = fixture.root / "data/homebrew" / imported.title_id / "game-launch.json";
+ CHECK(Read(descriptor).find("\"game_root\":\"/mnt/usb/playden/import/Imported\"") != std::string::npos);
+ fs::create_directories(fixture.root / "mnt/usb1");
+ CHECK(chmod((fixture.root / "mnt/usb1").c_str(), 0755) == 0);
+ fs::rename(fixture.root / "mnt/usb0/playden", fixture.root / "mnt/usb1/playden");
+ fs::create_directories(fixture.root / "data/playden-games");
+ fs::copy(fixture.root / "mnt/usb1/playden/import/Imported", fixture.root / fs::path(kImportedRoot).relative_path(),
+ fs::copy_options::recursive);
+ RuntimeHost host(config);
+ CHECK(host.Start());
+ const auto started = WaitFor(host, Started);
+ CHECK(started.installs[0].install_path == "/mnt/usb1/playden/import/Imported" && started.drive_updates_total == 0);
+ const auto result = RelocateNow(host, imported.number);
+ if (!result.message.empty()) std::fprintf(stderr, "Relocate: %s\n", result.message.c_str());
+ CHECK(result.outcome == RuntimeRelocationResult::Outcome::kDone && !result.prepare_again && result.message.empty());
+ const auto moved = WaitFor(host, [](const RuntimeSnapshot& s) { return !s.installs.empty() && !s.installs[0].republish_pending; }, 30);
+ CHECK(moved.installs[0].install_path == kImportedRoot && moved.installs[0].title_id == imported.title_id);
+ const auto published = Read(descriptor);
+ CHECK(published.find(std::string("\"game_root\":\"") + kImportedRoot + "\"") != std::string::npos);
+ CHECK(published.find("\"schema_version\":2") != std::string::npos);
+ host.Shutdown();
+}
+
// Copy later: a game prepared on a USB drive, copied into Playden. Its title follows the copy;
// the drive folder stays as it was.
void CopiedGameKeepsItsTitle() {
@@ -6570,6 +6955,11 @@ int main(int argc, char** argv) {
LocalGameSteamworksAppId();
PublicStateRootIsUnavailable();
PreparesExistingDownloadToReady();
+ UsbDriveChangesPlaces();
+ DriveUpdateSkipsABusyGame();
+ UsbGameNamesNoMount();
+ MoveAfterUsbSwap();
+ OlderTitleKeepsItsMount();
PreparesGameOnUnownedDrive();
PrepareFixesRootOwnedHomebrewFolder();
PrepareNamesUnfixableFolder();
diff --git a/tests/homebrew_simulation_test.cpp b/tests/homebrew_simulation_test.cpp
index 49c1e99..dc71d6c 100644
--- a/tests/homebrew_simulation_test.cpp
+++ b/tests/homebrew_simulation_test.cpp
@@ -900,7 +900,7 @@ void t52_recipe_values_in_game_settings(const std::filesystem::path& fixtures, c
auto& setup = setups[SteamId(900001)];
setup.scanned = true;
setup.programs = {{"bin/win64/hl2_win64.exe", "pe64", "", false, "d3d11 graphics=dxvk"},
- {"Launcher.exe", "pe32", "This game needs .NET, which Playden's runtime doesn't include yet.", true, ""},
+ {"Launcher.exe", "pe32", "This game needs .NET, which Playden's runtime kit doesn't include yet.", true, ""},
{"Stub.exe", "pe32", "This game's program has Steam DRM in a form Playden can't unpack yet.", false, ""}};
// The programs show in an open Program picker as soon as the folder's scan arrives.
simulation.action("details:900001");
diff --git a/tests/install_service_test.cpp b/tests/install_service_test.cpp
index 8095262..3d86c0c 100644
--- a/tests/install_service_test.cpp
+++ b/tests/install_service_test.cpp
@@ -1180,7 +1180,92 @@ void UpdateWaitsLongerWhenTheConsoleDoesNotSay(const std::filesystem::path& root
std::filesystem::remove_all(root);
}
+// The console can mount USB drives the other way round, or on another port: a game's line names the mount it
+// had, and its folder decides where it is now. Only USB volumes change places.
+void UsbDrivesChangePlaces(const std::filesystem::path& base) {
+ std::filesystem::remove_all(base);
+ const auto primary = base / "data";
+ const auto usb0 = base / "usb0";
+ const auto usb1 = base / "usb1";
+ const auto usb2 = base / "usb2";
+ for (const auto& folder : {primary, usb0, usb1, usb2}) std::filesystem::create_directories(folder);
+ const auto copying = [](const std::filesystem::path& root) {
+ std::filesystem::create_directories(root / ".playden-copy");
+ std::ofstream(root / ".playden-copy" / "plan.json") << "{}";
+ };
+ InstalledGameFolder(usb1 / "40"); // on the other mount
+ InstalledGameFolder(usb0 / "41");
+ InstalledGameFolder(usb1 / "41"); // on both: stays where it was recorded
+ InstalledGameFolder(usb1 / "43");
+ InstalledGameFolder(usb2 / "43"); // on two others: can't tell which
+ InstalledGameFolder(usb1 / "44"); // recorded on console storage: never followed
+ std::filesystem::create_directories(usb1 / "45");
+ std::ofstream(usb1 / "45" / ".playden-download") << "x"; // a download's partial folder
+ InstalledGameFolder(usb1 / "46"); // an uninstall that hadn't finished
+ // A paused move from usb0 to usb1, drives swapped: the partial copy is now on usb0 and the original on usb1.
+ InstalledGameFolder(usb1 / "47");
+ copying(usb0 / "47");
+ // One past its switch, deleting the old folder: the copy (with its journal) is on usb0, the old folder on usb1.
+ InstalledGameFolder(usb0 / "48");
+ copying(usb0 / "48");
+ InstalledGameFolder(usb1 / "48");
+ // A move that hadn't copied anything: the game is now on the drive it was going to.
+ InstalledGameFolder(usb1 / "49");
+ // Fully moved to usb1 with only the line left, drives swapped: the copy is on usb0 and there's nothing to do.
+ InstalledGameFolder(usb0 / "50");
+ std::ofstream(primary / ".playden-games")
+ << "40\tusb0\t4096\n41\tusb0\t4096\n42\tusb0\t4096\n43\tusb0\t4096\n44\tinternal\t4096\n"
+ << "45\tusb0\t0\tpaused\n46\tusb0\t4096\tremoving\n"
+ << "47\tusb0\t4096\tmove=usb1\tfrom=usb0\tpaused\n48\tusb1\t4096\tmove=usb1\tfrom=usb0\tpaused\n"
+ << "49\tusb0\t4096\tmove=usb1\tfrom=usb0\tpaused\n50\tusb1\t4096\tmove=usb1\tfrom=usb0\tpaused\n";
+ const std::vector<InstallVolume> volumes{{"internal", "Console storage", primary.string(), true},
+ {"usb0", "USB drive", usb0.string(), true},
+ {"usb1", "USB drive 2", usb1.string(), true},
+ {"usb2", "USB drive 3", usb2.string(), true}};
+ Sessions sessions;
+ Runner runner(sessions);
+ InstallService service(runner, volumes);
+ const auto game = [&](std::uint32_t app) -> InstalledGame {
+ for (const auto& installed : service.Snapshot().installed)
+ if (installed.id == SteamId(app)) return installed;
+ CHECK(false);
+ return {};
+ };
+ CHECK(game(40).volume_id == "usb1" && game(40).available && game(40).root == (usb1 / "40").string());
+ CHECK(game(41).volume_id == "usb0" && game(41).available && game(41).also_on == "usb1");
+ CHECK(game(40).also_on.empty());
+ CHECK(game(42).volume_id == "usb0" && !game(42).available);
+ CHECK(game(43).volume_id == "usb0" && !game(43).available);
+ CHECK(game(44).volume_id == "internal" && !game(44).available);
+ const auto snapshot = service.Snapshot();
+ const auto* download = JobOf(snapshot, SteamId(45));
+ CHECK(download && download->volume_id == "usb1");
+ // The partial copy is the destination, whatever the line says: it is never copied over the original.
+ CHECK(game(47).volume_id == "usb1" && game(47).available);
+ const auto* move = JobOf(snapshot, SteamId(47));
+ CHECK(move && move->volume_id == "usb0" && move->from_volume_id == "usb1");
+ // Past the switch the game plays from the copy, and the folder left to delete is the old one.
+ CHECK(game(48).volume_id == "usb0" && game(48).available);
+ const auto* finishing = JobOf(snapshot, SteamId(48));
+ CHECK(finishing && finishing->volume_id == "usb0" && finishing->from_volume_id == "usb1");
+ // Nothing copied yet: still bound for the other drive.
+ CHECK(game(49).volume_id == "usb1");
+ const auto* queued = JobOf(snapshot, SteamId(49));
+ CHECK(queued && queued->volume_id == "usb0" && queued->from_volume_id == "usb1");
+ // A finished move is not made again, and its only copy isn't taken for an old folder.
+ CHECK(game(50).volume_id == "usb0" && game(50).available && !JobOf(snapshot, SteamId(50)));
+ // What was found is saved: the next start reads it, and no drive has to stay where it is.
+ const auto text = ReadText(primary / ".playden-games");
+ CHECK(text.find("40\tusb1\t") != std::string::npos);
+ CHECK(text.find("41\tusb0\t") != std::string::npos);
+ CHECK(text.find("44\tinternal\t") != std::string::npos);
+ // The uninstall deletes the folder where it is now.
+ AwaitAt(__LINE__, service, [&](const InstallSnapshot&) { return !std::filesystem::exists(usb1 / "46"); });
+ service.Shutdown();
+}
+
int main() {
+ UsbDrivesChangePlaces(std::filesystem::temp_directory_path() / ("playden-usb-swap-" + std::to_string(::getpid())));
UpdateWaitsLongerWhenTheConsoleDoesNotSay(std::filesystem::temp_directory_path() /
("playden-update-unknown-" + std::to_string(::getpid())));
UpdateWaitsForTheGameToClose(std::filesystem::temp_directory_path() / ("playden-update-wait-" + std::to_string(::getpid())));
diff --git a/tests/install_volumes_test.cpp b/tests/install_volumes_test.cpp
index 200a4d2..ebe2192 100644
--- a/tests/install_volumes_test.cpp
+++ b/tests/install_volumes_test.cpp
@@ -1,3 +1,4 @@
+#include "platform/usb_mount.h"
#include "steam/install_volumes.h"
#include <cstdio>
@@ -134,6 +135,16 @@ int main() {
}
CHECK(detail::VolumeMountMatches("/data/playden/games", "/data"));
CHECK(detail::VolumeMountMatches("/mnt/ext10", "/mnt"));
+ using playden::platform::IsUsbVolumeId;
+ using playden::platform::OnUsbMount;
+ using playden::platform::WithoutUsbMountNumber;
+ CHECK(IsUsbVolumeId("usb0") && IsUsbVolumeId("usb7") && !IsUsbVolumeId("usb8") && !IsUsbVolumeId("usb") &&
+ !IsUsbVolumeId("usb10") && !IsUsbVolumeId("m2"));
+ CHECK(WithoutUsbMountNumber("/mnt/usb1/playden/games/730") == "/mnt/usb/playden/games/730");
+ CHECK(WithoutUsbMountNumber("/mnt/usb1") == "/mnt/usb");
+ for (const char* other : {"/mnt/usb/x", "/mnt/usb10/x", "/mnt/usb8/x", "/mnt/usbx/x", "/mnt/ext1/x", "/data/mnt/usb1/x", "/mnt/usb1x"})
+ CHECK(WithoutUsbMountNumber(other) == other);
+ CHECK(OnUsbMount("/mnt/usb1/playden/games/730", 3) == "/mnt/usb3/playden/games/730");
std::filesystem::permissions(base / "locked", std::filesystem::perms::owner_all);
std::filesystem::remove_all(base);
diff --git a/tests/local_copy_test.cpp b/tests/local_copy_test.cpp
index 57f82b8..11d89a8 100644
--- a/tests/local_copy_test.cpp
+++ b/tests/local_copy_test.cpp
@@ -100,6 +100,7 @@ struct Fixture {
std::mutex log_mutex;
int next_id = 0;
std::atomic<bool> usb_present{true}; // the source drive
+ bool extra_import_volumes = false; // /mnt/usb1 too
std::vector<InstallVolume> extra_volumes; // install volumes after the console storage
std::function<std::string(const std::string&, const std::string&)> game_program; // LocalLibraryConfig::game_program
@@ -143,6 +144,7 @@ struct Fixture {
}
LocalLibraryConfig config;
config.volumes = {{"internal", "/data", "playden-import", false}, {"usb0", "/mnt/usb0", "playden/import", false}};
+ if (extra_import_volumes) config.volumes.push_back({"usb1", "/mnt/usb1", "playden/import", false});
config.host_prefix = root.string();
config.present = [this](const ImportVolume& volume) { return volume.volume != "usb0" || usb_present.load(); };
config.log = options.log;
@@ -762,6 +764,31 @@ void UninstallWithoutTheSourceDrive() {
CHECK(fs::is_regular_file(fixture.root / "unplugged/playden/import/Rally/Bin/Rally.exe"));
}
+// The console mounts the source drive somewhere else: an in-place game follows its folder, and is saved there.
+void UsbDriveChangesPlaces() {
+ Fixture fixture;
+ fixture.Start();
+ fixture.Add();
+ WaitFor([&] { const auto all = fixture.local->Locations(); return all.size() == 1 && all[0].volume_id == "usb0"; }, "the game on usb0");
+ fixture.Stop();
+ fs::create_directories(fixture.root / "mnt/usb1");
+ fs::rename(fixture.root / "mnt/usb0/playden", fixture.root / "mnt/usb1/playden");
+ fixture.extra_import_volumes = true;
+ fixture.Start();
+ WaitFor([&] { return fixture.store->Find(kId)->volume == "usb1"; }, "the game on the other mount");
+ WaitFor([&] { const auto all = fixture.local->Locations(); return all.size() == 1 && all[0].available &&
+ all[0].root == "/mnt/usb1/playden/import/Rally"; },
+ "its location on the other mount");
+ // A second copy on another drive: the recorded one stays, and the location says so.
+ fs::create_directories(fixture.root / "mnt/usb0/playden/import");
+ fs::copy(fixture.root / "mnt/usb1/playden/import/Rally", fixture.root / "mnt/usb0/playden/import/Rally",
+ fs::copy_options::recursive);
+ fixture.Stop();
+ fixture.Start();
+ WaitFor([&] { const auto all = fixture.local->Locations(); return all.size() == 1 && all[0].also_on == "usb0"; }, "two copies");
+ CHECK(fixture.store->Find(kId)->volume == "usb1");
+}
+
void CrashBetweenCommitSteps() {
Fixture fixture;
// Playden stops after the install record, before imports.json says copied.
@@ -1177,6 +1204,7 @@ void DropFolderCopyFreesTheDropFolder() {
}
int main() {
+ UsbDriveChangesPlaces();
PlanCoversTheTree();
PlanLeavesOutTheWebPagesTemporaryFiles();
LinksAreRefused();
diff --git a/tests/local_import_store_test.cpp b/tests/local_import_store_test.cpp
index d3d28f8..fe13fa4 100644
--- a/tests/local_import_store_test.cpp
+++ b/tests/local_import_store_test.cpp
@@ -138,9 +138,13 @@ void InPlaceRemoveAndRestoreFromRemoved() {
// Removed twice keeps one entry for the folder.
CHECK(reloaded.Remove(kA).ok() && reloaded.Add("usb0", "playden/import/Celeste", "Celeste", "Celeste.exe").ok());
CHECK(reloaded.Remove(kA).ok() && reloaded.Removed().size() == 1);
- // Another slot is another folder: a new ID.
+ // Another USB slot is the same folder (drives change places): its ID, bottle and settings come back.
const auto other = reloaded.Add("usb1", "playden/import/Celeste", "Celeste", "Celeste.exe");
- CHECK(other.ok() && other.value().id == kB);
+ CHECK(other.ok() && other.value().id == kA);
+ // Another kind of drive is another folder: a new ID.
+ CHECK(reloaded.Remove(kA).ok());
+ const auto m2 = reloaded.Add("m2", "playden/import/Celeste", "Celeste", "Celeste.exe");
+ CHECK(m2.ok() && m2.value().id == kB);
}
void CopyTransitionsFollowTheStateTable() {
@@ -261,7 +265,36 @@ void FileIsPrivate() {
} // namespace
+// USB drives can change places: a game can follow its folder, and a removed game keeps its ID on either mount.
+void UsbDrivesChangePlaces() {
+ TemporaryDirectory directory;
+ playden::Storage storage(directory.path);
+ CHECK(storage.EnsureRootDirectory().ok());
+ ImportStore store(storage, "imports.json", Ids({kA, kB, kC}), Clock());
+ CHECK(store.Load().ok());
+ CHECK(store.Add("usb0", "playden/import/Celeste", "Celeste", "Celeste.exe").ok());
+ CHECK(store.Add("usb1", "playden/import/Rally", "Rally", "Rally.exe").ok());
+ CHECK(store.SetVolume(kA, "usb1").ok());
+ CHECK(store.Find(kA)->volume == "usb1" && store.FindByFolder("usb1", "playden/import/Celeste")->id == kA);
+ // That folder on that drive is another game's.
+ CHECK(store.Add("usb0", "playden/import/Rally", "Rally 2", "Rally.exe").ok());
+ CHECK(store.SetVolume(kB, "usb0").error() == ImportError::kDuplicate && store.Find(kB)->volume == "usb1");
+ CHECK(store.SetVolume(kA, "not a volume!").error() == ImportError::kInvalid);
+ CHECK(store.SetVolume("nobody", "usb0").error() == ImportError::kNotFound);
+ // It is saved.
+ ImportStore reloaded(storage, "imports.json", Ids({kC}), Clock());
+ CHECK(reloaded.Load().ok() && reloaded.Find(kA)->volume == "usb1");
+ // Removed on one mount, added on another: the same game.
+ CHECK(reloaded.Remove(kA).ok());
+ CHECK(reloaded.FindRemoved("usb2", "playden/import/Celeste")->id == kA);
+ const auto readded = reloaded.Add("usb2", "playden/import/Celeste", "Celeste", "Celeste.exe");
+ CHECK(readded.ok() && readded.value().id == kA && readded.value().volume == "usb2" && reloaded.Removed().empty());
+ // Console storage has no mounts to change.
+ CHECK(!reloaded.FindRemoved("m2", "playden/import/Celeste"));
+}
+
int main() {
+ UsbDrivesChangePlaces();
RandomIdsAreLowerCaseVersionFour();
AddFindAndRoundTrip();
DuplicatesAndInvalidFieldsAreRefused();
diff --git a/tests/preferences_test.cpp b/tests/preferences_test.cpp
index 60735c2..1f223d1 100644
--- a/tests/preferences_test.cpp
+++ b/tests/preferences_test.cpp
@@ -186,10 +186,10 @@ void SignInMethodPersistsAndVersionThreeOpensQr() {
Check(store.Save(preferences).ok(), "sign-in method preference saves");
const auto saved = storage.Read("preferences.conf");
Check(saved.ok() && std::string(saved.value().begin(), saved.value().end()) ==
- "version=11\nreduce_motion=0\ntitle_store_suffix=0\ncloud_saves_auto=1\nsteam_sign_in_password=1\n"
+ "version=12\nreduce_motion=0\ntitle_store_suffix=0\ncloud_saves_auto=1\nsteam_sign_in_password=1\n"
"downloads_slow_network=0\nsteam_stay_signed_in=1\nbeta_updates=0\ndownload_server=\nweb_access=1\n"
- "content_language=english\nhide_run_once_help=0\nhide_launcher_help=0\n",
- "version 11 format includes Automatic download server, web access and English");
+ "content_language=english\nhide_run_once_help=0\nhide_launcher_help=0\nruntime_prompt_kit=\n",
+ "version 12 format includes Automatic download server, web access and English");
const auto loaded = store.Load();
Check(loaded.status == playden::PreferencesLoadStatus::kLoaded && loaded.preferences.steam_sign_in_password &&
loaded.preferences.cloud_saves_auto,
@@ -324,6 +324,33 @@ void LauncherDialogsRemembered() {
playden::Storage storage(directory.path());
playden::PreferencesStore store(storage);
playden::Preferences preferences;
+ {
+ // Version 11 loads with no prompt shown; a kit's SHA-256 round-trips, and anything else is dropped alone.
+ playden::Preferences offered;
+ offered.runtime_prompt_kit = std::string(64, 'a');
+ offered.hide_launcher_help = true;
+ Check(store.Save(offered).ok(), "the prompt's kit saves");
+ auto kept = store.Load();
+ Check(kept.status == playden::PreferencesLoadStatus::kLoaded && kept.preferences.runtime_prompt_kit == offered.runtime_prompt_kit,
+ "the prompt's kit is kept");
+ const auto file = storage.Read("preferences.conf");
+ Check(file.ok(), "preferences read back");
+ std::string text(file.value().begin(), file.value().end());
+ const auto bad = text;
+ auto corrupted = bad;
+ corrupted.replace(corrupted.find("runtime_prompt_kit=") + 19, 64, "not-a-sha");
+ Check(storage.WriteAtomic("preferences.conf", playden::Bytes(corrupted.begin(), corrupted.end())).ok(), "write a bad value");
+ kept = store.Load();
+ Check(kept.status == playden::PreferencesLoadStatus::kLoaded && kept.preferences.runtime_prompt_kit.empty() && kept.preferences.hide_launcher_help,
+ "a bad prompt value is dropped alone");
+ auto older = bad;
+ older.replace(0, 10, "version=11");
+ older.erase(older.find("runtime_prompt_kit="));
+ Check(storage.WriteAtomic("preferences.conf", playden::Bytes(older.begin(), older.end())).ok(), "write version 11");
+ kept = store.Load();
+ Check(kept.status == playden::PreferencesLoadStatus::kLoaded && kept.preferences.runtime_prompt_kit.empty() && kept.preferences.hide_launcher_help,
+ "version 11 loads with the prompt not shown yet");
+ }
Check(!preferences.hide_run_once_help && !preferences.hide_launcher_help, "the launcher dialogs show by default");
preferences.hide_launcher_help = true;
Check(store.Save(preferences).ok(), "launcher dialog choice saves");
@@ -358,8 +385,8 @@ void OlderPreferencesUseAutomaticDownloadServer() {
"migration retains old fields and defaults later fields");
Check(store.Save(loaded.preferences).ok(), "migrated preferences save");
const auto saved = storage.Read("preferences.conf");
- Check(saved.ok() && std::string(saved.value().begin(), saved.value().end()).rfind("version=11\n", 0) == 0,
- "saving a migrated file writes version 11");
+ Check(saved.ok() && std::string(saved.value().begin(), saved.value().end()).rfind("version=12\n", 0) == 0,
+ "saving a migrated file writes version 12");
Check(loaded.preferences.web_access, "every older preference version has web access on");
Check(loaded.preferences.content_language == "english", "every older preference version downloads English");
}
diff --git a/third_party/prospero-win b/third_party/prospero-win
index 3b87bca..7537eb0 160000
--- a/third_party/prospero-win
+++ b/third_party/prospero-win
@@ -1 +1 @@
-Subproject commit 3b87bca0c759c6708090b0a6c6af81ce27f6073c
+Subproject commit 7537eb0113b438e8dc0730e594fa0743203bc7c9