From 2e4c4d18612fcc5e4fc082755a831608bf166209 Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Tue, 13 Oct 2026 14:12:16 +0200 Subject: [PATCH] Launcher: run the game from the saves folder, never a version folder The client ran in the version's own folder, so saves and options.txt would have landed there and been deleted with the version, and the saves in ~/.local/share/horizon (where the release folders' horizon.sh keeps them) were not seen. It now runs in HORIZON_HOME, else horizon in the platform's data folder, with --resources pointing at the version. Co-Authored-By: Claude Opus 5.5 --- launcher/Cargo.lock | 2 +- launcher/Cargo.toml | 2 +- launcher/src/backend.rs | 14 +++++++++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/launcher/Cargo.lock b/launcher/Cargo.lock index 8d3fca9e4..39304d02b 100644 --- a/launcher/Cargo.lock +++ b/launcher/Cargo.lock @@ -2565,7 +2565,7 @@ dependencies = [ [[package]] name = "horizon-launcher" -version = "0.1.0" +version = "0.1.1" dependencies = [ "clap", "dirs 5.0.1", diff --git a/launcher/Cargo.toml b/launcher/Cargo.toml index 386d9a881..8214ce64d 100644 --- a/launcher/Cargo.toml +++ b/launcher/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "horizon-launcher" -version = "0.1.0" +version = "0.1.1" edition = "2021" license = "MIT" description = "Downloads, prepares and starts Horizon builds" diff --git a/launcher/src/backend.rs b/launcher/src/backend.rs index a5d94567d..720101752 100644 --- a/launcher/src/backend.rs +++ b/launcher/src/backend.rs @@ -336,9 +336,21 @@ pub fn prepare_command(tag: &str, minecraft: &Path, log: &dyn Fn(String)) -> Res Ok(cmd) } +/// Where the game keeps saves and options.txt: `HORIZON_HOME`, else `horizon` in the platform's +/// data folder (~/.local/share/horizon on Linux, as the release folders' horizon.sh uses). It is +/// never inside a version folder, so installing, updating or removing a version keeps the saves. +pub fn game_home() -> PathBuf { + if let Some(home) = std::env::var_os("HORIZON_HOME").filter(|h| !h.is_empty()) { + return PathBuf::from(home); + } + dirs::data_dir().unwrap_or_else(std::env::temp_dir).join("horizon") +} + pub fn client_command(tag: &str) -> Command { + let home = game_home(); + let _ = fs::create_dir_all(&home); let mut cmd = Command::new(version_dir(tag).join(CLIENT)); - cmd.current_dir(version_dir(tag)); + cmd.current_dir(home).arg("--resources").arg(resources(tag)); cmd }