Skip to content

Commit 50e3f01

Browse files
committed
fix(steam): Encapsulate debug statements & fix double-launch issue
1 parent ba7e632 commit 50e3f01

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

Hi3Helper.Plugin.Wuwa/Exports.GameLaunch.Steam.cs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace Hi3Helper.Plugin.Wuwa;
1313
public partial class Exports
1414
{
15-
private const string SteamLaunchUri = "steam://run/3513350"; // 3513350 is Wuthering Waves' Steam AppID
15+
private const string SteamLaunchUri = "steam://nav/games/details/3513350"; // Wuthering Waves Steam AppID, game launches through Collapse and is picked up by Steam
1616
private bool IsSteamLoading = false;
1717
private DateTime? SteamStartTime = null;
1818
private Process[] SteamProcesses = [];
@@ -48,20 +48,27 @@ private async Task<bool> TryInitializeSteamLauncher(GameManagerExtension.RunGame
4848
int delay = 0;
4949
while (SteamProcesses.Length == 0 && delay < 15000)
5050
{
51-
SteamProcesses = Process.GetProcessesByName("steamwebhelper");
52-
53-
await Task.Delay(200, token);
54-
delay += 200;
51+
SteamProcesses = Process.GetProcessesByName("Steam");
52+
#if DEBUG
53+
SharedStatic.InstanceLogger.LogDebug($"Searching for Steam process... Found {SteamProcesses.Length} processes.");
54+
#endif
55+
await Task.Delay(10000, token); // Yes this is required because Steam is slow to start
56+
delay += 10000;
5557
}
5658

5759
if (SteamProcesses.Length > 0)
5860
{
5961
foreach (Process p1 in SteamProcesses)
6062
{
6163
p1.Refresh();
64+
#if DEBUG
65+
SharedStatic.InstanceLogger.LogDebug($"Checking Steam process ID {p1.Id} for main window handle...");
66+
#endif
6267
if (p1.MainWindowHandle != IntPtr.Zero)
6368
{
69+
#if DEBUG
6470
SharedStatic.InstanceLogger.LogDebug($"Found Steam main window handle: {p1.MainWindowHandle}");
71+
#endif
6572
while (!WaitForMainHandle(p1, token).Result)
6673
{
6774
await Task.Delay(200, token);
@@ -84,9 +91,10 @@ async static Task<bool> WaitForMainHandle(Process p, CancellationToken token)
8491
return true;
8592
}
8693

87-
8894
IsSteamLoading = false;
95+
#if DEBUG
8996
SharedStatic.InstanceLogger.LogDebug($"Steam should be done loading by now...");
97+
#endif
9098

9199
return true;
92100
}

0 commit comments

Comments
 (0)