mirror of
https://github.com/an-anime-team/an-anime-game-launcher.git
synced 2025-03-11 02:29:37 +03:00
feat: improved game repairing feature
Added support for xlua patch, stopped launcher from repairing one forgotten anti-cheat related file
This commit is contained in:
parent
f1b10c6bea
commit
5a4eeb5636
1 changed files with 32 additions and 7 deletions
|
@ -104,25 +104,46 @@ pub fn repair_game(sender: ComponentSender<App>, progress_bar_input: Sender<Prog
|
|||
|
||||
let total = broken.len() as f64;
|
||||
|
||||
// TODO: properly handle xlua patch
|
||||
let is_patch_applied = UnityPlayerPatch::from_folder(&config.patch.path).unwrap()
|
||||
let player_patch = UnityPlayerPatch::from_folder(&config.patch.path).unwrap()
|
||||
.is_applied(&config.game.path).unwrap();
|
||||
|
||||
tracing::debug!("Patch status: {}", is_patch_applied);
|
||||
let xlua_patch = UnityPlayerPatch::from_folder(&config.patch.path).unwrap()
|
||||
.is_applied(&config.game.path).unwrap();
|
||||
|
||||
fn should_ignore(path: &Path) -> bool {
|
||||
for part in ["UnityPlayer.dll", "xlua.dll", "crashreport.exe", "upload_crash.exe", "vulkan-1.dll"] {
|
||||
tracing::debug!("Patches status: player({player_patch}), xlua({xlua_patch})");
|
||||
|
||||
fn should_ignore(path: &Path, player_patch: bool, xlua_patch: bool) -> bool {
|
||||
// Files managed by launch.bat file
|
||||
for part in ["crashreport.exe", "upload_crash.exe"] {
|
||||
if path.ends_with(part) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// UnityPlayer patch related files
|
||||
if player_patch {
|
||||
for part in ["UnityPlayer.dll", "vulkan-1.dll"] {
|
||||
if path.ends_with(part) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Xlua patch related files
|
||||
if xlua_patch {
|
||||
for part in ["xlua.dll", "mhypbase.dll"] {
|
||||
if path.ends_with(part) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
false
|
||||
}
|
||||
|
||||
for (i, file) in broken.into_iter().enumerate() {
|
||||
if !is_patch_applied || !should_ignore(&file.path) {
|
||||
tracing::debug!("Repairing: {}", file.path.to_string_lossy());
|
||||
if !should_ignore(&file.path, player_patch, xlua_patch) {
|
||||
tracing::debug!("Repairing file: {}", file.path.to_string_lossy());
|
||||
|
||||
if let Err(err) = file.repair(&config.game.path) {
|
||||
sender.input(AppMsg::Toast {
|
||||
|
@ -134,6 +155,10 @@ pub fn repair_game(sender: ComponentSender<App>, progress_bar_input: Sender<Prog
|
|||
}
|
||||
}
|
||||
|
||||
else {
|
||||
tracing::debug!("Skipped file: {}", file.path.to_string_lossy());
|
||||
}
|
||||
|
||||
progress_bar_input.send(ProgressBarMsg::UpdateProgress(i as u64, total as u64));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue