From 3f07dafe0bc005a5ad1cd8e1329357c304d0b60d Mon Sep 17 00:00:00 2001 From: Ombrezz <37753837+Ombrezz@users.noreply.github.com> Date: Tue, 12 Sep 2023 21:38:50 -0400 Subject: [PATCH 1/5] Fix #284 Only count Northstar as running if it's not a dedicated server. --- src-tauri/src/util.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src-tauri/src/util.rs b/src-tauri/src/util.rs index b21b2208d..451f9ef19 100644 --- a/src-tauri/src/util.rs +++ b/src-tauri/src/util.rs @@ -136,12 +136,14 @@ pub fn check_ea_app_or_origin_running() -> bool { /// Checks if Northstar process is running pub fn check_northstar_running() -> bool { let s = sysinfo::System::new_all(); - let x = s - .processes_by_name("NorthstarLauncher.exe") - .next() - .is_some() - || s.processes_by_name("Titanfall2.exe").next().is_some(); - x + for (_, process) in s.processes() { + if (process.name().ends_with("Titanfall2.exe") || process.name().ends_with("Northstar.exe")) + && !process.cmd().contains(&String::from("-dedicated")) + { + return true; + } + } + false } /// Copies a folder and all its contents to a new location From d5466c0026acfdb4564d8fbbdd188769baf1cbc2 Mon Sep 17 00:00:00 2001 From: Ombrezz <37753837+Ombrezz@users.noreply.github.com> Date: Wed, 13 Sep 2023 15:41:55 -0400 Subject: [PATCH 2/5] Make compliant with clippy's for_kv_map check --- src-tauri/src/util.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src-tauri/src/util.rs b/src-tauri/src/util.rs index 451f9ef19..a10ad6cdb 100644 --- a/src-tauri/src/util.rs +++ b/src-tauri/src/util.rs @@ -136,7 +136,7 @@ pub fn check_ea_app_or_origin_running() -> bool { /// Checks if Northstar process is running pub fn check_northstar_running() -> bool { let s = sysinfo::System::new_all(); - for (_, process) in s.processes() { + for process in s.processes().values() { if (process.name().ends_with("Titanfall2.exe") || process.name().ends_with("Northstar.exe")) && !process.cmd().contains(&String::from("-dedicated")) { From 862845edb0f0f88f702dbcda41072798171e7318 Mon Sep 17 00:00:00 2001 From: Ombrezz <37753837+Ombrezz@users.noreply.github.com> Date: Thu, 14 Sep 2023 18:24:48 -0400 Subject: [PATCH 3/5] Fix false positives on Windows (maybe?) --- src-tauri/src/util.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src-tauri/src/util.rs b/src-tauri/src/util.rs index a10ad6cdb..ae10cc912 100644 --- a/src-tauri/src/util.rs +++ b/src-tauri/src/util.rs @@ -136,6 +136,7 @@ pub fn check_ea_app_or_origin_running() -> bool { /// Checks if Northstar process is running pub fn check_northstar_running() -> bool { let s = sysinfo::System::new_all(); + s.refresh_all(); for process in s.processes().values() { if (process.name().ends_with("Titanfall2.exe") || process.name().ends_with("Northstar.exe")) && !process.cmd().contains(&String::from("-dedicated")) From 93989aafdd84aa3cb6f52274e2d14ee269adbd55 Mon Sep 17 00:00:00 2001 From: Ombrezz Date: Thu, 14 Sep 2023 18:25:23 -0400 Subject: [PATCH 4/5] Clarify comment Co-authored-by: GeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com> --- src-tauri/src/util.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src-tauri/src/util.rs b/src-tauri/src/util.rs index a10ad6cdb..8f1389bbe 100644 --- a/src-tauri/src/util.rs +++ b/src-tauri/src/util.rs @@ -133,7 +133,7 @@ pub fn check_ea_app_or_origin_running() -> bool { x } -/// Checks if Northstar process is running +/// Checks if Northstar process is running (ignores dedicated server) pub fn check_northstar_running() -> bool { let s = sysinfo::System::new_all(); for process in s.processes().values() { From ecd39dc8b7828dc15ce8edd6182bf1b0a3661829 Mon Sep 17 00:00:00 2001 From: Ombrezz <37753837+Ombrezz@users.noreply.github.com> Date: Thu, 14 Sep 2023 18:29:03 -0400 Subject: [PATCH 5/5] Fix silly mistake --- src-tauri/src/util.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src-tauri/src/util.rs b/src-tauri/src/util.rs index 67db5db82..c5ac411ce 100644 --- a/src-tauri/src/util.rs +++ b/src-tauri/src/util.rs @@ -135,7 +135,7 @@ pub fn check_ea_app_or_origin_running() -> bool { /// Checks if Northstar process is running (ignores dedicated server) pub fn check_northstar_running() -> bool { - let s = sysinfo::System::new_all(); + let mut s = sysinfo::System::new_all(); s.refresh_all(); for process in s.processes().values() { if (process.name().ends_with("Titanfall2.exe") || process.name().ends_with("Northstar.exe"))