Skip to content

Commit

Permalink
Merge pull request #1941 from dartasen/version/1.7.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dartasen authored Dec 26, 2022
2 parents 0b06511 + 156ba80 commit 820e2f2
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project InitialTargets="PrepareForModding">
<!-- Set default properties for all projects (can be overridden per project) -->
<PropertyGroup>
<Version>1.7.0.0</Version>
<Version>1.7.1.0</Version>
<LangVersion>10</LangVersion>
<NitroxProject>false</NitroxProject>
<TestLibrary>false</TestLibrary>
Expand Down
50 changes: 46 additions & 4 deletions NitroxLauncher/LauncherLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,54 @@ await Task.Factory.StartNew(async () =>
[Conditional("RELEASE")]
public async void ConfigureFirewall()
{
Task task = Task.Run(() => WindowsHelper.CheckFirewallRules());
await task;
Log.Info($"Using {Environment.OSVersion}");

if (task.Exception != null)
if (Environment.OSVersion.Platform != PlatformID.Win32NT)
{
MessageBox.Show($"An error occurred configuring the firewall: {task.Exception}");
return;
}

/**
This feature won't work in older windows version and will crash the launcher instantly
Windows Vista : 6.0
Windows 7 : 6.1
Windows 8 : 6.2, Windows 8.1 : 6.3
Windows 10/11 : 10.0
**/
if (Environment.OSVersion.Version.Major <= 6)
{
return;
}

CancellationTokenSource cancellationTokenSource = new();
Task task = Task.Run(() => WindowsHelper.CheckFirewallRules(), cancellationTokenSource.Token);

try
{
cancellationTokenSource.CancelAfter(millisecondsDelay: 10000);

await task.ConfigureAwait(false);

if (task.Exception != null)
{
throw task.Exception;
}
}
catch (OperationCanceledException ex)
{
Log.Error(ex, "Firewall configuration took way too long");
LauncherNotifier.Error("Unable to configure firewall rules");
}
catch (AggregateException ex)
{
ex.Flatten().InnerExceptions.ForEach(exception => Log.Error(exception));
LauncherNotifier.Error("Unable to configure firewall rules");
}
catch (Exception ex)
{
Log.Error(ex, "Fatal error while configuring firewall");
LauncherNotifier.Error("Fatal error while configuring firewall");
}
}

Expand Down
47 changes: 47 additions & 0 deletions NitroxLauncher/Pages/LaunchGamePage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using NitroxLauncher.Models;
using NitroxModel;
using NitroxModel.Discovery;
Expand Down Expand Up @@ -32,9 +34,12 @@ public LaunchGamePage()

private async void SinglePlayerButton_Click(object sender, RoutedEventArgs e)
{
LauncherNotifier.Info("Launching singleplayer Subnautica ...");

try
{
await LauncherLogic.Instance.StartSingleplayerAsync();

}
catch (Exception ex)
{
Expand All @@ -44,6 +49,48 @@ private async void SinglePlayerButton_Click(object sender, RoutedEventArgs e)

private async void MultiplayerButton_Click(object sender, RoutedEventArgs e)
{
if (sender is not Button button)
{
return;
}

switch (GamePlatform)
{
case Platform.MICROSOFT:
button.Background = new SolidColorBrush(Colors.Red);
MessageBox.Show("Sorry, due to technical problems Nitrox isn't yet compatible with Subnautica on Microsoft Store\n\nWe're doing our best to give you the opportunity to be able to play again soon.", "Error while starting in multiplayer mode", MessageBoxButton.OK, MessageBoxImage.Error);
return;

case Platform.STEAM:

if (!NitroxUser.IsNewestSubnautica.GetValueOrDefault(false))
{
break;
}

button.Background = new SolidColorBrush(Colors.Red);
MessageBox.Show(
"Due to Subnautica's recent update \"Living Large\", Nitrox is currently not compatible.\nHowever you can still use older version of Subnautica in order to play Nitrox. You can do so by following these steps.\n\nENSURE NITROX AND SUBNAUTICA ARE CLOSED BEFORE PROCEEDING!\n\nChanging Subnautica to Legacy Build on STEAM:\n\n1. Right click Subnautica in Steam\n2. Click Properties\n3. Click Betas\n4. Select Legacy - Public legacy builds\n5. Close it out and let Steam download and install the Legacy version of Subnautica\n6. Run Subnautica through Steam (It will say \"Subnautica [legacy]\" in your library if you did it right)\n7. Launch Subnautica through Nitrox to play.",
"Nitrox requires your attention",
MessageBoxButton.OK,
MessageBoxImage.Information
);
return;

case Platform.EPIC:

if (!NitroxUser.IsNewestSubnautica.GetValueOrDefault(false))
{
break;
}

button.Background = new SolidColorBrush(Colors.Red);
MessageBox.Show("Due to Subnautica's recent update \"Living Large\", Epic Games is currently not compatible with Nitrox.\n\nWe are working on an update we do not have an estimate as to when it is done.", "Error while starting in multiplayer mode", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}

LauncherNotifier.Info("Launching Subnautica ...");

try
{
await LauncherLogic.Instance.StartMultiplayerAsync();
Expand Down
27 changes: 27 additions & 0 deletions NitroxModel/Helper/NitroxUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public static string GamePath
string path = GameInstallationFinder.Instance.FindGame(errors);
if (!string.IsNullOrWhiteSpace(path) && Directory.Exists(path))
{
GamePlatform = GamePlatforms.GetPlatformByGameDir(path);
return gamePath = path;
}

Expand All @@ -100,5 +101,31 @@ public static string GamePath
GamePlatform = GamePlatforms.GetPlatformByGameDir(gamePath);
}
}

public static bool? IsNewestSubnautica
{
get
{
if (string.IsNullOrWhiteSpace(GamePath))
{
return null;
}

string streamingAssetsFolder = Path.Combine(GamePath, "Subnautica_Data", "StreamingAssets");
string aaFolder = Path.Combine(streamingAssetsFolder, "aa");

if (!Directory.Exists(streamingAssetsFolder)) {
// Probably authorization exception
return null;
}

if (File.Exists(Path.Combine(aaFolder, "catalog.json")) && File.Exists(Path.Combine(aaFolder, "settings.json")))
{
return true;
}

return false;
}
}
}
}
13 changes: 13 additions & 0 deletions NitroxServer-Subnautica/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,19 @@ private static async Task StartServer(string[] args)
});
}

