diff --git a/Directory.Build.props b/Directory.Build.props index 86cfd3958..9dcc9535c 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,7 +1,7 @@ - 1.7.0.0 + 1.7.1.0 10 false false diff --git a/NitroxLauncher/LauncherLogic.cs b/NitroxLauncher/LauncherLogic.cs index 2546c5cc7..28319581d 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"); } } diff --git a/NitroxLauncher/Pages/LaunchGamePage.xaml.cs b/NitroxLauncher/Pages/LaunchGamePage.xaml.cs index 283ec0eb0..871755922 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 ddefb4f0e..28e2c1b6e 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; } @@ -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; + } + } } } diff --git a/NitroxServer-Subnautica/Program.cs b/NitroxServer-Subnautica/Program.cs index 42f2034b7..57241ac37 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 b9eb99c2c..f4e509962 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}");