feat(genshin): updated dawn patch

This commit is contained in:
Observer KRypt0n_ 2023-06-18 00:31:00 +02:00
parent e46f42674d
commit f8e0b67cc6
No known key found for this signature in database
GPG key ID: 844DA47BA25FE1E2
3 changed files with 36 additions and 32 deletions

View file

@ -9,7 +9,7 @@ edition = "2021"
[dependencies.anime-game-core] [dependencies.anime-game-core]
git = "https://github.com/an-anime-team/anime-game-core" git = "https://github.com/an-anime-team/anime-game-core"
tag = "1.12.6" tag = "1.13.0"
features = ["all"] features = ["all"]
# path = "../anime-game-core" # ! for dev purposes only # path = "../anime-game-core" # ! for dev purposes only

View file

@ -9,9 +9,9 @@ use crate::genshin::consts::launcher_dir;
pub struct Patch { pub struct Patch {
pub path: PathBuf, pub path: PathBuf,
pub servers: Vec<String>, pub servers: Vec<String>,
pub apply_main: bool, pub apply: bool,
pub apply_xlua: bool, pub root: bool,
pub root: bool pub disable_mhypbase: bool
} }
impl Default for Patch { impl Default for Patch {
@ -27,11 +27,12 @@ impl Default for Patch {
String::from("https://notabug.org/Krock/dawn") String::from("https://notabug.org/Krock/dawn")
], ],
apply_main: true, apply: true,
apply_xlua: false,
// Disable root requirement for patching if we're running launcher in flatpak // 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 None => default.servers
}, },
apply_main: match value.get("apply_main") { apply: match value.get("apply") {
Some(value) => value.as_bool().unwrap_or(default.apply_main), Some(value) => value.as_bool().unwrap_or(default.apply),
None => default.apply_main
},
apply_xlua: match value.get("apply_xlua") { // Migration from 1.7.8 to 1.8.0
Some(value) => value.as_bool().unwrap_or(default.apply_xlua), // Xlua patch doesn't exist now so there's only one patch
None => default.apply_xlua // 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") { root: match value.get("root") {
Some(value) => value.as_bool().unwrap_or(default.root), Some(value) => value.as_bool().unwrap_or(default.root),
None => 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
} }
} }
} }

View file

@ -22,8 +22,10 @@ pub enum LauncherState {
cleanup_folder: Option<PathBuf> cleanup_folder: Option<PathBuf>
}, },
UnityPlayerPatchAvailable(UnityPlayerPatch), PlayerPatchAvailable {
XluaPatchAvailable(XluaPatch), patch: PlayerPatch,
disable_mhypbase: bool
},
#[cfg(feature = "components")] #[cfg(feature = "components")]
WineNotInstalled, WineNotInstalled,
@ -66,8 +68,8 @@ pub struct LauncherStateParams<F: Fn(StateUpdating)> {
pub patch_servers: Vec<String>, pub patch_servers: Vec<String>,
pub patch_folder: PathBuf, pub patch_folder: PathBuf,
pub use_main_patch: bool, pub use_patch: bool,
pub use_xlua_patch: bool, pub disable_mhypbase: bool,
pub status_updater: F pub status_updater: F
} }
@ -151,20 +153,14 @@ impl LauncherState {
} }
// Check UnityPlayer patch // Check UnityPlayer patch
if params.use_main_patch { if params.use_patch {
let player_patch = patch.unity_player_patch()?; let player_patch = patch.player_patch()?;
if !player_patch.is_applied(&params.game_path)? { if !player_patch.is_applied(&params.game_path)? {
return Ok(Self::UnityPlayerPatchAvailable(player_patch)); return Ok(Self::PlayerPatchAvailable {
} patch: player_patch,
} disable_mhypbase: params.disable_mhypbase
});
// Check xlua patch
if params.use_xlua_patch {
let xlua_patch = patch.xlua_patch()?;
if !xlua_patch.is_applied(&params.game_path)? {
return Ok(Self::XluaPatchAvailable(xlua_patch));
} }
} }
@ -222,8 +218,8 @@ impl LauncherState {
patch_servers: config.patch.servers, patch_servers: config.patch.servers,
patch_folder: config.patch.path, patch_folder: config.patch.path,
use_main_patch: config.patch.apply_main, use_patch: config.patch.apply,
use_xlua_patch: config.patch.apply_xlua, disable_mhypbase: config.patch.disable_mhypbase,
status_updater status_updater
}) })