From 5a4eeb563689b761500bf9f8ecae3c1fc3e4d012 Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Sat, 25 Mar 2023 14:00:20 +0200 Subject: [PATCH] feat: improved game repairing feature Added support for xlua patch, stopped launcher from repairing one forgotten anti-cheat related file --- src/ui/main/repair_game.rs | 39 +++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/src/ui/main/repair_game.rs b/src/ui/main/repair_game.rs index d48719b..dcf3a7c 100644 --- a/src/ui/main/repair_game.rs +++ b/src/ui/main/repair_game.rs @@ -104,25 +104,46 @@ pub fn repair_game(sender: ComponentSender, progress_bar_input: Sender 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, progress_bar_input: Sender