Skip to content

Commit

Permalink
Fixed GameInstallationFinder for Below Zero
Browse files Browse the repository at this point in the history
  • Loading branch information
VELD-Dev authored and Coding-Hen committed Jun 13, 2023
1 parent 4fc20b6 commit fc2231e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
10 changes: 9 additions & 1 deletion Nitrox.BuildTool/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
Expand All @@ -22,7 +22,11 @@ public static class Program

public static string GeneratedOutputDir => Path.Combine(ProcessDir, "generated_files");

#if BELOWZERO
private const int LEGACY_BRANCH_SUBNAUTICA_VERSION = 49370;
#elif SUBNAUTICA
private const int LEGACY_BRANCH_SUBNAUTICA_VERSION = 68598;
#endif

public static async Task Main(string[] args)
{
Expand Down Expand Up @@ -58,7 +62,11 @@ private static void LogError(string message)

private static void AbortIfInvalidGameVersion(GameInstallData game)
{
#if BELOWZERO
string gameVersionFile = Path.Combine(game.InstallDir, "SubnauticaZero_Data", "StreamingAssets", "SNUnmanagedData", "plastic_status.ignore");
#elif SUBNAUTICA
string gameVersionFile = Path.Combine(game.InstallDir, "Subnautica_Data", "StreamingAssets", "SNUnmanagedData", "plastic_status.ignore");
#endif
if (!File.Exists(gameVersionFile))
{
return;
Expand Down
5 changes: 2 additions & 3 deletions NitroxModel/Discovery/GameInstallationFinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,9 @@ public static bool IsSubnauticaDirectory(string directory)
#if SUBNAUTICA
return Directory.EnumerateFiles(directory, "*.exe")
.Any(file => Path.GetFileName(file)?.Equals("subnautica.exe", StringComparison.OrdinalIgnoreCase) ?? false);
#endif
#if BELOWZERO
#elif BELOWZERO
return Directory.EnumerateFiles(directory, "*.exe")
.Any(file => Path.GetFileName(file)?.Equals("subnauticazero.exe", StringComparison.OrdinalIgnoreCase) ?? false);
.Any(file => Path.GetFileName(file)?.Equals("subnauticazero.exe", StringComparison.OrdinalIgnoreCase) ?? false);
#endif
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
Expand Down Expand Up @@ -36,6 +36,7 @@ public string FindGame(IList<string> errors = null)
return null;
}
string appsPath = Path.Combine(steamPath, "steamapps");
#if SUBNAUTICA
if (File.Exists(Path.Combine(appsPath, $"appmanifest_{GameInfo.Subnautica.SteamAppId}.acf")))
{
return Path.Combine(appsPath, "common", GameInfo.Subnautica.Name);
Expand All @@ -49,6 +50,21 @@ public string FindGame(IList<string> errors = null)
{
return path;
}
#elif BELOWZERO
if(File.Exists(Path.Combine(appsPath, $"appmanifest_{GameInfo.SubnauticaBelowZero.SteamAppId}.acf")))
{
return Path.Combine(appsPath, "common", GameInfo.SubnauticaBelowZero.Name);
}
string path = SearchAllInstallations(Path.Combine(appsPath, "libraryfolders.vdf"), GameInfo.SubnauticaBelowZero.SteamAppId, GameInfo.SubnauticaBelowZero.Name);
if(string.IsNullOrEmpty(path))
{
errors?.Add($"It appears you don't have {GameInfo.SubnauticaBelowZero.Name} installed anywhere. The game files are needed to run the server");
}
else
{
return path;
}
#endif

return null;
}
Expand Down

0 comments on commit fc2231e

Please sign in to comment.