feat(genshin): removed patch support
This commit is contained in:
parent
0a2b5e8711
commit
847214f52e
5 changed files with 11 additions and 171 deletions
|
@ -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.14.0"
|
tag = "1.15.0"
|
||||||
features = ["all"]
|
features = ["all"]
|
||||||
|
|
||||||
# path = "../anime-game-core" # ! for dev purposes only
|
# path = "../anime-game-core" # ! for dev purposes only
|
||||||
|
@ -35,7 +35,6 @@ star-rail = ["anime-game-core/star-rail"]
|
||||||
honkai = ["anime-game-core/honkai"]
|
honkai = ["anime-game-core/honkai"]
|
||||||
pgr = ["anime-game-core/pgr"]
|
pgr = ["anime-game-core/pgr"]
|
||||||
|
|
||||||
genshin-patch = ["anime-game-core/patch-dawn"]
|
|
||||||
star-rail-patch = ["anime-game-core/patch-jadeite"]
|
star-rail-patch = ["anime-game-core/patch-jadeite"]
|
||||||
honkai-patch = [
|
honkai-patch = [
|
||||||
"anime-game-core/patch-jadeite",
|
"anime-game-core/patch-jadeite",
|
||||||
|
|
|
@ -19,7 +19,6 @@ use crate::components::{
|
||||||
|
|
||||||
pub mod launcher;
|
pub mod launcher;
|
||||||
pub mod game;
|
pub mod game;
|
||||||
pub mod patch;
|
|
||||||
|
|
||||||
#[cfg(feature = "components")]
|
#[cfg(feature = "components")]
|
||||||
pub mod components;
|
pub mod components;
|
||||||
|
@ -30,7 +29,6 @@ pub mod prelude {
|
||||||
|
|
||||||
pub use super::launcher::prelude::*;
|
pub use super::launcher::prelude::*;
|
||||||
pub use super::game::*;
|
pub use super::game::*;
|
||||||
pub use super::patch::*;
|
|
||||||
|
|
||||||
#[cfg(feature = "components")]
|
#[cfg(feature = "components")]
|
||||||
pub use super::components::*;
|
pub use super::components::*;
|
||||||
|
@ -47,9 +45,7 @@ pub struct Schema {
|
||||||
pub sandbox: Sandbox,
|
pub sandbox: Sandbox,
|
||||||
|
|
||||||
#[cfg(feature = "components")]
|
#[cfg(feature = "components")]
|
||||||
pub components: Components,
|
pub components: Components
|
||||||
|
|
||||||
pub patch: Patch
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<&JsonValue> for Schema {
|
impl From<&JsonValue> for Schema {
|
||||||
|
@ -77,12 +73,7 @@ impl From<&JsonValue> for Schema {
|
||||||
components: match value.get("components") {
|
components: match value.get("components") {
|
||||||
Some(value) => Components::from(value),
|
Some(value) => Components::from(value),
|
||||||
None => default.components
|
None => default.components
|
||||||
},
|
}
|
||||||
|
|
||||||
patch: match value.get("patch") {
|
|
||||||
Some(value) => Patch::from(value),
|
|
||||||
None => default.patch
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,94 +0,0 @@
|
||||||
use std::path::PathBuf;
|
|
||||||
|
|
||||||
use serde::{Serialize, Deserialize};
|
|
||||||
use serde_json::Value as JsonValue;
|
|
||||||
|
|
||||||
use crate::genshin::consts::launcher_dir;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
||||||
pub struct Patch {
|
|
||||||
pub path: PathBuf,
|
|
||||||
pub servers: Vec<String>,
|
|
||||||
pub apply: bool,
|
|
||||||
pub root: bool,
|
|
||||||
pub disable_mhypbase: bool
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for Patch {
|
|
||||||
#[inline]
|
|
||||||
fn default() -> Self {
|
|
||||||
let launcher_dir = launcher_dir().expect("Failed to get launcher dir");
|
|
||||||
|
|
||||||
Self {
|
|
||||||
path: launcher_dir.join("patch"),
|
|
||||||
|
|
||||||
servers: vec![
|
|
||||||
String::from("https://codeberg.org/an-anime-team/dawn"),
|
|
||||||
String::from("https://notabug.org/Krock/dawn")
|
|
||||||
],
|
|
||||||
|
|
||||||
apply: false,
|
|
||||||
|
|
||||||
// Disable root requirement for patching if we're running launcher in flatpak
|
|
||||||
root: !PathBuf::from("/.flatpak-info").exists(),
|
|
||||||
|
|
||||||
disable_mhypbase: false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<&JsonValue> for Patch {
|
|
||||||
fn from(value: &JsonValue) -> Self {
|
|
||||||
let default = Self::default();
|
|
||||||
|
|
||||||
Self {
|
|
||||||
path: match value.get("path") {
|
|
||||||
Some(value) => match value.as_str() {
|
|
||||||
Some(value) => PathBuf::from(value),
|
|
||||||
None => default.path
|
|
||||||
},
|
|
||||||
None => default.path
|
|
||||||
},
|
|
||||||
|
|
||||||
servers: match value.get("servers") {
|
|
||||||
Some(value) => match value.as_array() {
|
|
||||||
Some(values) => {
|
|
||||||
let mut servers = Vec::new();
|
|
||||||
|
|
||||||
for value in values {
|
|
||||||
if let Some(server) = value.as_str() {
|
|
||||||
servers.push(server.to_string());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
servers
|
|
||||||
},
|
|
||||||
None => default.servers
|
|
||||||
},
|
|
||||||
None => default.servers
|
|
||||||
},
|
|
||||||
|
|
||||||
apply: match value.get("apply") {
|
|
||||||
Some(value) => value.as_bool().unwrap_or(default.apply),
|
|
||||||
|
|
||||||
// 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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -50,12 +50,10 @@ pub fn run() -> anyhow::Result<()> {
|
||||||
|
|
||||||
let config = Config::get()?;
|
let config = Config::get()?;
|
||||||
|
|
||||||
let game_executable = config.patch.apply
|
let game_executable = match config.launcher.edition {
|
||||||
.then_some("launcher.bat")
|
genshin::GameEdition::Global => "GenshinImpact.exe",
|
||||||
.unwrap_or_else(|| match config.launcher.edition {
|
genshin::GameEdition::China => "YuanShen.exe"
|
||||||
genshin::GameEdition::Global => "GenshinImpact.exe",
|
};
|
||||||
genshin::GameEdition::China => "YuanShen.exe"
|
|
||||||
});
|
|
||||||
|
|
||||||
let game_path = config.game.path.for_edition(config.launcher.edition);
|
let game_path = config.game.path.for_edition(config.launcher.edition);
|
||||||
|
|
||||||
|
@ -117,21 +115,10 @@ pub fn run() -> anyhow::Result<()> {
|
||||||
return Err(anyhow::anyhow!("Failed to update FPS unlocker config: {err}"));
|
return Err(anyhow::anyhow!("Failed to update FPS unlocker config: {err}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
let launcher_bat = game_path.join("launcher.bat");
|
|
||||||
let fps_unlocker_bat = game_path.join("fps_unlocker.bat");
|
|
||||||
|
|
||||||
// Generate fps_unlocker.bat
|
// If patch applying is disabled, then game_executable is either GenshinImpact.exe or YuanShen.exe
|
||||||
if config.patch.apply {
|
// so we don't need to check it here
|
||||||
std::fs::write(fps_unlocker_bat, std::fs::read_to_string(launcher_bat)?
|
std::fs::write(game_path.join("fps_unlocker.bat"), format!("start {game_executable} %*\n\nZ:\ncd \"{}\"\nstart unlocker.exe", unlocker.dir().to_string_lossy()))?;
|
||||||
.replace("start GenshinImpact.exe %*", &format!("start GenshinImpact.exe %*\n\nZ:\ncd \"{}\"\nstart unlocker.exe", unlocker.dir().to_string_lossy()))
|
|
||||||
.replace("start YuanShen.exe %*", &format!("start YuanShen.exe %*\n\nZ:\ncd \"{}\"\nstart unlocker.exe", unlocker.dir().to_string_lossy())))?;
|
|
||||||
}
|
|
||||||
|
|
||||||
else {
|
|
||||||
// If patch applying is disabled, then game_executable is either GenshinImpact.exe or YuanShen.exe
|
|
||||||
// so we don't need to check it here
|
|
||||||
std::fs::write(fps_unlocker_bat, format!("start {game_executable} %*\n\nZ:\ncd \"{}\"\nstart unlocker.exe", unlocker.dir().to_string_lossy()))?;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate `config.ini` if environment emulation feature is presented
|
// Generate `config.ini` if environment emulation feature is presented
|
||||||
|
|
|
@ -22,11 +22,6 @@ pub enum LauncherState {
|
||||||
cleanup_folder: Option<PathBuf>
|
cleanup_folder: Option<PathBuf>
|
||||||
},
|
},
|
||||||
|
|
||||||
PlayerPatchAvailable {
|
|
||||||
patch: PlayerPatch,
|
|
||||||
disable_mhypbase: bool
|
|
||||||
},
|
|
||||||
|
|
||||||
TelemetryNotDisabled,
|
TelemetryNotDisabled,
|
||||||
|
|
||||||
#[cfg(feature = "components")]
|
#[cfg(feature = "components")]
|
||||||
|
@ -56,8 +51,7 @@ pub enum LauncherState {
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
pub enum StateUpdating {
|
pub enum StateUpdating {
|
||||||
Game,
|
Game,
|
||||||
Voice(VoiceLocale),
|
Voice(VoiceLocale)
|
||||||
Patch
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
|
@ -68,11 +62,6 @@ pub struct LauncherStateParams<F: Fn(StateUpdating)> {
|
||||||
pub wine_prefix: PathBuf,
|
pub wine_prefix: PathBuf,
|
||||||
pub selected_voices: Vec<VoiceLocale>,
|
pub selected_voices: Vec<VoiceLocale>,
|
||||||
|
|
||||||
pub patch_servers: Vec<String>,
|
|
||||||
pub patch_folder: PathBuf,
|
|
||||||
pub use_patch: bool,
|
|
||||||
pub disable_mhypbase: bool,
|
|
||||||
|
|
||||||
pub status_updater: F
|
pub status_updater: F
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,33 +111,6 @@ impl LauncherState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check game patch status
|
|
||||||
(params.status_updater)(StateUpdating::Patch);
|
|
||||||
|
|
||||||
let patch = Patch::new(¶ms.patch_folder, params.game_edition);
|
|
||||||
|
|
||||||
// Sync local patch folder with remote if needed
|
|
||||||
// TODO: maybe I shouldn't do it here?
|
|
||||||
if patch.is_sync(¶ms.patch_servers)?.is_none() {
|
|
||||||
for server in ¶ms.patch_servers {
|
|
||||||
if patch.sync(server).is_ok() {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check UnityPlayer patch
|
|
||||||
if params.use_patch {
|
|
||||||
let player_patch = patch.player_patch()?;
|
|
||||||
|
|
||||||
if !player_patch.is_applied(¶ms.game_path)? {
|
|
||||||
return Ok(Self::PlayerPatchAvailable {
|
|
||||||
patch: player_patch,
|
|
||||||
disable_mhypbase: params.disable_mhypbase
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check telemetry servers
|
// Check telemetry servers
|
||||||
let disabled = telemetry::is_disabled(params.game_edition)
|
let disabled = telemetry::is_disabled(params.game_edition)
|
||||||
|
|
||||||
|
@ -219,11 +181,6 @@ impl LauncherState {
|
||||||
wine_prefix: config.get_wine_prefix_path(),
|
wine_prefix: config.get_wine_prefix_path(),
|
||||||
selected_voices: voices,
|
selected_voices: voices,
|
||||||
|
|
||||||
patch_servers: config.patch.servers,
|
|
||||||
patch_folder: config.patch.path,
|
|
||||||
use_patch: config.patch.apply,
|
|
||||||
disable_mhypbase: config.patch.disable_mhypbase,
|
|
||||||
|
|
||||||
status_updater
|
status_updater
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue