aboutsummaryrefslogtreecommitdiff
path: root/apps/fparkan-game/src
diff options
context:
space:
mode:
Diffstat (limited to 'apps/fparkan-game/src')
-rw-r--r--apps/fparkan-game/src/main.rs8
-rw-r--r--apps/fparkan-game/src/mission_startup.rs14
2 files changed, 20 insertions, 2 deletions
diff --git a/apps/fparkan-game/src/main.rs b/apps/fparkan-game/src/main.rs
index cfae3ffb..2129f82c 100644
--- a/apps/fparkan-game/src/main.rs
+++ b/apps/fparkan-game/src/main.rs
@@ -11557,7 +11557,11 @@ impl Args {
_ => return Err(usage()),
}
}
- let root = root.ok_or_else(|| "missing --root".to_string())?;
+ let root = match root {
+ Some(root) => root,
+ None => std::env::current_dir()
+ .map_err(|error| format!("cannot resolve the game data directory: {error}"))?,
+ };
let mission = match (list_missions, mission) {
(true, None) if sim_report_ms.is_none() => String::new(),
(true, _) => {
@@ -11612,7 +11616,7 @@ impl Args {
}
fn usage() -> String {
- "usage: fparkan-game --root <path> --list-missions\n fparkan-game --root <path> --mission <number|path> --sim-report <seconds>\n fparkan-game --root <path> --mission <number|path> [--build-scheme <Unit DAT path> [--build-part OLD=NEW]...] [--viewer] [--frames <n>] [--atmosphere-seconds <seconds>] [--control-clock-ms <u32>] [--validation] [--preview-roots <non-zero n>] [--legacy-camera-capture <path>] [--static-animation-frame <u16>] [--static-material-phase <u16>] [--readback-out <path>] [--readback-sequence-out <directory>]\n--viewer skips mission simulation. Capture, static pose/material and root-limit options select viewer mode. --control-clock-ms replays the scene clock from zero to the selected time over the requested frames; --readback-sequence-out captures each submitted frame and requires that clock.".to_string()
+ "usage: fparkan-game [--root <path>] --list-missions\n fparkan-game [--root <path>] --mission <number|path> --sim-report <seconds>\n fparkan-game [--root <path>] --mission <number|path> [--build-scheme <Unit DAT path> [--build-part OLD=NEW]...] [--viewer] [--frames <n>] [--atmosphere-seconds <seconds>] [--control-clock-ms <u32>] [--validation] [--preview-roots <non-zero n>] [--legacy-camera-capture <path>] [--static-animation-frame <u16>] [--static-material-phase <u16>] [--readback-out <path>] [--readback-sequence-out <directory>]\nWithout --root, game data is read from the working directory.\n--viewer skips mission simulation. Capture, static pose/material and root-limit options select viewer mode. --control-clock-ms replays the scene clock from zero to the selected time over the requested frames; --readback-sequence-out captures each submitted frame and requires that clock.".to_string()
}
#[cfg(test)]
diff --git a/apps/fparkan-game/src/mission_startup.rs b/apps/fparkan-game/src/mission_startup.rs
index f0841da5..2b3f47ef 100644
--- a/apps/fparkan-game/src/mission_startup.rs
+++ b/apps/fparkan-game/src/mission_startup.rs
@@ -24,6 +24,20 @@ use std::{
use mission_loading::Stage;
+#[cfg(test)]
+#[test]
+fn omitted_game_root_uses_the_working_directory() {
+ let args = Args::parse(&["--list-missions".into()]).unwrap();
+ assert_eq!(args.root, std::env::current_dir().unwrap());
+ let args = Args::parse(&[
+ "--root".into(),
+ "other-root".into(),
+ "--list-missions".into(),
+ ])
+ .unwrap();
+ assert_eq!(args.root, std::path::Path::new("other-root"));
+}
+
pub(super) fn run(args: &[String]) -> Result<String, String> {
let mut args = Args::parse(args)?;
let vfs = Arc::new(DirectoryVfs::new(&args.root));