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:
Observer KRypt0n_ 2023-03-25 14:00:20 +02:00
parent f1b10c6bea
commit 5a4eeb5636
No known key found for this signature in database
GPG key ID: 844DA47BA25FE1E2

View file

@ -104,25 +104,46 @@ pub fn repair_game(sender: ComponentSender<App>, progress_bar_input: Sender<Prog
let total = broken.len() as f64; let total = broken.len() as f64;
// TODO: properly handle xlua patch let player_patch = UnityPlayerPatch::from_folder(&config.patch.path).unwrap()
let is_patch_applied = UnityPlayerPatch::from_folder(&config.patch.path).unwrap()
.is_applied(&config.game.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 { tracing::debug!("Patches status: player({player_patch}), xlua({xlua_patch})");
for part in ["UnityPlayer.dll", "xlua.dll", "crashreport.exe", "upload_crash.exe", "vulkan-1.dll"] {
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) { if path.ends_with(part) {
return true; 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 false
} }
for (i, file) in broken.into_iter().enumerate() { for (i, file) in broken.into_iter().enumerate() {
if !is_patch_applied || !should_ignore(&file.path) { if !should_ignore(&file.path, player_patch, xlua_patch) {
tracing::debug!("Repairing: {}", file.path.to_string_lossy()); tracing::debug!("Repairing file: {}", file.path.to_string_lossy());
if let Err(err) = file.repair(&config.game.path) { if let Err(err) = file.repair(&config.game.path) {
sender.input(AppMsg::Toast { 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)); progress_bar_input.send(ProgressBarMsg::UpdateProgress(i as u64, total as u64));
} }
} }