From f97ad4eac0fc9db9f8886de654d375e1a8dbbf7d Mon Sep 17 00:00:00 2001
From: Lightczx <1686188646@qq.com>
Date: Thu, 26 Oct 2023 14:12:45 +0800
Subject: [PATCH] fix IsGameRunning
---
.../Snap.Hutao/Service/DailyNote/DailyNoteOptions.cs | 4 ++--
src/Snap.Hutao/Snap.Hutao/Service/Game/GameService.cs | 5 +++--
.../Snap.Hutao/Service/Game/Unlocker/GameFpsUnlocker.cs | 5 +----
src/Snap.Hutao/Snap.Hutao/View/Control/StatisticsCard.xaml | 1 -
4 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/src/Snap.Hutao/Snap.Hutao/Service/DailyNote/DailyNoteOptions.cs b/src/Snap.Hutao/Snap.Hutao/Service/DailyNote/DailyNoteOptions.cs
index bcabcfae..819c8a50 100644
--- a/src/Snap.Hutao/Snap.Hutao/Service/DailyNote/DailyNoteOptions.cs
+++ b/src/Snap.Hutao/Snap.Hutao/Service/DailyNote/DailyNoteOptions.cs
@@ -76,7 +76,7 @@ internal sealed partial class DailyNoteOptions : DbStoreOptions
{
if (runtimeOptions.IsElevated)
{
- // leave below untouched if we are running in elevated privilege
+ // leave untouched when we are running in elevated privilege
return null;
}
@@ -87,7 +87,7 @@ internal sealed partial class DailyNoteOptions : DbStoreOptions
{
if (runtimeOptions.IsElevated)
{
- // leave below untouched if we are running in elevated privilege
+ // leave untouched when we are running in elevated privilege
return;
}
diff --git a/src/Snap.Hutao/Snap.Hutao/Service/Game/GameService.cs b/src/Snap.Hutao/Snap.Hutao/Service/Game/GameService.cs
index 5ff9e19f..ec6fea39 100644
--- a/src/Snap.Hutao/Snap.Hutao/Service/Game/GameService.cs
+++ b/src/Snap.Hutao/Snap.Hutao/Service/Game/GameService.cs
@@ -222,8 +222,8 @@ internal sealed partial class GameService : IGameService
return false;
}
- return Process.GetProcessesByName(YuanShenProcessName) is [_, ..]
- || Process.GetProcessesByName(GenshinImpactProcessName) is [_, ..];
+ return Process.GetProcessesByName(YuanShenProcessName).Any()
+ || Process.GetProcessesByName(GenshinImpactProcessName).Any();
}
///
@@ -242,6 +242,7 @@ internal sealed partial class GameService : IGameService
{
try
{
+ Interlocked.Increment(ref runningGamesCounter);
game.Start();
progress.Report(new(LaunchPhase.ProcessStarted, SH.ServiceGameLaunchPhaseProcessStarted));
diff --git a/src/Snap.Hutao/Snap.Hutao/Service/Game/Unlocker/GameFpsUnlocker.cs b/src/Snap.Hutao/Snap.Hutao/Service/Game/Unlocker/GameFpsUnlocker.cs
index b7d3178b..21bba708 100644
--- a/src/Snap.Hutao/Snap.Hutao/Service/Game/Unlocker/GameFpsUnlocker.cs
+++ b/src/Snap.Hutao/Snap.Hutao/Service/Game/Unlocker/GameFpsUnlocker.cs
@@ -72,10 +72,7 @@ internal sealed class GameFpsUnlocker : IGameFpsUnlocker
{
ulong temp = 0;
bool result = ReadProcessMemory((HANDLE)process.Handle, (void*)baseAddress, (byte*)&temp, 8);
- if (!result)
- {
- ThrowHelper.InvalidOperation(SH.ServiceGameUnlockerReadProcessMemoryPointerAddressFailed, null);
- }
+ Verify.Operation(result, SH.ServiceGameUnlockerReadProcessMemoryPointerAddressFailed);
value = (nuint)temp;
return result;
diff --git a/src/Snap.Hutao/Snap.Hutao/View/Control/StatisticsCard.xaml b/src/Snap.Hutao/Snap.Hutao/View/Control/StatisticsCard.xaml
index 5b3dfc4d..388f4d05 100644
--- a/src/Snap.Hutao/Snap.Hutao/View/Control/StatisticsCard.xaml
+++ b/src/Snap.Hutao/Snap.Hutao/View/Control/StatisticsCard.xaml
@@ -212,7 +212,6 @@
-