From 4a037fed3f27ec73f52a2f3c1485d492d0d34a9c Mon Sep 17 00:00:00 2001
From: Jannify <23176718+Jannify@users.noreply.github.com>
Date: Fri, 5 Apr 2024 13:54:24 +0200
Subject: [PATCH] Address request changes and bugs
---
.../LanguageFiles/en.json | 15 +++++--------
.../Settings/NitroxSettingsManager.cs | 1 -
.../MainMenu/ServerJoin/JoinServerBackend.cs | 3 ---
.../ServerJoin/MainMenuJoinServerPanel.cs | 2 +-
.../ServersList/MainMenuServerListPanel.cs | 16 ++++++++++++--
NitroxModel/Core/NitroxServiceLocator.cs | 2 +-
.../SystemsSpawner_SetupSingleton_Patch.cs | 22 -------------------
7 files changed, 22 insertions(+), 39 deletions(-)
delete mode 100644 NitroxPatcher/Patches/Persistent/SystemsSpawner_SetupSingleton_Patch.cs
diff --git a/Nitrox.Assets.Subnautica/LanguageFiles/en.json b/Nitrox.Assets.Subnautica/LanguageFiles/en.json
index 5016e3b5e1..6bc005c136 100644
--- a/Nitrox.Assets.Subnautica/LanguageFiles/en.json
+++ b/Nitrox.Assets.Subnautica/LanguageFiles/en.json
@@ -1,14 +1,11 @@
{
"Nitrox_AddServer": "Add Server",
- "Nitrox_AddServer_NameDescription": "Name:",
- "Nitrox_AddServer_AddressDescription": "Host:",
- "Nitrox_AddServer_PortDescription": "Port:",
- "Nitrox_AddServer_NamePlaceholder": "Enter a name for the server",
- "Nitrox_AddServer_AddressPlaceholder": "Enter the IP or address of the server",
- "Nitrox_AddServer_PortPlaceholder": "Enter the numeric port of the server",
- "Nitrox_AddServer_Confirm": "Create server",
- "Nitrox_AddServer_Back": "Back",
- "Nitrox_AddServer_InvalidInput": "You input is invalid. Please check if all text boxes are filled out.",
+ "Nitrox_AddServerAdd": "Add",
+ "Nitrox_AddServerHost": "Host:",
+ "Nitrox_AddServerName": "Name:",
+ "Nitrox_AddServerPort": "Port:",
+ "Nitrox_BuildingDesyncDetected": "Server detected a desync with the local client's buildings (go to Nitrox settings to request a resync)",
+ "Nitrox_BuildingSettings": "Base building",
"Nitrox_Cancel": "Cancel",
"Nitrox_CommandNotAvailable": "This command is not available in Nitrox",
"Nitrox_ConnectTo": "Connect to",
diff --git a/NitroxClient/GameLogic/Settings/NitroxSettingsManager.cs b/NitroxClient/GameLogic/Settings/NitroxSettingsManager.cs
index ee9dc1892b..8c357405d0 100644
--- a/NitroxClient/GameLogic/Settings/NitroxSettingsManager.cs
+++ b/NitroxClient/GameLogic/Settings/NitroxSettingsManager.cs
@@ -48,7 +48,6 @@ private void MakeSettings()
BuildingHandler.Main.AskForResync();
}
}));
- MainMenuServerListPanel.Main.RefreshServerEntries();
AddSetting("Nitrox_BuildingSettings", new Setting("Nitrox_SafeBuilding", NitroxPrefs.SafeBuilding, safe => NitroxPrefs.SafeBuilding.Value = safe));
AddSetting("Nitrox_BuildingSettings", new Setting("Nitrox_SafeBuildingLog", NitroxPrefs.SafeBuildingLog, safeLog => NitroxPrefs.SafeBuildingLog.Value = safeLog));
diff --git a/NitroxClient/MonoBehaviours/Gui/MainMenu/ServerJoin/JoinServerBackend.cs b/NitroxClient/MonoBehaviours/Gui/MainMenu/ServerJoin/JoinServerBackend.cs
index d465e631ae..4582339d6d 100644
--- a/NitroxClient/MonoBehaviours/Gui/MainMenu/ServerJoin/JoinServerBackend.cs
+++ b/NitroxClient/MonoBehaviours/Gui/MainMenu/ServerJoin/JoinServerBackend.cs
@@ -1,6 +1,5 @@
using System.Collections;
using System.Diagnostics;
-using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
using NitroxClient.Communication.Abstract;
using NitroxClient.Communication.Exceptions;
@@ -100,7 +99,6 @@ private static void SessionConnectionStateChangedHandler(IMultiplayerSessionConn
}
}
- [SuppressMessage("Usage", "DIMA001:Dependency Injection container is used directly")]
public static async Task StartMultiplayerClientAsync(string ip, int port)
{
serverIp = ip;
@@ -147,7 +145,6 @@ public static async Task StartMultiplayerClientAsync(string ip, int port)
}
}
- [SuppressMessage("Usage", "DIMA001:Dependency Injection container is used directly")]
public static void StopMultiplayerClient()
{
if (!multiplayerClient || !Multiplayer.Main)
diff --git a/NitroxClient/MonoBehaviours/Gui/MainMenu/ServerJoin/MainMenuJoinServerPanel.cs b/NitroxClient/MonoBehaviours/Gui/MainMenu/ServerJoin/MainMenuJoinServerPanel.cs
index 876da84000..9901af1315 100644
--- a/NitroxClient/MonoBehaviours/Gui/MainMenu/ServerJoin/MainMenuJoinServerPanel.cs
+++ b/NitroxClient/MonoBehaviours/Gui/MainMenu/ServerJoin/MainMenuJoinServerPanel.cs
@@ -120,7 +120,7 @@ private static void OnCancelClick()
public void UpdatePanelValues(string ip, string playerName, Vector3 hsb)
{
- header.text = $" {Language.main.Get("Nitrox_JoinServer")}{ip}";
+ header.text = $" {Language.main.Get("Nitrox_JoinServer")} {ip}";
playerNameInputField.text = playerName;
colorPicker.SetHSB(hsb);
}
diff --git a/NitroxClient/MonoBehaviours/Gui/MainMenu/ServersList/MainMenuServerListPanel.cs b/NitroxClient/MonoBehaviours/Gui/MainMenu/ServersList/MainMenuServerListPanel.cs
index 110082814a..e5e8556832 100644
--- a/NitroxClient/MonoBehaviours/Gui/MainMenu/ServersList/MainMenuServerListPanel.cs
+++ b/NitroxClient/MonoBehaviours/Gui/MainMenu/ServersList/MainMenuServerListPanel.cs
@@ -43,7 +43,13 @@ public void Setup(GameObject savedGamesRef)
CreateAddServerButton();
LoadSavedServers();
- _ = FindLANServersAsync();
+ FindLANServersAsync().ContinueWith(t =>
+ {
+ if (t is { IsFaulted: true, Exception: { } ex })
+ {
+ Log.Warn($"Failed to execute FindLANServersAsync: {ex.GetFirstNonAggregateMessage()}");
+ }
+ });
}
public bool OnButtonDown(GameInput.Button button)
@@ -272,6 +278,12 @@ public void RefreshServerEntries()
CreateAddServerButton();
LoadSavedServers();
- _ = FindLANServersAsync();
+ FindLANServersAsync().ContinueWith(t =>
+ {
+ if (t is { IsFaulted: true, Exception: { } ex })
+ {
+ Log.Warn($"Failed to execute FindLANServersAsync: {ex.GetFirstNonAggregateMessage()}");
+ }
+ });
}
}
diff --git a/NitroxModel/Core/NitroxServiceLocator.cs b/NitroxModel/Core/NitroxServiceLocator.cs
index 4c6893ec5c..3c7fc20111 100644
--- a/NitroxModel/Core/NitroxServiceLocator.cs
+++ b/NitroxModel/Core/NitroxServiceLocator.cs
@@ -150,7 +150,7 @@ private static T LocateServicePreLifetimeAndRegister()
///
/// Invalidates the cache for type . The next access will request from again.
///
- public static void Invalidate(object _, EventArgs __)
+ private static void Invalidate(object _, EventArgs __)
{
value = null;
LifetimeScopeEnded -= Invalidate;
diff --git a/NitroxPatcher/Patches/Persistent/SystemsSpawner_SetupSingleton_Patch.cs b/NitroxPatcher/Patches/Persistent/SystemsSpawner_SetupSingleton_Patch.cs
deleted file mode 100644
index dc48a687b0..0000000000
--- a/NitroxPatcher/Patches/Persistent/SystemsSpawner_SetupSingleton_Patch.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using System;
-using System.Reflection;
-using HarmonyLib;
-using NitroxModel.Helper;
-
-namespace NitroxPatcher.Patches.Persistent;
-
-///
-/// Patch to suppress SentrySdk NRE as it's destroyed by us
-///
-public sealed partial class SystemsSpawner_SetupSingleton_Patch : NitroxPatch, IPersistentPatch
-{
- private static readonly MethodInfo TARGET_METHOD = AccessTools.EnumeratorMoveNext(Reflect.Method((SystemsSpawner s) => s.SetupSingleton(default)));
-
- public static void Finalizer(ref Exception __exception)
- {
- if (__exception is NullReferenceException)
- {
- __exception = null;
- }
- }
-}