From 6dd63b1f12320d283f2db0f39286d81c4eac4296 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mustafa=20=C3=96NCEL?= Date: Sun, 10 Dec 2023 01:17:50 +0300 Subject: [PATCH] run rustfmt --- src/master_skull_upgrade_helper.rs | 2 +- src/minecraft_launcher_launcher.rs | 45 ++++++++++++++++++++---------- src/rng_simulator.rs | 24 ++++++++++++---- 3 files changed, 51 insertions(+), 20 deletions(-) diff --git a/src/master_skull_upgrade_helper.rs b/src/master_skull_upgrade_helper.rs index 693906c..74b9f97 100644 --- a/src/master_skull_upgrade_helper.rs +++ b/src/master_skull_upgrade_helper.rs @@ -233,7 +233,7 @@ async fn parse_request_and_insert_prices( Ok(response) => { match response.text().await { Ok(response_body) => { - //println!("Received response: {response_body}"); + // println!("Received response: {response_body}"); match serde_json::from_str::(&response_body) { Ok(json) => { json.get("matching_query").map_or_else(|| { diff --git a/src/minecraft_launcher_launcher.rs b/src/minecraft_launcher_launcher.rs index caf3451..665cad0 100644 --- a/src/minecraft_launcher_launcher.rs +++ b/src/minecraft_launcher_launcher.rs @@ -126,23 +126,29 @@ pub(crate) fn launch() -> ExitCode { static KILLING_IN_PROGRESS: Lazy = Lazy::new(|| AtomicBool::new(false)); - -const LAUNCHER_PROFILES_MLLBACKUP_FILE: &str = "launcher_profiles.json.mllbackup"; + +const LAUNCHER_PROFILES_MLLBACKUP_FILE: &str = + "launcher_profiles.json.mllbackup"; fn get_launcher_profiles_path() -> Option { match home::home_dir() { Some(home_folder) => { - // not using utils::get_minecraft_dir_from_home_path as that can be overriden to return a different folder specific to a installation, but the launcher files will always be in the .minecraft foler. - let launcher_profiles_path = Path::new(&home_folder).join(".minecraft").join("launcher_profiles.json"); + // not using utils::get_minecraft_dir_from_home_path as that can be + // overriden to return a different folder specific to a + // installation, but the launcher files will always be in the + // .minecraft foler. + let launcher_profiles_path = Path::new(&home_folder) + .join(".minecraft") + .join("launcher_profiles.json"); Some(launcher_profiles_path) - } - + }, + None => { notify_error("can't find home directory"); - + None - } + }, } } @@ -151,11 +157,17 @@ fn backup_launcher_profiles() { if let Some(path) = get_launcher_profiles_path() { if let Some(contents) = utils::read_file(&path) { if let Some(parent) = &path.parent() { - if utils::write_file(&parent.join(LAUNCHER_PROFILES_MLLBACKUP_FILE), &contents) { + if utils::write_file( + &parent.join(LAUNCHER_PROFILES_MLLBACKUP_FILE), + &contents, + ) { println!("Backed up launcher profiles."); } // Error will be printed by the util method if write fails. } else { - notify_error(&format!("no parent for {}", path.to_string_lossy())); + notify_error(&format!( + "no parent for {}", + path.to_string_lossy() + )); } } // error will be printed by the read method if None } // error will be printed by the get method if None @@ -165,14 +177,18 @@ fn restore_launcher_profiles() { println!("Restoring launcher profiles from backup..."); if let Some(path) = get_launcher_profiles_path() { if let Some(parent) = &path.parent() { - let backup_file_path = parent.join(LAUNCHER_PROFILES_MLLBACKUP_FILE); + let backup_file_path = + parent.join(LAUNCHER_PROFILES_MLLBACKUP_FILE); if let Some(contents) = utils::read_file(&backup_file_path) { if utils::write_file(&path, &contents) { println!("Restored launcher profiles from backup."); } // Error will be printed by the util method if write fails. if let Err(e) = fs::remove_file(backup_file_path) { - notify_error(&format!("error while removing {}: {e}", LAUNCHER_PROFILES_MLLBACKUP_FILE)); + notify_error(&format!( + "error while removing {}: {e}", + LAUNCHER_PROFILES_MLLBACKUP_FILE + )); } } // error will be printed by the read method if None } else { @@ -411,9 +427,10 @@ fn launch_launcher() { * for performance */ ("MESA_GLES_VERSION_OVERRIDE", "3.2"), // ^^ ("MESA_GLSL_VERSION_OVERRIDE", "430"), // ^^ - ("DRI_NO_MSAA", "true"), // Disable MSAA for performance + ("DRI_NO_MSAA", "true"), /* Disable MSAA for + * performance */ ("MESA_SHADER_CACHE_DISABLE", "false"), /* Force enable Shader - * Cache */ + * Cache */ ("MESA_SHADER_CACHE_MAX_SIZE", "4G"), /* Use a big value as limit for Shader Cache */ ("LD_PRELOAD", "/usr/local/lib/libmimalloc.so.2.1"), /* Use mimalloc to increase memory/GC performance */ ]); diff --git a/src/rng_simulator.rs b/src/rng_simulator.rs index 07eb270..a9c30ca 100644 --- a/src/rng_simulator.rs +++ b/src/rng_simulator.rs @@ -77,7 +77,11 @@ fn print_drops_selection() { #[inline] #[must_use] -fn get_drop_chance(selection: i32, no_looting: &mut bool, has_bestiary: &mut bool) -> f64 { +fn get_drop_chance( + selection: i32, + no_looting: &mut bool, + has_bestiary: &mut bool, +) -> f64 { match selection { 1 => { *no_looting = false; @@ -117,7 +121,8 @@ pub(crate) fn rng_simulator( let mut no_looting = true; let mut has_bestiary = false; - let mut drop_chance = get_drop_chance(selection, &mut no_looting, &mut has_bestiary); + let mut drop_chance = + get_drop_chance(selection, &mut no_looting, &mut has_bestiary); let original_drop_chance = drop_chance; let mut rng_meter_percent = -1.0; @@ -138,10 +143,15 @@ pub(crate) fn rng_simulator( } } - let mut magic_find = if selection == 5 || selection == 6 || selection == 7 { + let mut magic_find = if selection == 5 || selection == 6 || selection == 7 + { 0 } else { - ask_int_input("What is your Magic Find? (0-900, as shown in stat menu): ", Some(0), Some(900)) + ask_int_input( + "What is your Magic Find? (0-900, as shown in stat menu): ", + Some(0), + Some(900), + ) }; let looting_extra_chance = 15 @@ -156,7 +166,11 @@ pub(crate) fn rng_simulator( magic_find += conditional_value_or_default( has_bestiary, || { - ask_int_input("What is your extra Magic Find from Bestiary?: ", Some(0), Some(70)) + ask_int_input( + "What is your extra Magic Find from Bestiary?: ", + Some(0), + Some(70), + ) }, 0, );