diff --git a/src-tauri/src/patch.rs b/src-tauri/src/patch.rs index 856f53d..cabc217 100644 --- a/src-tauri/src/patch.rs +++ b/src-tauri/src/patch.rs @@ -50,79 +50,80 @@ struct WhatToUnpach { #[cfg(windows)] #[tauri::command] -pub async fn patch_game(newer_game: bool, version: String) -> bool { +pub async fn patch_game(_newer_game: bool, version: String) -> bool { let mut patch_path; // Altpatch first - Now using as hoyonet switch - if newer_game { - let alt_patch_path = PathBuf::from(system_helpers::install_location()).join("altpatch"); + // People keep using this when they shouldn't, 99.8% of people will never need it. Just remove for now. + // if newer_game { + // let alt_patch_path = PathBuf::from(system_helpers::install_location()).join("altpatch"); - // Should handle overwriting backup with new version backup later - let backup_path = PathBuf::from(system_helpers::install_location()) - .join("altpatch/original-mihoyonet.dll") - .to_str() - .unwrap() - .to_string(); - let backup_exists = file_helpers::does_file_exist(&backup_path); + // // Should handle overwriting backup with new version backup later + // let backup_path = PathBuf::from(system_helpers::install_location()) + // .join("altpatch/original-mihoyonet.dll") + // .to_str() + // .unwrap() + // .to_string(); + // let backup_exists = file_helpers::does_file_exist(&backup_path); - if !backup_exists { - let backup = file_helpers::copy_file_with_new_name( - get_game_rsa_path().await.unwrap() - + &String::from("/GenshinImpact_Data/Plugins/mihoyonet.dll"), - alt_patch_path.clone().to_str().unwrap().to_string(), - String::from("original-mihoyonet.dll"), - ); + // if !backup_exists { + // let backup = file_helpers::copy_file_with_new_name( + // get_game_rsa_path().await.unwrap() + // + &String::from("/GenshinImpact_Data/Plugins/mihoyonet.dll"), + // alt_patch_path.clone().to_str().unwrap().to_string(), + // String::from("original-mihoyonet.dll"), + // ); - if !backup { - println!("Unable to backup file!"); - } - } + // if !backup { + // println!("Unable to backup file!"); + // } + // } - patch_path = PathBuf::from(system_helpers::install_location()).join("altpatch/mihoyonet.dll"); - // Copy the other part of patch to game files - let alt_replaced = file_helpers::copy_file_with_new_name( - patch_path.clone().to_str().unwrap().to_string(), - get_game_rsa_path().await.unwrap() + &String::from("/GenshinImpact_Data/Plugins"), - String::from("mihoyonet.dll"), - ); + // patch_path = PathBuf::from(system_helpers::install_location()).join("altpatch/mihoyonet.dll"); + // // Copy the other part of patch to game files + // let alt_replaced = file_helpers::copy_file_with_new_name( + // patch_path.clone().to_str().unwrap().to_string(), + // get_game_rsa_path().await.unwrap() + &String::from("/GenshinImpact_Data/Plugins"), + // String::from("mihoyonet.dll"), + // ); - if !alt_replaced { - return false; - } + // if !alt_replaced { + // return false; + // } - /*** For replacing old backup file with new one, for example when version changes - * Currently replaces when it shouldn't. Will figure it out when it matters - * ***/ - // else { - // // Check if game file matches backup - // let matching_alt_backup = file_helpers::are_files_identical( - // &backup_path.clone(), - // PathBuf::from(get_game_rsa_path().await.unwrap()) - // .join("/GenshinImpact_Data/Plugins/mihoyonet.dll") - // .to_str() - // .unwrap(), - // ); + /*** For replacing old backup file with new one, for example when version changes + * Currently replaces when it shouldn't. Will figure it out when it matters + * ***/ + // else { + // // Check if game file matches backup + // let matching_alt_backup = file_helpers::are_files_identical( + // &backup_path.clone(), + // PathBuf::from(get_game_rsa_path().await.unwrap()) + // .join("/GenshinImpact_Data/Plugins/mihoyonet.dll") + // .to_str() + // .unwrap(), + // ); - // let is_alt_patched = file_helpers::are_files_identical( - // PathBuf::from(system_helpers::install_location()).join("altpatch/mihoyonet.dll").to_str().unwrap(), - // PathBuf::from(get_game_rsa_path().await.unwrap()) - // .join("/GenshinImpact_Data/Plugins/mihoyonet.dll") - // .to_str() - // .unwrap(), - // ); + // let is_alt_patched = file_helpers::are_files_identical( + // PathBuf::from(system_helpers::install_location()).join("altpatch/mihoyonet.dll").to_str().unwrap(), + // PathBuf::from(get_game_rsa_path().await.unwrap()) + // .join("/GenshinImpact_Data/Plugins/mihoyonet.dll") + // .to_str() + // .unwrap(), + // ); - // // Check if already alt patched - // if !matching_alt_backup { - // // Copy new backup if it is not patched - // if !is_alt_patched { - // file_helpers::copy_file_with_new_name( - // get_game_rsa_path().await.unwrap() + &String::from("/GenshinImpact_Data/Plugins/mihoyonet.dll"), - // alt_patch_path.clone().to_str().unwrap().to_string(), - // String::from("original-mihoyonet.dll"), - // ); - // } - // } - // } - } + // // Check if already alt patched + // if !matching_alt_backup { + // // Copy new backup if it is not patched + // if !is_alt_patched { + // file_helpers::copy_file_with_new_name( + // get_game_rsa_path().await.unwrap() + &String::from("/GenshinImpact_Data/Plugins/mihoyonet.dll"), + // alt_patch_path.clone().to_str().unwrap().to_string(), + // String::from("original-mihoyonet.dll"), + // ); + // } + // } + // } + // } // Standard patch patch_path = PathBuf::from(system_helpers::install_location()).join("patch/version.dll"); diff --git a/src/ui/components/ServerLaunchSection.tsx b/src/ui/components/ServerLaunchSection.tsx index 2d9d642..8840174 100644 --- a/src/ui/components/ServerLaunchSection.tsx +++ b/src/ui/components/ServerLaunchSection.tsx @@ -149,7 +149,7 @@ export default class ServerLaunchSection extends React.Component // Connect to proxy if (config.toggle_grasscutter) { const game_exe = await getGameExecutable() - let newerGame = false + const newerGame = false const patchable = game_exe?.toLowerCase().includes('yuanshen') || game_exe?.toLowerCase().includes('genshin') @@ -183,35 +183,36 @@ export default class ServerLaunchSection extends React.Component const versionString = gameVersion?.major.toString() + gameVersion?.minor.toString() - if ((gameVersion?.major == 4 && gameVersion?.minor > 5) || config.newer_game) { - newerGame = true + // Keeps being misused, remove for now. + // if ((gameVersion?.major == 4 && gameVersion?.minor > 5) || config.newer_game) { + // newerGame = true - const path = (await invoke('install_location')) as string + // const path = (await invoke('install_location')) as string - const patchstring = '\\altpatch\\' - const altPatch = path + patchstring + // const patchstring = '\\altpatch\\' + // const altPatch = path + patchstring - const ALT_PATCH = - 'https://autopatchhk.yuanshen.com/client_app/download/pc_zip/20231030132335_iOEfPMcbrXpiA8Ca/ScatteredFiles/GenshinImpact_Data/Plugins/mihoyonet.dll' - const pExists = (await invoke('dir_exists', { - path: altPatch, - })) as boolean + // const ALT_PATCH = + // 'https://autopatchhk.yuanshen.com/client_app/download/pc_zip/20231030132335_iOEfPMcbrXpiA8Ca/ScatteredFiles/GenshinImpact_Data/Plugins/mihoyonet.dll' + // const pExists = (await invoke('dir_exists', { + // path: altPatch, + // })) as boolean - if (!pExists) { - await invoke('dir_create', { - path: altPatch, - }) - this.props.downloadHandler.addDownload(ALT_PATCH, path + '/altpatch/mihoyonet.dll') - await confirm('Please wait for the download in the bottom left to disappear, then click yes') - } + // if (!pExists) { + // await invoke('dir_create', { + // path: altPatch, + // }) + // this.props.downloadHandler.addDownload(ALT_PATCH, path + '/altpatch/mihoyonet.dll') + // await confirm('Please wait for the download in the bottom left to disappear, then click yes') + // } - /* For custom address patch only, used in 4.5 */ - // let httpString = 'http://' - // if (this.state.httpsEnabled) { - // httpString = 'https://' - // } - // config.launch_args = '-server=' + httpString + this.state.ip + ':' + this.state.port - } + // /* For custom address patch only, used in 4.5 */ + // // let httpString = 'http://' + // // if (this.state.httpsEnabled) { + // // httpString = 'https://' + // // } + // // config.launch_args = '-server=' + httpString + this.state.ip + ':' + this.state.port + // } const patched = await patchGame(newerGame, versionString) diff --git a/src/ui/components/menu/Options.tsx b/src/ui/components/menu/Options.tsx index 3b5c9f5..a8880ea 100644 --- a/src/ui/components/menu/Options.tsx +++ b/src/ui/components/menu/Options.tsx @@ -712,7 +712,7 @@ export default class Options extends React.Component { - + */}