From f8e0b67cc659bd8214afad4417c364db74411d27 Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Sun, 18 Jun 2023 00:31:00 +0200 Subject: [PATCH] feat(genshin): updated dawn patch --- Cargo.toml | 2 +- src/games/genshin/config/schema/patch.rs | 34 +++++++++++++++--------- src/games/genshin/states.rs | 32 ++++++++++------------ 3 files changed, 36 insertions(+), 32 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3e65186..b3c237c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ edition = "2021" [dependencies.anime-game-core] git = "https://github.com/an-anime-team/anime-game-core" -tag = "1.12.6" +tag = "1.13.0" features = ["all"] # path = "../anime-game-core" # ! for dev purposes only diff --git a/src/games/genshin/config/schema/patch.rs b/src/games/genshin/config/schema/patch.rs index 9dd2ecf..6e8c83c 100644 --- a/src/games/genshin/config/schema/patch.rs +++ b/src/games/genshin/config/schema/patch.rs @@ -9,9 +9,9 @@ use crate::genshin::consts::launcher_dir; pub struct Patch { pub path: PathBuf, pub servers: Vec, - pub apply_main: bool, - pub apply_xlua: bool, - pub root: bool + pub apply: bool, + pub root: bool, + pub disable_mhypbase: bool } impl Default for Patch { @@ -27,11 +27,12 @@ impl Default for Patch { String::from("https://notabug.org/Krock/dawn") ], - apply_main: true, - apply_xlua: false, + apply: true, // Disable root requirement for patching if we're running launcher in flatpak - root: !PathBuf::from("/.flatpak-info").exists() + root: !PathBuf::from("/.flatpak-info").exists(), + + disable_mhypbase: false } } } @@ -67,19 +68,26 @@ impl From<&JsonValue> for Patch { None => default.servers }, - apply_main: match value.get("apply_main") { - Some(value) => value.as_bool().unwrap_or(default.apply_main), - None => default.apply_main - }, + apply: match value.get("apply") { + Some(value) => value.as_bool().unwrap_or(default.apply), - apply_xlua: match value.get("apply_xlua") { - Some(value) => value.as_bool().unwrap_or(default.apply_xlua), - None => default.apply_xlua + // Migration from 1.7.8 to 1.8.0 + // Xlua patch doesn't exist now so there's only one patch + // and thus it's main, and doesn't need this suffix here + None => match value.get("apply_main") { + Some(value) => value.as_bool().unwrap_or(default.apply), + None => default.apply + } }, root: match value.get("root") { Some(value) => value.as_bool().unwrap_or(default.root), None => default.root + }, + + disable_mhypbase: match value.get("disable_mhypbase") { + Some(value) => value.as_bool().unwrap_or(default.disable_mhypbase), + None => default.disable_mhypbase } } } diff --git a/src/games/genshin/states.rs b/src/games/genshin/states.rs index c81b534..083e94b 100644 --- a/src/games/genshin/states.rs +++ b/src/games/genshin/states.rs @@ -22,8 +22,10 @@ pub enum LauncherState { cleanup_folder: Option }, - UnityPlayerPatchAvailable(UnityPlayerPatch), - XluaPatchAvailable(XluaPatch), + PlayerPatchAvailable { + patch: PlayerPatch, + disable_mhypbase: bool + }, #[cfg(feature = "components")] WineNotInstalled, @@ -66,8 +68,8 @@ pub struct LauncherStateParams { pub patch_servers: Vec, pub patch_folder: PathBuf, - pub use_main_patch: bool, - pub use_xlua_patch: bool, + pub use_patch: bool, + pub disable_mhypbase: bool, pub status_updater: F } @@ -151,20 +153,14 @@ impl LauncherState { } // Check UnityPlayer patch - if params.use_main_patch { - let player_patch = patch.unity_player_patch()?; + if params.use_patch { + let player_patch = patch.player_patch()?; if !player_patch.is_applied(¶ms.game_path)? { - return Ok(Self::UnityPlayerPatchAvailable(player_patch)); - } - } - - // Check xlua patch - if params.use_xlua_patch { - let xlua_patch = patch.xlua_patch()?; - - if !xlua_patch.is_applied(¶ms.game_path)? { - return Ok(Self::XluaPatchAvailable(xlua_patch)); + return Ok(Self::PlayerPatchAvailable { + patch: player_patch, + disable_mhypbase: params.disable_mhypbase + }); } } @@ -222,8 +218,8 @@ impl LauncherState { patch_servers: config.patch.servers, patch_folder: config.patch.path, - use_main_patch: config.patch.apply_main, - use_xlua_patch: config.patch.apply_xlua, + use_patch: config.patch.apply, + disable_mhypbase: config.patch.disable_mhypbase, status_updater })