From 1c8d79741dad672167e98c9841bb3e10f2a45c73 Mon Sep 17 00:00:00 2001 From: dartasen Date: Sun, 25 Dec 2022 00:06:10 +0100 Subject: [PATCH 1/4] Bump assembly version to 1.7.1.0 --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 86cfd39584..9dcc9535c5 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,7 +1,7 @@ - 1.7.0.0 + 1.7.1.0 10 false false From ae5d8d9a27cd64ac785345d0df6407aa7ca822da Mon Sep 17 00:00:00 2001 From: dartasen Date: Sun, 25 Dec 2022 00:50:51 +0100 Subject: [PATCH 2/4] Fix for older windows version crashing launcher during firewall configuration --- NitroxLauncher/LauncherLogic.cs | 50 ++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 4 deletions(-) diff --git a/NitroxLauncher/LauncherLogic.cs b/NitroxLauncher/LauncherLogic.cs index 2546c5cc7d..28319581da 100644 --- a/NitroxLauncher/LauncherLogic.cs +++ b/NitroxLauncher/LauncherLogic.cs @@ -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"); } } From 2286395e1b51523ca46a84f82ad40d6a9953d7bd Mon Sep 17 00:00:00 2001 From: dartasen Date: Sun, 25 Dec 2022 19:19:58 +0100 Subject: [PATCH 3/4] Added specific message for each platform --- NitroxLauncher/Pages/LaunchGamePage.xaml.cs | 47 +++++++++++++++++++++ NitroxModel/Helper/NitroxUser.cs | 26 ++++++++++++ 2 files changed, 73 insertions(+) diff --git a/NitroxLauncher/Pages/LaunchGamePage.xaml.cs b/NitroxLauncher/Pages/LaunchGamePage.xaml.cs index 283ec0eb01..8717559228 100644 --- a/NitroxLauncher/Pages/LaunchGamePage.xaml.cs +++ b/NitroxLauncher/Pages/LaunchGamePage.xaml.cs @@ -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; @@ -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) { @@ -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(); diff --git a/NitroxModel/Helper/NitroxUser.cs b/NitroxModel/Helper/NitroxUser.cs index ddefb4f0ea..ca187610af 100644 --- a/NitroxModel/Helper/NitroxUser.cs +++ b/NitroxModel/Helper/NitroxUser.cs @@ -100,5 +100,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; + } + } } } From 156ba80b0e1eceb12bfb7901926e9355c25132ed Mon Sep 17 00:00:00 2001 From: dartasen Date: Sun, 25 Dec 2022 21:45:29 +0100 Subject: [PATCH 4/4] Added message for newest version upon server start --- NitroxModel/Helper/NitroxUser.cs | 1 + NitroxServer-Subnautica/Program.cs | 13 +++++++++++++ NitroxServer/Server.cs | 4 ++-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/NitroxModel/Helper/NitroxUser.cs b/NitroxModel/Helper/NitroxUser.cs index ca187610af..28e2c1b6e6 100644 --- a/NitroxModel/Helper/NitroxUser.cs +++ b/NitroxModel/Helper/NitroxUser.cs @@ -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; } diff --git a/NitroxServer-Subnautica/Program.cs b/NitroxServer-Subnautica/Program.cs index 42f2034b7d..57241ac37d 100644 --- a/NitroxServer-Subnautica/Program.cs +++ b/NitroxServer-Subnautica/Program.cs @@ -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(); diff --git a/NitroxServer/Server.cs b/NitroxServer/Server.cs index b9eb99c2ce..f4e509962d 100644 --- a/NitroxServer/Server.cs +++ b/NitroxServer/Server.cs @@ -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}");