diff --git a/QSB/QSBCore.cs b/QSB/QSBCore.cs index 955f299e..9cf2191f 100644 --- a/QSB/QSBCore.cs +++ b/QSB/QSBCore.cs @@ -58,6 +58,7 @@ public class QSBCore : ModBehaviour Application.version.Split('.').Take(3).Join(delimiter: "."); public static bool DLCInstalled => EntitlementsManager.IsDlcOwned() == EntitlementsManager.AsyncOwnershipStatus.Owned; public static bool IncompatibleModsAllowed { get; private set; } + public static bool ShowPlayerNames { get; private set; } public static bool ShipDamage { get; private set; } public static GameVendor GameVendor { get; private set; } = GameVendor.None; public static bool IsStandalone => GameVendor is GameVendor.Epic or GameVendor.Steam; @@ -245,24 +246,14 @@ public class QSBCore : ModBehaviour { DefaultServerIP = config.GetSettingsValue("defaultServerIP"); IncompatibleModsAllowed = config.GetSettingsValue("incompatibleModsAllowed"); - if (!IsInMultiplayer) - { - ServerSettingsManager.ShowPlayerNames = config.GetSettingsValue("showPlayerNames"); - } - else if (IsHost) - { - var _showPlayerNames = config.GetSettingsValue("showPlayerNames"); - if (_showPlayerNames != ServerSettingsManager.ShowPlayerNames) - { - new ServerSettingsMessage().Send(); - } - ServerSettingsManager.ShowPlayerNames = _showPlayerNames; - } - else - { - config.SetSettingsValue("showPlayerNames", ServerSettingsManager.ShowPlayerNames); - } + ShowPlayerNames = config.GetSettingsValue("showPlayerNames"); ShipDamage = config.GetSettingsValue("shipDamage"); + + if (IsHost) + { + ServerSettingsManager.ServerShowPlayerNames = ShowPlayerNames; + new ServerSettingsMessage().Send(); + } } private void Update() diff --git a/QSB/ServerSettings/ServerSettingsManager.cs b/QSB/ServerSettings/ServerSettingsManager.cs index 42710214..505f0ba2 100644 --- a/QSB/ServerSettings/ServerSettingsManager.cs +++ b/QSB/ServerSettings/ServerSettingsManager.cs @@ -5,5 +5,6 @@ namespace QSB.ServerSettings; internal class ServerSettingsManager : MonoBehaviour, IAddComponentOnStart { - public static bool ShowPlayerNames; + public static bool ServerShowPlayerNames; + public static bool ShowPlayerNames => (ServerShowPlayerNames || QSBCore.IsHost) && QSBCore.ShowPlayerNames; } diff --git a/QSB/ServerSettings/ServerSettingsMessage.cs b/QSB/ServerSettings/ServerSettingsMessage.cs index 9d857a60..1b88b00c 100644 --- a/QSB/ServerSettings/ServerSettingsMessage.cs +++ b/QSB/ServerSettings/ServerSettingsMessage.cs @@ -8,9 +8,7 @@ internal class ServerSettingsMessage : QSBMessage private bool _showPlayerNames; public ServerSettingsMessage() - { - _showPlayerNames = ServerSettingsManager.ShowPlayerNames; - } + => _showPlayerNames = QSBCore.ShowPlayerNames; public override void Serialize(NetworkWriter writer) { @@ -25,8 +23,5 @@ internal class ServerSettingsMessage : QSBMessage } public override void OnReceiveRemote() - { - ServerSettingsManager.ShowPlayerNames = _showPlayerNames; - QSBCore.Helper.Config.SetSettingsValue("showPlayerNames", _showPlayerNames); - } + => ServerSettingsManager.ServerShowPlayerNames = _showPlayerNames; }