if (NitroxUser.IsNewestSubnautica.GetValueOrDefault(false))
{
Log.Error("Due to Subnautica's recent update \"Living Large\", Nitrox is currently not compatible. However you can still use older version of Subnautica in order to play Nitrox. You can do so by following these steps");

if (NitroxUser.GamePlatform?.Platform == Platform.STEAM)
{
Log.Warn("ENSURE NITROX AND SUBNAUTICA ARE CLOSED BEFORE PROCEEDING!");
Log.Warn("Changing Subnautica to Legacy Build on STEAM:\n1. Right click Subnautica in Steam\n2. Click Properties\n3. Click Betas\n4. Select Legacy - Public legacy builds\n5. Close it out and let Steam download and install the Legacy version of Subnautica\n6. Run Subnautica through Steam (It will say \"Subnautica [legacy]\" in your library if you did it right)\n7. Launch Subnautica through Nitrox to play.");
}

throw new Exception("Unable to start server, Nitrox isn't compatible with this Subnautica version");
}

NitroxServiceLocator.InitializeDependencyContainer(new SubnauticaServerAutoFacRegistrar());
NitroxServiceLocator.BeginNewLifetimeScope();

Expand Down
4 changes: 2 additions & 2 deletions NitroxServer/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ public Server(WorldPersistence worldPersistence, World world, ServerConfig serve

public string GetSaveSummary(Perms viewerPerms = Perms.CONSOLE)
{
// TODO: Extend summary with more useful save file data
// Note for later additions: order these lines by their length
StringBuilder builder = new("\n");

if (viewerPerms is Perms.CONSOLE)
{
builder.AppendLine($" - Save location: {Path.GetFullPath(serverConfig.SaveName)}");
}

builder.AppendLine($" - Aurora's state: {world.EventTriggerer.GetAuroraStateSummary()}");
builder.AppendLine($" - Current time: day {world.EventTriggerer.Day} ({Math.Floor(world.EventTriggerer.ElapsedSeconds)}s)");
builder.AppendLine($" - Scheduled goals stored: {world.GameData.StoryGoals.ScheduledGoals.Count}");
Expand Down

0 comments on commit 820e2f2

Please sign in to comment.