From 9ede1136907f2f4f00e639e63db24443ff14ae66 Mon Sep 17 00:00:00 2001 From: AliceWood <36452359+AliceWood@users.noreply.github.com> Date: Tue, 24 Nov 2026 21:27:22 +0300 Subject: [PATCH 1/2] app, hle: resolve title folders for xtp run --- Cargo.lock | 1 + README.md | 8 +- apps/xtp/Cargo.toml | 3 + apps/xtp/src/main.rs | 7 +- apps/xtp/src/run.rs | 189 ++++++++++++++++++++++++++++++++-- crates/xtp-hle/src/runtime.rs | 88 +++++++++++----- docs/dev/START_HERE.md | 2 +- 7 files changed, 259 insertions(+), 39 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e40d88f6..ea29f311 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -805,6 +805,7 @@ dependencies = [ "blake3", "clap", "memchr", + "tempfile", "walkdir", "xtp-core", "xtp-game", diff --git a/README.md b/README.md index ecf32d8d..5b31d4b4 100644 --- a/README.md +++ b/README.md @@ -66,9 +66,13 @@ Run the title: ```powershell cargo build --release -p xtp -target\release\xtp.exe run \ --execute +target\release\xtp.exe run "" --execute ``` +With a folder, `xtp run` selects an existing executable named in +`MicrosoftGame.config`. If none matches, it looks for a single `.exe` in +the folder. When several match, it lists them so you can pass one explicitly. + The window caption shows the framerate. Saves, settings and `crashes.log` are kept under the data folder (default `%LOCALAPPDATA%\xtp\data`), derived data under the cache folder. @@ -109,7 +113,7 @@ xtp census [paths...] [--missing] [--strict] xtp lib-exports [--list] xtp shader-info [paths...] [--verbose] [--disasm] xtp translate [paths...] [--validate] [--pipelines] [--list] [--jobs N] -xtp run [--execute] [--unimplemented trap|zero] [--strict] +xtp run [--execute] [--unimplemented trap|zero] [--strict] [--console series-s|series-x] [-- ] xtp config ``` diff --git a/apps/xtp/Cargo.toml b/apps/xtp/Cargo.toml index b48acc7d..6ff866df 100644 --- a/apps/xtp/Cargo.toml +++ b/apps/xtp/Cargo.toml @@ -20,6 +20,9 @@ memchr.workspace = true clap.workspace = true walkdir.workspace = true +[dev-dependencies] +tempfile.workspace = true + [features] # Debug-level logs and the debugging switches (frame capture, stack dumps, # the host debug layer, scripted keys). Off in a plain release build. diff --git a/apps/xtp/src/main.rs b/apps/xtp/src/main.rs index 5d56c84a..de85cccb 100644 --- a/apps/xtp/src/main.rs +++ b/apps/xtp/src/main.rs @@ -120,7 +120,8 @@ enum Command { }, /// Prepare, map and bind a title executable; with --execute, run it. Run { - exe: PathBuf, + /// A title executable or the folder containing MicrosoftGame.config. + target: PathBuf, /// What unimplemented imports do when called. #[arg(long, value_enum, default_value_t = Unimplemented::Trap)] unimplemented: Unimplemented, @@ -223,7 +224,7 @@ fn main() -> Result<()> { host_lanes, ), Command::Run { - exe, + target, unimplemented, strict, execute, @@ -233,7 +234,7 @@ fn main() -> Result<()> { } => { let env = std::env::var("XTP_CONSOLE").ok(); let console = Console::pick(console, env.as_deref())?; - run::run(&exe, unimplemented, strict, execute, console, autopilot) + run::run(&target, unimplemented, strict, execute, console, autopilot) } Command::Config => show_config(), } diff --git a/apps/xtp/src/run.rs b/apps/xtp/src/run.rs index a7bff89c..88c15139 100644 --- a/apps/xtp/src/run.rs +++ b/apps/xtp/src/run.rs @@ -4,9 +4,93 @@ use anyhow::{Context, Result}; use crate::{Console, Unimplemented}; +#[cfg(windows)] +struct RunTarget<'a> { + exe: PathBuf, + package_dir: &'a Path, + title: xtp_hle::runtime::Title, +} + +#[cfg(windows)] +fn resolve_target(path: &Path) -> Result<RunTarget<'_>> { + let folder = path.is_dir(); + let package_dir = if folder { + path + } else { + path.parent().unwrap_or(Path::new(".")) + }; + let manifest = + std::fs::read_to_string(package_dir.join("MicrosoftGame.config")).unwrap_or_default(); + let title = xtp_hle::runtime::Title::from_manifest(&manifest); + let exe = if folder { + pick_executable(package_dir, &title.executables)? + } else { + path.to_owned() + }; + Ok(RunTarget { + exe, + package_dir, + title, + }) +} + +#[cfg(windows)] +fn pick_executable(folder: &Path, configured: &[String]) -> Result<PathBuf> { + use std::path::Component; + + let is_exe = |p: &Path| { + p.extension() + .is_some_and(|ext| ext.eq_ignore_ascii_case("exe")) + }; + let root = folder + .canonicalize() + .with_context(|| format!("opening {}", folder.display()))?; + let mut candidates = Vec::new(); + for name in configured { + let path = Path::new(name); + if is_exe(path) + && path + .components() + .all(|c| matches!(c, Component::Normal(_) | Component::CurDir)) + && let Ok(file) = root.join(path).canonicalize() + && let Ok(relative) = file.strip_prefix(&root) + && file.is_file() + { + candidates.push(relative.to_owned()); + } + } + if candidates.is_empty() { + for entry in std::fs::read_dir(folder) + .with_context(|| format!("listing executables in {}", folder.display()))? + { + let entry = entry?; + if is_exe(&entry.path()) && entry.file_type()?.is_file() { + candidates.push(PathBuf::from(entry.file_name())); + } + } + } + candidates.sort(); + candidates.dedup(); + match candidates.as_slice() { + [exe] => Ok(folder.join(exe)), + [] => anyhow::bail!("no executable found in {}", folder.display()), + _ => { + let names = candidates + .iter() + .map(|p| p.display().to_string()) + .collect::<Vec<_>>(); + anyhow::bail!( + "multiple executables in {}. Pass one to xtp run:\n {}", + folder.display(), + names.join("\n ") + ) + } + } +} + #[cfg(windows)] pub fn run( - exe: &Path, + target: &Path, unimplemented: Unimplemented, strict: bool, execute: bool, @@ -30,7 +114,12 @@ pub fn run( bindings: input.bindings.clone(), }) .map_err(|e| anyhow::anyhow!("[input] in the config: {e}"))?; - let original = std::fs::read(exe).with_context(|| format!("reading {}", exe.display()))?; + let RunTarget { + exe, + package_dir, + title, + } = resolve_target(target)?; + let original = std::fs::read(&exe).with_context(|| format!("reading {}", exe.display()))?; let prepared = xtp_loader::prepare(&original)?; let hash = prepared.original_hash.to_hex(); match xtp_game::identify(&hash) { @@ -44,7 +133,7 @@ pub fn run( // SAFETY: just mapped from the executable `hash` names; no title code has run. unsafe { xtp_game::watchdog::apply_if_asked(&hash, image.base(), image.info().size_of_image) }; xtp_hle::runtime::set_main_image(image.base()); - xtp_hle::runtime::set_image_path(image.base(), exe); + xtp_hle::runtime::set_image_path(image.base(), &exe); println!( "mapped at {:#x} (preferred {:#x})", image.base(), @@ -57,10 +146,6 @@ pub fn run( }); let wanted = |dll: &str| title_dll(&resolver.host, dll); let title_dir = exe.parent().unwrap_or(Path::new(".")); - // A missing manifest leaves id 0 and no storage quota. - let manifest = - std::fs::read_to_string(title_dir.join("MicrosoftGame.config")).unwrap_or_default(); - let title = xtp_hle::runtime::Title::from_manifest(&manifest); let storage = cfg.data_subdir(&format!("{:08X}/storage", title.id))?; println!( "title {:08X}, storage {} ({} MB)", @@ -69,7 +154,7 @@ pub fn run( title.storage_bytes >> 20 ); // The console's fixed drives: the package as `G:`, temporary files `T:`. - xtp_hle::modules::files::mount_at('G', title_dir); + xtp_hle::modules::files::mount_at('G', package_dir); let temp = cfg.data_subdir(&format!("{:08X}/temp", title.id))?; xtp_hle::modules::files::mount_at('T', &temp); xtp_hle::runtime::set_title(xtp_hle::runtime::Title { storage, ..title }); @@ -327,8 +412,96 @@ impl LoaderLock { #[cfg(all(test, windows))] mod tests { + use std::fs; use std::sync::{Arc, Mutex}; + use super::resolve_target; + + #[test] + fn folder_prefers_the_configured_executable() { + let dir = tempfile::tempdir().unwrap(); + let root = dir.path(); + fs::create_dir(root.join("bin")).unwrap(); + let selected = root.join("bin").join("Title & Tools.exe"); + fs::write(&selected, []).unwrap(); + fs::write(root.join("Helper.exe"), []).unwrap(); + fs::write( + root.join("MicrosoftGame.config"), + r#"<Game><TitleId>2A</TitleId> + <!-- <ExecutableList><Executable Name="Helper.exe"/></ExecutableList> --> + <Other><Executable Name="Helper.exe"/></Other> + <ExecutableList><Executable DisplayName="A > B" Name = 'bin/Title & Tools.exe'/> + </ExecutableList></Game>"#, + ) + .unwrap(); + let target = resolve_target(root).unwrap(); + assert_eq!(target.exe, selected); + assert_eq!(target.package_dir, root); + assert_eq!(target.title.id, 42); + } + + #[test] + fn folder_falls_back_to_its_only_executable() { + let dir = tempfile::tempdir().unwrap(); + let root = dir.path(); + let exe = root.join("Only.EXE"); + fs::write(&exe, []).unwrap(); + fs::create_dir(root.join("not-a-file.exe")).unwrap(); + assert_eq!(resolve_target(root).unwrap().exe, exe); + fs::write( + root.join("MicrosoftGame.config"), + r#"<Game><ExecutableList><Executable Name="missing.exe"/></ExecutableList></Game>"#, + ) + .unwrap(); + assert_eq!(resolve_target(root).unwrap().exe, exe); + } + + #[test] + fn ambiguous_folder_lists_candidates_and_accepts_an_explicit_path() { + let dir = tempfile::tempdir().unwrap(); + let root = dir.path(); + for name in ["B.exe", "A.exe"] { + fs::write(root.join(name), []).unwrap(); + } + let error = resolve_target(root).err().unwrap().to_string(); + assert!(error.ends_with("\n A.exe\n B.exe"), "{error}"); + let exe = root.join("B.exe"); + assert_eq!(resolve_target(&exe).unwrap().exe, exe); + } + + #[test] + fn several_configured_executables_list_only_the_matches() { + let dir = tempfile::tempdir().unwrap(); + let root = dir.path(); + for name in ["Tool.exe", "A.exe", "B.exe"] { + fs::write(root.join(name), []).unwrap(); + } + fs::write( + root.join("MicrosoftGame.config"), + r#"<Game><ExecutableList><Executable Name="B.exe"/><Executable Name="A.exe"/> + <Executable Name="B.exe"/></ExecutableList></Game>"#, + ) + .unwrap(); + let error = resolve_target(root).err().unwrap().to_string(); + assert!(error.ends_with("\n A.exe\n B.exe"), "{error}"); + } + + #[test] + fn empty_folder_does_not_follow_a_manifest_outside_the_package() { + let dir = tempfile::tempdir().unwrap(); + let root = dir.path().join("package"); + fs::create_dir(&root).unwrap(); + fs::write(dir.path().join("Outside.exe"), []).unwrap(); + fs::write( + root.join("MicrosoftGame.config"), + r#"<Game><ExecutableList><Executable Name="../Outside.exe"/></ExecutableList></Game>"#, + ) + .unwrap(); + let error = resolve_target(&root).err().unwrap().to_string(); + assert!(error.contains("no executable found"), "{error}"); + assert!(error.contains(root.to_str().unwrap()), "{error}"); + } + #[test] fn loader_lock_is_reentrant_and_exclusive() { let lock = Arc::new(super::LoaderLock::default()); diff --git a/crates/xtp-hle/src/runtime.rs b/crates/xtp-hle/src/runtime.rs index ea76fd14..7ac08af1 100644 --- a/crates/xtp-hle/src/runtime.rs +++ b/crates/xtp-hle/src/runtime.rs @@ -78,6 +78,8 @@ pub struct Title { pub id: u32, /// The store's product id (empty if the manifest has none). pub store_id: String, + /// Package-relative executable names in the manifest's executable list. + pub executables: Vec<String>, /// Persistent local storage: our folder for it and the title's quota. /// Game saves live beside it ([`Title::saves`]). pub storage: PathBuf, @@ -85,21 +87,26 @@ pub struct Title { } impl Title { - /// Id, store id and storage quota from the manifest (zero or empty - /// where it has none); the storage folder is left for the caller. + /// Read the title IDs, executable list and storage quota. The caller + /// supplies the storage folder. pub fn from_manifest(text: &str) -> Title { let elements = elements(text); let get = |path: &str| { elements .iter() - .find(|(p, _)| p == path) - .map(|(_, text)| text.as_str()) + .find(|e| e.path == path) + .map(|e| e.text.as_str()) }; let id = get("Game/TitleId").and_then(|v| u32::from_str_radix(v, 16).ok()); let storage_mb = get("Game/PersistentLocalStorage/SizeMB").and_then(|v| v.parse().ok()); Title { id: id.unwrap_or(0), store_id: get("Game/StoreId").unwrap_or_default().to_owned(), + executables: elements + .iter() + .filter(|e| e.path == "Game/ExecutableList/Executable") + .filter_map(|e| attribute(e.attributes, "Name")) + .collect(), storage: PathBuf::new(), storage_bytes: storage_mb.unwrap_or(0) << 20, } @@ -112,11 +119,40 @@ impl Title { } } -/// Each element of an XML text as its path from the root (`Game/TitleId`) -/// and its trimmed text up to the first child, the predefined entities -/// decoded; comments, CDATA sections, declarations and attributes are -/// skipped. -fn elements(text: &str) -> Vec<(String, String)> { +struct Element<'a> { + path: String, + text: String, + attributes: &'a str, +} + +fn unescape(text: &str) -> String { + [ + ("<", "<"), + (">", ">"), + (""", "\""), + ("'", "'"), + ("&", "&"), + ] + .iter() + .fold(text.to_owned(), |s, (entity, c)| s.replace(entity, c)) +} + +fn attribute(mut attributes: &str, key: &str) -> Option<String> { + loop { + let (name, rest) = attributes.split_once('=')?; + let rest = rest.trim_start(); + let quote = rest.chars().next().filter(|c| matches!(c, '"' | '\''))?; + let (value, tail) = rest[1..].split_once(quote)?; + if name.trim() == key { + return Some(unescape(value)); + } + attributes = tail; + } +} + +/// Each element's path from the root, its attributes and its trimmed text +/// up to the first child. Skip comments, CDATA sections and declarations. +fn elements(text: &str) -> Vec<Element<'_>> { let mut out = Vec::new(); let mut path: Vec<&str> = Vec::new(); let mut rest = text; @@ -127,7 +163,17 @@ fn elements(text: &str) -> Vec<(String, String)> { } else if rest.starts_with("<![CDATA[") { rest.find("]]>").map(|e| e + 3) } else { - rest.find('>').map(|e| e + 1) + // A quoted attribute may itself contain a '>'. + let mut quote = None; + rest.char_indices().find_map(|(i, c)| { + match quote { + Some(q) if c == q => quote = None, + None if matches!(c, '"' | '\'') => quote = Some(c), + None if c == '>' => return Some(i + 1), + _ => {} + } + None + }) }; let Some(end) = end else { break }; let tag = &rest[1..end - 1]; @@ -142,23 +188,15 @@ fn elements(text: &str) -> Vec<(String, String)> { continue; } let closed = tag.ends_with('/'); - let name = tag - .trim_end_matches('/') - .split_whitespace() - .next() - .unwrap_or(""); + let tag = tag.trim_end_matches('/'); + let (name, attributes) = tag.split_once(char::is_whitespace).unwrap_or((tag, "")); path.push(name); let body = rest[..rest.find('<').unwrap_or(rest.len())].trim(); - let body = [ - ("<", "<"), - (">", ">"), - (""", "\""), - ("'", "'"), - ("&", "&"), - ] - .iter() - .fold(body.to_owned(), |b, (entity, c)| b.replace(entity, c)); - out.push((path.join("/"), body)); + out.push(Element { + path: path.join("/"), + text: unescape(body), + attributes, + }); if closed { path.pop(); } diff --git a/docs/dev/START_HERE.md b/docs/dev/START_HERE.md index 9b65c6b2..75a4793b 100644 --- a/docs/dev/START_HERE.md +++ b/docs/dev/START_HERE.md @@ -77,7 +77,7 @@ any of it into the repository, and the tools refuse to write below it. ```powershell cargo build --release -p xtp - target\release\xtp.exe run <game dir>\<the title's exe> --execute + target\release\xtp.exe run "<game dir>" --execute ``` For debugging aids, build `--profile diag --features diagnostics`; the From eb05f4e7c0cb216966f7610b15eeb1485e6b769d Mon Sep 17 00:00:00 2001 From: AliceWood <36452359+AliceWood@users.noreply.github.com> Date: Tue, 24 Nov 2026 21:50:26 +0300 Subject: [PATCH 2/2] app, hle: explain why manifest executables were skipped --- README.md | 3 +- apps/xtp/src/main.rs | 3 +- apps/xtp/src/run.rs | 79 +++++++++++++++++++++++++++-------- apps/xtp/tests/run_folder.rs | 27 ++++++++++++ crates/xtp-hle/src/runtime.rs | 13 +++++- docs/dev/autopilot.md | 2 +- 6 files changed, 105 insertions(+), 22 deletions(-) create mode 100644 apps/xtp/tests/run_folder.rs diff --git a/README.md b/README.md index 5b31d4b4..e0ad043b 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,8 @@ target\release\xtp.exe run "<game dir>" --execute With a folder, `xtp run` selects an existing executable named in `MicrosoftGame.config`. If none matches, it looks for a single `.exe` in -the folder. When several match, it lists them so you can pass one explicitly. +the folder and reports why it skipped any named entries. When several match, +it lists them so you can pass one explicitly. The window caption shows the framerate. Saves, settings and `crashes.log` are kept under the data folder (default `%LOCALAPPDATA%\xtp\data`), derived diff --git a/apps/xtp/src/main.rs b/apps/xtp/src/main.rs index de85cccb..dd770acf 100644 --- a/apps/xtp/src/main.rs +++ b/apps/xtp/src/main.rs @@ -120,7 +120,8 @@ enum Command { }, /// Prepare, map and bind a title executable; with --execute, run it. Run { - /// A title executable or the folder containing MicrosoftGame.config. + /// A title executable or a package folder with a manifest or a single .exe. + #[arg(value_name = "EXE|FOLDER")] target: PathBuf, /// What unimplemented imports do when called. #[arg(long, value_enum, default_value_t = Unimplemented::Trap)] diff --git a/apps/xtp/src/run.rs b/apps/xtp/src/run.rs index 88c15139..5d0e58cf 100644 --- a/apps/xtp/src/run.rs +++ b/apps/xtp/src/run.rs @@ -19,8 +19,15 @@ fn resolve_target(path: &Path) -> Result<RunTarget<'_>> { } else { path.parent().unwrap_or(Path::new(".")) }; - let manifest = - std::fs::read_to_string(package_dir.join("MicrosoftGame.config")).unwrap_or_default(); + let manifest_path = package_dir.join("MicrosoftGame.config"); + let manifest = match std::fs::read_to_string(&manifest_path) { + Ok(text) => text, + Err(e) if e.kind() == std::io::ErrorKind::NotFound => String::new(), + Err(e) => { + eprintln!("warning: could not read {}: {e}", manifest_path.display()); + String::new() + } + }; let title = xtp_hle::runtime::Title::from_manifest(&manifest); let exe = if folder { pick_executable(package_dir, &title.executables)? @@ -35,28 +42,41 @@ fn resolve_target(path: &Path) -> Result<RunTarget<'_>> { } #[cfg(windows)] -fn pick_executable(folder: &Path, configured: &[String]) -> Result<PathBuf> { +fn configured_executable(root: &Path, name: &str) -> Result<PathBuf> { use std::path::Component; - let is_exe = |p: &Path| { - p.extension() - .is_some_and(|ext| ext.eq_ignore_ascii_case("exe")) - }; + let path = Path::new(name); + anyhow::ensure!(is_exe(path), "expected an .exe extension"); + anyhow::ensure!( + path.components() + .all(|c| matches!(c, Component::Normal(_) | Component::CurDir)), + "expected a path inside the package" + ); + let file = root.join(path).canonicalize()?; + let relative = file + .strip_prefix(root) + .context("resolves outside the package")?; + anyhow::ensure!(file.is_file(), "not a regular file"); + Ok(relative.to_owned()) +} + +#[cfg(windows)] +fn is_exe(path: &Path) -> bool { + path.extension() + .is_some_and(|ext| ext.eq_ignore_ascii_case("exe")) +} + +#[cfg(windows)] +fn pick_executable(folder: &Path, configured: &[String]) -> Result<PathBuf> { let root = folder .canonicalize() .with_context(|| format!("opening {}", folder.display()))?; let mut candidates = Vec::new(); + let mut skipped = Vec::new(); for name in configured { - let path = Path::new(name); - if is_exe(path) - && path - .components() - .all(|c| matches!(c, Component::Normal(_) | Component::CurDir)) - && let Ok(file) = root.join(path).canonicalize() - && let Ok(relative) = file.strip_prefix(&root) - && file.is_file() - { - candidates.push(relative.to_owned()); + match configured_executable(&root, name) { + Ok(path) => candidates.push(path), + Err(e) => skipped.push(format!("{name:?}: {e}")), } } if candidates.is_empty() { @@ -68,6 +88,19 @@ fn pick_executable(folder: &Path, configured: &[String]) -> Result<PathBuf> { candidates.push(PathBuf::from(entry.file_name())); } } + if !skipped.is_empty() { + let details = skipped.join("\n "); + if candidates.is_empty() { + anyhow::bail!( + "no executable found in {}. MicrosoftGame.config entries skipped:\n {details}", + folder.display() + ); + } + eprintln!( + "warning: using the top-level .exe search in {}. MicrosoftGame.config entries skipped:\n {details}", + folder.display() + ); + } } candidates.sort(); candidates.dedup(); @@ -494,11 +527,21 @@ mod tests { fs::write(dir.path().join("Outside.exe"), []).unwrap(); fs::write( root.join("MicrosoftGame.config"), - r#"<Game><ExecutableList><Executable Name="../Outside.exe"/></ExecutableList></Game>"#, + r#"<Game><ExecutableList><Executable Name="../Outside.exe"/><Executable Name="readme.txt"/> + <Executable Name="missing.exe"/></ExecutableList></Game>"#, ) .unwrap(); let error = resolve_target(&root).err().unwrap().to_string(); assert!(error.contains("no executable found"), "{error}"); + for reason in [ + "Outside.exe", + "inside the package", + "readme.txt", + ".exe extension", + "missing.exe", + ] { + assert!(error.contains(reason), "{error}"); + } assert!(error.contains(root.to_str().unwrap()), "{error}"); } diff --git a/apps/xtp/tests/run_folder.rs b/apps/xtp/tests/run_folder.rs new file mode 100644 index 00000000..0be8b231 --- /dev/null +++ b/apps/xtp/tests/run_folder.rs @@ -0,0 +1,27 @@ +#![cfg(windows)] + +#[test] +fn warns_before_falling_back_from_unusable_manifest_entries() { + let dir = tempfile::tempdir().unwrap(); + std::fs::write(dir.path().join("Fallback.exe"), b"synthetic non-PE").unwrap(); + std::fs::write( + dir.path().join("MicrosoftGame.config"), + r#"<Game><ExecutableList><Executable Name="missing.exe"/> + <Executable Name="notes.txt"/></ExecutableList></Game>"#, + ) + .unwrap(); + let output = std::process::Command::new(env!("CARGO_BIN_EXE_xtp")) + .current_dir(dir.path()) + .args(["run", "."]) + .output() + .unwrap(); + let stderr = String::from_utf8_lossy(&output.stderr); + assert!( + stderr.contains("warning:") && stderr.contains("MicrosoftGame.config"), + "{stderr}" + ); + assert!( + stderr.contains("missing.exe") && stderr.contains("notes.txt"), + "{stderr}" + ); +} diff --git a/crates/xtp-hle/src/runtime.rs b/crates/xtp-hle/src/runtime.rs index 7ac08af1..a73f7a16 100644 --- a/crates/xtp-hle/src/runtime.rs +++ b/crates/xtp-hle/src/runtime.rs @@ -71,7 +71,7 @@ pub fn load_title_dll(file: &str) -> Result<Option<usize>, String> { TITLE_DLL_LOADER.get().map_or(Ok(None), |load| load(file)) } -/// What the title's manifest (`MicrosoftGame.config` beside its executable) +/// What the title's manifest (`MicrosoftGame.config` in its package root) /// says about it, and where its persistent local storage lives. #[derive(Debug, Clone, Default, PartialEq, Eq)] pub struct Title { @@ -254,6 +254,17 @@ pub fn use_console_timers() { mod tests { use super::*; + #[test] + fn reads_executable_names_only_in_the_package_list() { + let manifest = r#"<Game><Executable Name="outside.exe"/> + <ExecutableList><Executable Description="x > y" Name = 'R&D Tools.exe'/> + <Executable Name="Second.exe"/></ExecutableList></Game>"#; + assert_eq!( + Title::from_manifest(manifest).executables, + ["R&D Tools.exe", "Second.exe"] + ); + } + #[test] fn reads_title_id_store_id_and_storage_quota() { let text = "\u{feff}<?xml version=\"1.0\"?>\n<Game configVersion=\"1\">\ diff --git a/docs/dev/autopilot.md b/docs/dev/autopilot.md index 162ce020..61fd3a70 100644 --- a/docs/dev/autopilot.md +++ b/docs/dev/autopilot.md @@ -8,7 +8,7 @@ start-up or loading gets faster or slower. ```text cargo xtask play # from the golden save to gameplay, then you play cargo xtask play --measure 60 # 60 s of gameplay, then a frame-rate summary -xtp run <exe> --execute --autopilot autopilot/gameplay.txt +xtp run <exe|folder> --execute --autopilot autopilot/gameplay.txt ``` The code is in `crates/xtp-hle/src/modules/autopilot/` (`script.rs` the