fix player name setting

This commit is contained in:
_nebula 2022-12-02 22:27:23 +00:00
parent 3ea84f889e
commit 0a97b992b2
3 changed files with 12 additions and 25 deletions

View File

@ -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<string>("defaultServerIP");
IncompatibleModsAllowed = config.GetSettingsValue<bool>("incompatibleModsAllowed");
if (!IsInMultiplayer)
{
ServerSettingsManager.ShowPlayerNames = config.GetSettingsValue<bool>("showPlayerNames");
}
else if (IsHost)
{
var _showPlayerNames = config.GetSettingsValue<bool>("showPlayerNames");
if (_showPlayerNames != ServerSettingsManager.ShowPlayerNames)
{
new ServerSettingsMessage().Send();
}
ServerSettingsManager.ShowPlayerNames = _showPlayerNames;
}
else
{
config.SetSettingsValue("showPlayerNames", ServerSettingsManager.ShowPlayerNames);
}
ShowPlayerNames = config.GetSettingsValue<bool>("showPlayerNames");
ShipDamage = config.GetSettingsValue<bool>("shipDamage");
if (IsHost)
{
ServerSettingsManager.ServerShowPlayerNames = ShowPlayerNames;
new ServerSettingsMessage().Send();
}
}
private void Update()

View File

@ -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;
}

View File

@ -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;
}