From 42026b382f6e0ea0c022a7647ea92d7383f70098 Mon Sep 17 00:00:00 2001 From: maxjivi05 Date: Fri, 23 Oct 2026 23:11:17 -0400 Subject: [PATCH] fix: keep manifest launch arguments to the installed build and their own additions The manifest's arguments apply only when its build matches the installed version, only arguments the merge inserted are tracked as its own, escaped quotes split like a Windows command line, and the REDprelauncher rule needs Cyberpunk2077.exe beside it. --- .../launcher/stores/epic/EpicClientLibrary.kt | 10 +++-- app/src/main/rust/stores/JNI.md | 2 +- app/src/main/rust/stores/src/epic/launch.rs | 41 +++++++++++++------ app/src/main/rust/stores/src/epic/service.rs | 7 +++- .../launcher/stores/epic/EpicClientTest.kt | 5 +++ .../overlay/usr/local/bin/droiddeck-game-env | 5 ++- tools/tests/test_game_environment.py | 4 ++ 7 files changed, 56 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicClientLibrary.kt b/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicClientLibrary.kt index 65b5b5614c..4591b12e43 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicClientLibrary.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicClientLibrary.kt @@ -384,15 +384,19 @@ internal object EpicClientLibrary { private fun manifestArgs(install: Install, guid: String): List? { val manifest = File(install.folder, ".egstore/$guid.manifest").takeIf { it.isFile } ?: return null - val args = EpicNative.inspect(manifest.readBytes(), JSONObject().put("op", "launch"))?.optJSONArray("args") ?: return null + val launch = EpicNative.inspect(manifest.readBytes(), JSONObject().put("op", "launch")) ?: return null + val build = launch.optString("buildVersion") + if (install.version.isNotEmpty() && build.isNotEmpty() && build != install.version) return null + val args = launch.optJSONArray("args") ?: return null return List(args.length()) { args.optString(it) }.filter { it.isNotEmpty() } } internal fun withLaunchArgs(sidecar: StoreGameSidecar, args: List): StoreGameSidecar { val previous = sidecar.extra[LAUNCH_ARGS]?.split('\n')?.filter { it.isNotEmpty() }.orEmpty() val kept = sidecar.args.filterNot { it in previous } - val next = kept + args.filterNot { it in kept } - val extra = LinkedHashMap(sidecar.extra).apply { if (args.isEmpty()) remove(LAUNCH_ARGS) else put(LAUNCH_ARGS, args.joinToString("\n")) } + val added = args.filterNot { it in kept } + val next = kept + added + val extra = LinkedHashMap(sidecar.extra).apply { if (added.isEmpty()) remove(LAUNCH_ARGS) else put(LAUNCH_ARGS, added.joinToString("\n")) } if (next == sidecar.args && extra == sidecar.extra) return sidecar return sidecar.copy(args = next, extra = extra) } diff --git a/app/src/main/rust/stores/JNI.md b/app/src/main/rust/stores/JNI.md index 9ea0ae8305..b160ace3c1 100644 --- a/app/src/main/rust/stores/JNI.md +++ b/app/src/main/rust/stores/JNI.md @@ -167,7 +167,7 @@ synchronous on the calling thread (network calls block: call them off the main t body → `{"ok": true}` or an error. `nativeInspect` parses manifest bytes: `{"op":"summary"}` → `buildVersion`, `launchExe`, `prereqName`, `prereqPath`, `prereqRead`, `files[]` (`path`, `size`, `tags`); `{"op":"select","tags":[…]}` → `indices[]` of the files an install with those tags gets; -`{"op":"launch"}` → the manifest's `command` line and its `args[]`. +`{"op":"launch"}` → the manifest's `buildVersion`, its `command` line and the `args[]` split from it. ### `nativeInstall` diff --git a/app/src/main/rust/stores/src/epic/launch.rs b/app/src/main/rust/stores/src/epic/launch.rs index d2afe582a2..24e35db608 100644 --- a/app/src/main/rust/stores/src/epic/launch.rs +++ b/app/src/main/rust/stores/src/epic/launch.rs @@ -44,24 +44,37 @@ pub fn split_command(command: &str) -> Vec { let mut current = String::new(); let mut quoted = false; let mut started = false; + let mut slashes = 0usize; for c in command.chars().map(|c| if c == '\t' { ' ' } else { c }).filter(|&c| c >= ' ' && c != '\u{7f}') { - match c { - '"' => { + if c == '\\' { + slashes += 1; + started = true; + continue; + } + if c == '"' { + current.extend(std::iter::repeat('\\').take(slashes / 2)); + if slashes % 2 == 1 { + current.push('"'); + } else { quoted = !quoted; - started = true; } - ' ' if !quoted => { - if started { - args.push(std::mem::take(&mut current)); - started = false; - } - } - _ => { - current.push(c); - started = true; + slashes = 0; + started = true; + continue; + } + current.extend(std::iter::repeat('\\').take(slashes)); + slashes = 0; + if c == ' ' && !quoted { + if started { + args.push(std::mem::take(&mut current)); + started = false; } + } else { + current.push(c); + started = true; } } + current.extend(std::iter::repeat('\\').take(slashes)); if started { args.push(current); } @@ -80,6 +93,10 @@ mod tests { split_command(" -a\t-b=\"c d\" \"-e f\" \"\" -g\r\n"), vec!["-a", "-b=c d", "-e f", "-g"] ); + assert_eq!( + split_command(r#"-name="a\" b" -dir=C:\Games\ "-q=\\" -r"#), + vec![r#"-name=a" b"#, r"-dir=C:\Games\", r"-q=\", "-r"] + ); assert!(split_command(" ").is_empty()); } diff --git a/app/src/main/rust/stores/src/epic/service.rs b/app/src/main/rust/stores/src/epic/service.rs index 79cd29d3fd..7248342866 100644 --- a/app/src/main/rust/stores/src/epic/service.rs +++ b/app/src/main/rust/stores/src/epic/service.rs @@ -160,7 +160,11 @@ pub fn inspect(bytes: &[u8], request: &str) -> String { .map(|a| a.iter().filter_map(|t| t.as_str()).map(str::to_string).collect()); json!({ "indices": locale::select(&m.files, tags.as_deref()) }) } - "launch" => json!({ "command": m.launch_command, "args": launch::split_command(&m.launch_command) }), + "launch" => json!({ + "buildVersion": m.build_version, + "command": m.launch_command, + "args": launch::split_command(&m.launch_command), + }), _ => json!({ "buildVersion": m.build_version, "launchExe": m.launch_exe, @@ -212,6 +216,7 @@ mod tests { let v: Value = serde_json::from_str(&inspect(&bytes, r#"{"op":"select","tags":["English"]}"#)).unwrap(); assert_eq!(v["indices"], json!([0])); let v: Value = serde_json::from_str(&inspect(&bytes, r#"{"op":"launch"}"#)).unwrap(); + assert_eq!(v["buildVersion"], "b"); assert_eq!(v["command"], "-PCStore=EGS \"-log=a b.txt\""); assert_eq!(v["args"], json!(["-PCStore=EGS", "-log=a b.txt"])); let v: Value = serde_json::from_str(&inspect(b"nonsense", "{}")).unwrap(); diff --git a/app/src/test/java/com/droiddeck/launcher/stores/epic/EpicClientTest.kt b/app/src/test/java/com/droiddeck/launcher/stores/epic/EpicClientTest.kt index de8a440283..c0687db98c 100644 --- a/app/src/test/java/com/droiddeck/launcher/stores/epic/EpicClientTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/stores/epic/EpicClientTest.kt @@ -300,6 +300,11 @@ class EpicClientTest { val reinstalled = first.copy(args = epicArgs) assertEquals(epicArgs + "-PCStore=EGS", EpicClientLibrary.withLaunchArgs(reinstalled, listOf("-PCStore=EGS")).args) assertTrue(EpicClientLibrary.withLaunchArgs(installed, emptyList()) === installed) + val own = installed.copy(args = epicArgs + "-PCStore=EGS") + assertTrue(EpicClientLibrary.withLaunchArgs(own, listOf("-PCStore=EGS")) === own) + val ownUpdated = EpicClientLibrary.withLaunchArgs(own, listOf("-PCStore=EGS", "-log=a b.txt")) + assertEquals(epicArgs + listOf("-PCStore=EGS", "-log=a b.txt"), ownUpdated.args) + assertEquals(epicArgs + "-PCStore=EGS", EpicClientLibrary.withLaunchArgs(ownUpdated, emptyList()).args) } @Test fun itemsDescribeTheInstallForTheLauncher() { diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env b/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env index 03707c1d70..53537c072f 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env @@ -129,7 +129,10 @@ def caravan_sandwitch_feature_level(game): @fix def cyberpunk_feature_level(game): - if game.stem in ("cyberpunk2077", "redprelauncher"): + if game.stem == "cyberpunk2077" or ( + game.stem == "redprelauncher" + and os.path.isfile(os.path.join(os.path.dirname(game.exe), "bin", "x64", "Cyberpunk2077.exe")) + ): return {"VKD3D_FEATURE_LEVEL": "12_1"}, [], "Cyberpunk 2077: D3D12 feature level 12_1" def skip_red_launcher(command): diff --git a/tools/tests/test_game_environment.py b/tools/tests/test_game_environment.py index 5e7cf1b56e..13b31f7435 100644 --- a/tools/tests/test_game_environment.py +++ b/tools/tests/test_game_environment.py @@ -384,6 +384,10 @@ class GameEnvironmentTest(unittest.TestCase): other.mkdir(parents=True) (other / "Other-Win64-Shipping.exe").touch() self.assertEqual(MODULE["engine_fixes"](str(other / "Other-Win64-Shipping.exe"), []), ({}, [], [])) + witcher = Path(tmp) / "The Witcher 3" + witcher.mkdir() + (witcher / "REDprelauncher.exe").touch() + self.assertNotIn("VKD3D_FEATURE_LEVEL", MODULE["engine_fixes"](str(witcher / "REDprelauncher.exe"), [])[0]) def test_unity_players_keep_tso_over_the_preset(self): with tempfile.TemporaryDirectory() as tmp: