Skip to content

Commit 6b2542e

Browse files
authored
Start game exe directly if no game platform detected (SubnauticaNitrox#2590)
1 parent c586d7e commit 6b2542e

3 files changed

Lines changed: 32 additions & 4 deletions

File tree

Nitrox.Launcher/ViewModels/LaunchGameViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,12 +243,12 @@ private async Task StartGameAsync(GameInfo gameInfo, string[]? args = null)
243243
HeroicGames => await HeroicGames.StartGameAsync(gameInfo.EgsNamespace, launchArguments),
244244
MSStore => await MSStore.StartGameAsync(gameExePath, launchArguments),
245245
Discord => await Discord.StartGameAsync(gameExePath, launchArguments),
246-
_ => throw new Exception($"Directory '{NitroxUser.GamePath}' is not a valid {gameInfo.Name} game installation or the game platform is unsupported by Nitrox.")
246+
_ => await Standalone.StartGameAsync(gameExePath, launchArguments),
247247
};
248248

249249
if (game is null)
250250
{
251-
throw new Exception($"Game failed to start through {NitroxUser.GamePlatform.Name}");
251+
throw new Exception($"Game failed to start through {NitroxUser.GamePlatform?.Name ?? "Standalone"}");
252252
}
253253
}
254254

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System.IO;
2+
using System.Threading.Tasks;
3+
using Nitrox.Model.Helper;
4+
using Nitrox.Model.Platforms.OS.Shared;
5+
6+
namespace Nitrox.Model.Platforms.Store;
7+
8+
public static class Standalone
9+
{
10+
public static Task<ProcessEx> StartGameAsync(string pathToGameExe, string launchArguments)
11+
{
12+
return Task.FromResult(
13+
ProcessEx.Start(
14+
pathToGameExe,
15+
[(NitroxUser.LAUNCHER_PATH_ENV_KEY, NitroxUser.LauncherPath)],
16+
Path.GetDirectoryName(pathToGameExe),
17+
launchArguments
18+
)
19+
);
20+
}
21+
}

Nitrox.Model/Platforms/Store/Steam.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,21 @@ public sealed class Steam : IGamePlatform
2222

2323
private static string SteamProcessName => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "steam_osx" : "steam";
2424

25-
public bool OwnsGame(string gameRootPath) =>
26-
gameRootPath switch
25+
public bool OwnsGame(string gameRootPath)
26+
{
27+
if (GetExeFile() == null)
28+
{
29+
return false;
30+
}
31+
32+
return gameRootPath switch
2733
{
2834
not null when RuntimeInformation.IsOSPlatform(OSPlatform.OSX) => Directory.Exists(Path.Combine(gameRootPath, "Plugins", "steam_api.bundle")),
2935
not null when File.Exists(Path.Combine(gameRootPath, GameInfo.Subnautica.DataFolder, "Plugins", "x86_64", "steam_api64.dll")) => true,
3036
not null when File.Exists(Path.Combine(gameRootPath, GameInfo.Subnautica.DataFolder, "Plugins", "steam_api64.dll")) => true,
3137
_ => false
3238
};
39+
}
3340

3441
private static async Task<ProcessEx?> StartPlatformAsync()
3542
{

0 commit comments

Comments
 (0)