remove variable from QSBCore, only allow setting as host (or when not in multiplayer), fix the message

This commit is contained in:
JohnCorby 2022-11-07 12:25:54 -08:00
parent 9c4c80eb36
commit 108561adb7
2 changed files with 19 additions and 8 deletions

View File

@ -58,7 +58,6 @@ 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 GameVendor GameVendor { get; private set; } = GameVendor.None;
public static bool IsStandalone => GameVendor is GameVendor.Epic or GameVendor.Steam;
public static IProfileManager ProfileManager => IsStandalone
@ -245,14 +244,21 @@ public class QSBCore : ModBehaviour
{
DefaultServerIP = config.GetSettingsValue<string>("defaultServerIP");
IncompatibleModsAllowed = config.GetSettingsValue<bool>("incompatibleModsAllowed");
var _showPlayerNames = config.GetSettingsValue<bool>("showPlayerNames");
if (_showPlayerNames != ShowPlayerNames)
if (!IsInMultiplayer || IsHost)
{
new ServerSettingsMessage().Send();
}
var _showPlayerNames = config.GetSettingsValue<bool>("showPlayerNames");
ShowPlayerNames = _showPlayerNames;
if (_showPlayerNames != ServerSettingsManager.ShowPlayerNames)
{
new ServerSettingsMessage().Send();
}
ServerSettingsManager.ShowPlayerNames = _showPlayerNames;
}
else
{
config.SetSettingsValue("showPlayerNames", ServerSettingsManager.ShowPlayerNames);
}
}
private void Update()

View File

@ -7,10 +7,15 @@ internal class ServerSettingsMessage : QSBMessage
{
private bool _showPlayerNames;
public ServerSettingsMessage()
{
_showPlayerNames = ServerSettingsManager.ShowPlayerNames;
}
public override void Serialize(NetworkWriter writer)
{
base.Serialize(writer);
writer.Write(QSBCore.ShowPlayerNames);
writer.Write(_showPlayerNames);
}
public override void Deserialize(NetworkReader reader)