From cdd7ba06c1f4a3841a3cb7b9127f081cee705df2 Mon Sep 17 00:00:00 2001 From: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com> Date: Thu, 26 Nov 2026 08:53:53 -0500 Subject: [PATCH] fix(steam): plan only the depots the account's licenses grant, and flag games with a Linux build The client installs no depot that none of the account's packages lists in `depotids`; the engine also took edition-only depots (Sekiro, Bomb Rush Cyberfunk and MGS V: Ground Zeroes each got one or two extra). The library now keeps the granted depot ids and the plan of an owned app skips the rest. Every game the Thor's client installed now plans to exactly its depots and manifests. The plan also reports `linuxBuild` (`common.oslist` lists linux), since the client installs a Linux build instead unless the game is mapped to a Proton. --- app/src/main/rust/stores/JNI.md | 9 ++-- app/src/main/rust/stores/src/steam/NOTICE.md | 2 + app/src/main/rust/stores/src/steam/install.rs | 10 +++- app/src/main/rust/stores/src/steam/library.rs | 18 ++++++- app/src/main/rust/stores/src/steam/plan.rs | 53 ++++++++++++++++--- 5 files changed, 79 insertions(+), 13 deletions(-) diff --git a/app/src/main/rust/stores/JNI.md b/app/src/main/rust/stores/JNI.md index 70424b7435..809f55f6b5 100644 --- a/app/src/main/rust/stores/JNI.md +++ b/app/src/main/rust/stores/JNI.md @@ -377,7 +377,7 @@ What `nativeStart` would install for `appId` with `language` (Steam's language n ```json {"ok":true,"appId":291550,"name":"Brawlhalla","installDir":"Brawlhalla","buildId":26465982, - "language":"english","downloadBytes":…,"installBytes":1594368732, + "language":"english","linuxBuild":false,"downloadBytes":…,"installBytes":1594368732, "depots":[{"depotId":291551,"manifestId":"4224536525702420323","size":1565156559,"dlcAppId":0}], "shared":[{"depotId":228988,"fromAppId":228980,"manifestId":"6645201662696499616","size":29212173}]} ``` @@ -386,13 +386,16 @@ Selection (what the client picks for a Windows game run through Proton): `config containing `windows`; `config.osarch` empty or `64` (`32` only when no `64` depot exists); `config.language` empty or the language (english when the game has no depot for the requested language but has english ones; the answer's `language` is the one used); no `lowviolence` -depots; DLC depots (`dlcappid`) only when the DLC is owned; `depotfromapp`/`sharedinstall` +depots; for an owned app, only depots one of the account's packages grants (`depotids`), as +the client installs no other; DLC depots (`dlcappid`) only when the DLC is owned; `depotfromapp`/`sharedinstall` depots are listed under `shared` with the owning app (e.g. 228980 Steamworks Common Redistributables), whose public manifest they use. Manifest gids are the public branch's, sizes come from PICS, `buildId` is the public branch's. `installBytes`/`downloadBytes` include the shared depots (they are not checked against what is already installed here). Errors: `not_signed_in`, `not_owned`, `appinfo unavailable`, `no installable Windows depot`. A free app -the account does not own yet is planned without asking for its license. +the account does not own yet is planned without asking for its license. `linuxBuild` is true +when `common.oslist` lists `linux`: the client then installs the Linux build unless the game is +mapped to a Proton, so the caller checks that mapping before installing. ### `nativeStart` diff --git a/app/src/main/rust/stores/src/steam/NOTICE.md b/app/src/main/rust/stores/src/steam/NOTICE.md index aee46e6408..49256ab3e1 100644 --- a/app/src/main/rust/stores/src/steam/NOTICE.md +++ b/app/src/main/rust/stores/src/steam/NOTICE.md @@ -42,6 +42,8 @@ Date of modification: 2026-11-07. session), `library`, `plan` (depot selection), `register` (app manifests, shared depots, `libraryfolders.vdf`, takeover of half-finished client downloads, uninstall), `kv` (Valve KeyValues writer), `install` (download orchestration) and a new JNI layer (`jni`). +- `library` records the depots the account's packages grant, and `plan` installs only those + (the client skips the rest, e.g. edition-only depots); `plan` flags apps with a Linux build. - Not ported: QR and password sign-in, auth sessions, friends, chat and chat images, persona, lobbies, cloud, user stats, achievements, inventory, published files and workshop, app and ownership tickets, playing-session control, the Wine bridge, the other stores' downloaders, diff --git a/app/src/main/rust/stores/src/steam/install.rs b/app/src/main/rust/stores/src/steam/install.rs index e46c940350..768903e73f 100644 --- a/app/src/main/rust/stores/src/steam/install.rs +++ b/app/src/main/rust/stores/src/steam/install.rs @@ -84,7 +84,15 @@ pub fn build_plan( } } } - let mut plan = crate::steam::plan::plan_app(app_id, &appinfo, &library.owned_apps, language)?; + // An app planned without its license (a free one, for sizes) has no granted depots to go by. + let owned_depots = library.owns(app_id).then_some(&library.owned_depots); + let mut plan = crate::steam::plan::plan_app( + app_id, + &appinfo, + &library.owned_apps, + owned_depots, + language, + )?; crate::steam::plan::resolve_shared(&mut plan, &|from| session.app_info(from)); Ok(plan) } diff --git a/app/src/main/rust/stores/src/steam/library.rs b/app/src/main/rust/stores/src/steam/library.rs index 93c5143f8b..4a8e17eeee 100644 --- a/app/src/main/rust/stores/src/steam/library.rs +++ b/app/src/main/rust/stores/src/steam/library.rs @@ -23,14 +23,16 @@ pub struct Game { pub struct Library { /// Every app id the account's licenses grant (games, DLC, tools …). pub owned_apps: HashSet, + /// Every depot id the account's licenses grant; the client installs no other depot of an app. + pub owned_depots: HashSet, games: Option>, } -pub fn package_app_ids(buffer: &[u8]) -> Vec { +fn package_ids(buffer: &[u8], key: &str) -> Vec { let Some((_id, root)) = vdf::parse_binary_package(buffer) else { return Vec::new(); }; - root.child("appids") + root.child(key) .map(|node| { node.children .iter() @@ -41,6 +43,14 @@ pub fn package_app_ids(buffer: &[u8]) -> Vec { .unwrap_or_default() } +pub fn package_app_ids(buffer: &[u8]) -> Vec { + package_ids(buffer, "appids") +} + +pub fn package_depot_ids(buffer: &[u8]) -> Vec { + package_ids(buffer, "depotids") +} + /// A library entry for an app, or `None` when it is not a game. pub fn game_from_appinfo(app_id: u32, appinfo: &KVNode) -> Option { let info = crate::steam::plan::appinfo_root(appinfo); @@ -104,6 +114,7 @@ impl Library { let mut package_ids: Vec = tokens.keys().copied().collect(); package_ids.sort_unstable(); let mut owned_apps = HashSet::new(); + let mut owned_depots = HashSet::new(); for batch in package_ids.chunks(PACKAGE_BATCH) { let request = batch .iter() @@ -117,6 +128,7 @@ impl Library { .ok_or_else(|| "package info request failed".to_string())?; for package in &response.packages { owned_apps.extend(package_app_ids(&package.buffer)); + owned_depots.extend(package_depot_ids(&package.buffer)); } } crate::steam::log(&format!( @@ -127,6 +139,7 @@ impl Library { )); Ok(Library { owned_apps, + owned_depots, games: None, }) } @@ -186,6 +199,7 @@ impl Library { pub fn with_games(&self, games: Vec) -> Library { Library { owned_apps: self.owned_apps.clone(), + owned_depots: self.owned_depots.clone(), games: Some(games), } } diff --git a/app/src/main/rust/stores/src/steam/plan.rs b/app/src/main/rust/stores/src/steam/plan.rs index 51a23e5e45..01c81f05b7 100644 --- a/app/src/main/rust/stores/src/steam/plan.rs +++ b/app/src/main/rust/stores/src/steam/plan.rs @@ -50,6 +50,9 @@ pub struct AppPlan { pub build_id: u64, /// The language written to the app manifest (the requested one, or english, see above). pub language: String, + /// The app ships a Linux build (`common.oslist`). The client installs it, not these Windows + /// depots, unless the game is mapped to a Proton; the caller checks that mapping. + pub linux_build: bool, pub depots: Vec, pub shared_refs: Vec, pub shared: Vec, @@ -74,6 +77,7 @@ impl AppPlan { "installDir": self.install_dir, "buildId": self.build_id, "language": self.language, + "linuxBuild": self.linux_build, "downloadBytes": self.download_bytes(), "installBytes": self.install_bytes(), "depots": self.depots.iter().map(|d| json!({ @@ -236,6 +240,7 @@ pub fn plan_app( app_id: u32, appinfo: &KVNode, owned_apps: &HashSet, + owned_depots: Option<&HashSet>, language: &str, ) -> Result { let appinfo = appinfo_root(appinfo); @@ -246,6 +251,9 @@ pub fn plan_app( install_dir: app_install_dir(appinfo), build_id: public_build_id(appinfo), language: language.clone(), + linux_build: str_at(appinfo, &["common", "oslist"]) + .split(',') + .any(|os| os.trim().eq_ignore_ascii_case("linux")), ..Default::default() }; if plan.install_dir.is_empty() { @@ -272,15 +280,19 @@ pub fn plan_app( if dlc != 0 && !owned_apps.contains(&dlc) { continue; } + let from_app = uint_at(depot, &["depotfromapp"]) as u32; + let shared_install = str_at(depot, &["sharedinstall"]) == "1"; + let is_shared = from_app != 0 || shared_install; + if !is_shared && owned_depots.is_some_and(|owned| !owned.contains(&depot_id)) { + continue; + } let candidate = Candidate { depot_id, node: depot, arch: arch_of(config), language: language_of(config), }; - let from_app = uint_at(depot, &["depotfromapp"]) as u32; - let shared_install = str_at(depot, &["sharedinstall"]) == "1"; - if from_app != 0 || shared_install { + if is_shared { shared.push(candidate); } else { own.push(candidate); @@ -539,7 +551,7 @@ pub mod tests { #[test] fn picks_windows_64bit_language_and_shared_depots_like_the_client() { let info = parse(BRAWLHALLA); - let mut plan = plan_app(291550, &info, &HashSet::new(), "english").unwrap(); + let mut plan = plan_app(291550, &info, &HashSet::new(), None, "english").unwrap(); assert_eq!(plan.name, "Brawlhalla"); assert_eq!(plan.install_dir, "Brawlhalla"); assert_eq!(plan.build_id, 26465982); @@ -575,7 +587,7 @@ pub mod tests { fn owned_dlc_german_and_32bit_fallback() { let info = parse(BRAWLHALLA); let owned: HashSet = [291560].into_iter().collect(); - let plan = plan_app(291550, &info, &owned, "german").unwrap(); + let plan = plan_app(291550, &info, &owned, None, "german").unwrap(); let ids: Vec = plan.depots.iter().map(|d| d.depot_id).collect(); assert_eq!(ids, vec![291551, 291554, 291556]); assert_eq!(plan.depots[2].dlc_app_id, 291560); @@ -583,7 +595,7 @@ pub mod tests { let only32 = parse( r#""appinfo" { "config" { "installdir" "X" } "depots" { "1" { "config" { "osarch" "32" } "manifests" { "public" "5" } "maxsize" "10" } } }"#, ); - let plan = plan_app(1, &only32, &HashSet::new(), "english").unwrap(); + let plan = plan_app(1, &only32, &HashSet::new(), None, "english").unwrap(); assert_eq!(plan.depots[0].depot_id, 1); assert_eq!(plan.depots[0].manifest_id, 5); assert_eq!(plan.depots[0].size, 10); @@ -597,7 +609,7 @@ pub mod tests { "2" { "config" { "language" "english" } "manifests" { "public" { "gid" "2" "size" "1" } } } "3" { "config" { "language" "german" } "manifests" { "public" { "gid" "3" "size" "1" } } } } }"#, ); - let plan = plan_app(9, &info, &HashSet::new(), "koreana").unwrap(); + let plan = plan_app(9, &info, &HashSet::new(), None, "koreana").unwrap(); assert_eq!(plan.language, "english"); let ids: Vec = plan.depots.iter().map(|d| d.depot_id).collect(); assert_eq!(ids, vec![1, 2]); @@ -605,8 +617,35 @@ pub mod tests { 9, &parse(r#""appinfo" { "depots" { } }"#), &HashSet::new(), + None, "english" ) .is_err()); } + + #[test] + fn skips_depots_the_licenses_do_not_grant() { + let info = parse( + r#""appinfo" { "config" { "installdir" "X" } "depots" { + "11" { "config" { "oslist" "windows" } "manifests" { "public" { "gid" "1" "size" "1" } } } + "12" { "config" { "oslist" "windows" } "manifests" { "public" { "gid" "2" "size" "1" } } } + "13" { "config" { "oslist" "windows" } "depotfromapp" "228980" "sharedinstall" "1" } } }"#, + ); + let owned: HashSet = [11].into_iter().collect(); + let plan = plan_app(10, &info, &HashSet::new(), Some(&owned), "english").unwrap(); + let ids: Vec = plan.depots.iter().map(|d| d.depot_id).collect(); + assert_eq!(ids, vec![11]); + assert_eq!(plan.shared_refs.len(), 1); + let all = plan_app(10, &info, &HashSet::new(), None, "english").unwrap(); + assert_eq!(all.depots.len(), 2); + } + + #[test] + fn flags_a_linux_build() { + let info = parse( + r#""appinfo" { "common" { "oslist" "windows,linux" } "config" { "installdir" "X" } "depots" { + "1" { "config" { "oslist" "windows" } "manifests" { "public" { "gid" "1" "size" "1" } } } } }"#, + ); + assert!(plan_app(1, &info, &HashSet::new(), None, "english").unwrap().linux_build); + } }