Skip to content

Commit

Permalink
run rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
TheDGOfficial committed Dec 9, 2023
1 parent 19d508f commit 6dd63b1
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/master_skull_upgrade_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Value>(&response_body) {
Ok(json) => {
json.get("matching_query").map_or_else(|| {
Expand Down
45 changes: 31 additions & 14 deletions src/minecraft_launcher_launcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,23 +126,29 @@ pub(crate) fn launch() -> ExitCode {

static KILLING_IN_PROGRESS: Lazy<AtomicBool> =
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<PathBuf> {
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
}
},
}
}

Expand All @@ -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
Expand All @@ -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 {
Expand Down Expand Up @@ -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 */
]);
Expand Down
24 changes: 19 additions & 5 deletions src/rng_simulator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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,
);
Expand Down

0 comments on commit 6dd63b1

Please sign in to comment.