fix: Epic games get their manifest launch command

Epic manifests carry a launch command next to the launch executable, which the Epic launcher passes to the game. It was read and dropped, so Caravan SandWitch never got -PCStore=EGS and quit with "started outside of any known PC store". The manifest's launch command now joins the game's arguments, including for games already installed.
This commit is contained in:
maxjivi05 authored and MaxsTechReview committed 2026-10-23 23:59:37 -04:00
1 parent 6e1621fe53
commit 46cd8e1777
6 files changed
+94 -4

No files matched your search

+2 -1
View File
@@ -166,7 +166,8 @@ synchronous on the calling thread (network calls block: call them off the main t
`cloud.read` (`url`) → the file. `null` = failed. `nativeSend` op: `cloud.write` (`url`) with the
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.
`tags`); `{"op":"select","tags":[…]}` → `indices[]` of the files an install with those tags gets;
`{"op":"launch"}` → the manifest's `command` line and its `args[]`.
### `nativeInstall`
@@ -39,10 +39,50 @@ pub fn arguments(d: &LaunchData) -> Vec<String> {
args
}
pub fn split_command(command: &str) -> Vec<String> {
let mut args = Vec::new();
let mut current = String::new();
let mut quoted = false;
let mut started = false;
for c in command.chars().map(|c| if c == '\t' { ' ' } else { c }).filter(|&c| c >= ' ' && c != '\u{7f}') {
match c {
'"' => {
quoted = !quoted;
started = true;
}
' ' if !quoted => {
if started {
args.push(std::mem::take(&mut current));
started = false;
}
}
_ => {
current.push(c);
started = true;
}
}
}
if started {
args.push(current);
}
args.retain(|a| !a.is_empty());
args
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn launch_command_splits_like_a_command_line() {
assert_eq!(split_command("-PCStore=EGS"), vec!["-PCStore=EGS"]);
assert_eq!(
split_command(" -a\t-b=\"c d\" \"-e f\" \"\" -g\r\n"),
vec!["-a", "-b=c d", "-e f", "-g"]
);
assert!(split_command(" ").is_empty());
}
#[test]
fn arguments_in_order() {
let args = arguments(&LaunchData {
@@ -68,6 +68,7 @@ pub struct Manifest {
pub version: i64,
pub build_version: String,
pub launch_exe: String,
pub launch_command: String,
pub prereq_name: String,
pub prereq_path: String,
pub prereq_read: bool,
@@ -279,6 +280,7 @@ fn parse_binary(bytes: &[u8]) -> Result<Manifest, String> {
version,
build_version: meta.build_version,
launch_exe: meta.launch_exe,
launch_command: meta.launch_command,
prereq_name: meta.prereq_name,
prereq_path: meta.prereq_path,
prereq_read: meta.complete,
@@ -292,6 +294,7 @@ fn parse_binary(bytes: &[u8]) -> Result<Manifest, String> {
struct Meta {
build_version: String,
launch_exe: String,
launch_command: String,
prereq_name: String,
prereq_path: String,
complete: bool,
@@ -308,7 +311,7 @@ fn read_meta(data: &[u8]) -> Meta {
r.fstring()?;
meta.build_version = r.fstring()?;
meta.launch_exe = normalise_path(&r.fstring()?);
r.fstring()?;
meta.launch_command = r.fstring()?;
let ids = r.count(4)?;
for _ in 0..ids {
r.fstring()?;
@@ -548,6 +551,7 @@ fn parse_json(bytes: &[u8]) -> Result<Manifest, String> {
version,
build_version: str_field("BuildVersionString"),
launch_exe: normalise_path(launch),
launch_command: str_field("LaunchCommand"),
prereq_name: str_field("PrereqName"),
prereq_path: normalise_path(&str_field("PrereqPath")),
prereq_read: true,
@@ -611,7 +615,7 @@ pub mod testing {
fstring(&mut meta, "App");
fstring(&mut meta, &m.build);
fstring(&mut meta, &m.exe);
fstring(&mut meta, "");
fstring(&mut meta, "-PCStore=EGS \"-log=a b.txt\"");
if let Some((name, path)) = &m.prereq {
meta.extend_from_slice(&1i32.to_le_bytes());
fstring(&mut meta, "prereq-id");
@@ -763,6 +767,7 @@ mod tests {
assert_eq!(m.chunk_folder(), "ChunksV4");
assert_eq!(m.build_version, "1.2.3-CL-99");
assert_eq!(m.launch_exe, "Binaries/Win64/Game.exe");
assert_eq!(m.launch_command, "-PCStore=EGS \"-log=a b.txt\"");
assert_eq!(m.prereq_name, "UE4 Prerequisites (x64)");
assert_eq!(m.prereq_path, "Engine/Extras/UE4PrereqSetup_x64.exe");
assert!(m.prereq_read);
@@ -851,6 +856,7 @@ mod tests {
let doc = r#"{
"ManifestFileVersion": "013000000000",
"LaunchExeString": "Bin\\Game.exe",
"LaunchCommand": "-PCStore=EGS",
"BuildVersionString": "++Game+Release-1.0",
"PrereqName": "Redist", "PrereqPath": "Redist\\setup.exe",
"ChunkHashList": {
@@ -872,6 +878,7 @@ mod tests {
assert_eq!(m.version, 13);
assert_eq!(m.chunk_folder(), "ChunksV3");
assert_eq!(m.launch_exe, "Bin/Game.exe");
assert_eq!(m.launch_command, "-PCStore=EGS");
assert!(m.prereq_read);
assert_eq!(m.prereq_path, "Redist/setup.exe");
assert_eq!(m.chunks.len(), 2);
@@ -160,6 +160,7 @@ 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) }),
_ => json!({
"buildVersion": m.build_version,
"launchExe": m.launch_exe,
@@ -210,6 +211,9 @@ mod tests {
assert_eq!(v["files"].as_array().unwrap().len(), 2);
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["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();
assert!(v["error"].is_string());
}