From 81da2a3cef022007b9ead25785294ff2734059c9 Mon Sep 17 00:00:00 2001 From: Starkku Date: Fri, 3 Jan 2025 17:45:16 +0200 Subject: [PATCH] Allow customizing default values for game networking settings in config It was possible to force them to specific values via ForcedSpawnIniOptions but this overwrote host-changed settings --- ClientCore/ClientConfiguration.cs | 19 +++++++++++++++++++ .../GameLobby/MultiplayerGameLobby.cs | 15 ++++++++++----- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/ClientCore/ClientConfiguration.cs b/ClientCore/ClientConfiguration.cs index cccd36eb3..baf3fa739 100644 --- a/ClientCore/ClientConfiguration.cs +++ b/ClientCore/ClientConfiguration.cs @@ -422,6 +422,25 @@ public IEnumerable SupplementalMapFileExtensions #endregion + #region Game networking defaults + + /// + /// Default value for FrameSendRate setting written in spawn.ini. + /// + public int DefaultFrameSendRate => clientDefinitionsIni.GetIntValue(SETTINGS, nameof(DefaultFrameSendRate), 7); + + /// + /// Default value for Protocol setting written in spawn.ini. + /// + public int DefaultProtocolVersion => clientDefinitionsIni.GetIntValue(SETTINGS, nameof(DefaultProtocolVersion), 2); + + /// + /// Default value for MaxAhead setting written in spawn.ini. + /// + public int DefaultMaxAhead => clientDefinitionsIni.GetIntValue(SETTINGS, nameof(DefaultMaxAhead), 0); + + #endregion + public List GetIRCServers() { List servers = []; diff --git a/DXMainClient/DXGUI/Multiplayer/GameLobby/MultiplayerGameLobby.cs b/DXMainClient/DXGUI/Multiplayer/GameLobby/MultiplayerGameLobby.cs index 36e1aeb92..f04458ae0 100644 --- a/DXMainClient/DXGUI/Multiplayer/GameLobby/MultiplayerGameLobby.cs +++ b/DXMainClient/DXGUI/Multiplayer/GameLobby/MultiplayerGameLobby.cs @@ -39,11 +39,11 @@ public MultiplayerGameLobby(WindowManager windowManager, string iniName, s => HideMapList()), new ChatBoxCommand("SHOWMAPS", "Show map list (game host only)".L10N("Client:Main:ChatboxCommandShowMapsHelp"), true, s => ShowMapList()), - new ChatBoxCommand("FRAMESENDRATE", "Change order lag / FrameSendRate (default 7) (game host only)".L10N("Client:Main:ChatboxCommandFrameSendRateHelp"), true, + new ChatBoxCommand("FRAMESENDRATE", string.Format("Change order lag / FrameSendRate (default {0}) (game host only)".L10N("Client:Main:ChatboxCommandFrameSendRateHelp"), ClientConfiguration.Instance.DefaultFrameSendRate), true, s => SetFrameSendRate(s)), - new ChatBoxCommand("MAXAHEAD", "Change MaxAhead (default 0) (game host only)".L10N("Client:Main:ChatboxCommandMaxAheadHelp"), true, + new ChatBoxCommand("MAXAHEAD", string.Format("Change MaxAhead (default {0}) (game host only)".L10N("Client:Main:ChatboxCommandMaxAheadHelp"), ClientConfiguration.Instance.DefaultMaxAhead), true, s => SetMaxAhead(s)), - new ChatBoxCommand("PROTOCOLVERSION", "Change ProtocolVersion (default 2) (game host only)".L10N("Client:Main:ChatboxCommandProtocolVersionHelp"), true, + new ChatBoxCommand("PROTOCOLVERSION", string.Format("Change ProtocolVersion (default {0}) (game host only)".L10N("Client:Main:ChatboxCommandProtocolVersionHelp"), ClientConfiguration.Instance.DefaultProtocolVersion), true, s => SetProtocolVersion(s)), new ChatBoxCommand("LOADMAP", "Load a custom map with given filename from /Maps/Custom/ folder.".L10N("Client:Main:ChatboxCommandLoadMapHelp"), true, LoadCustomMap), new ChatBoxCommand("RANDOMSTARTS", "Enables completely random starting locations (Tiberian Sun based games only).".L10N("Client:Main:ChatboxCommandRandomStartsHelp"), true, @@ -91,7 +91,7 @@ protected bool Locked protected TopBar TopBar; - protected int FrameSendRate { get; set; } = 7; + protected int FrameSendRate { get; set; } /// /// Controls the MaxAhead parameter. The default value of 0 means that @@ -100,7 +100,7 @@ protected bool Locked /// protected int MaxAhead { get; set; } - protected int ProtocolVersion { get; set; } = 2; + protected int ProtocolVersion { get; set; } protected List chatBoxCommands; @@ -122,6 +122,11 @@ public override void Initialize() base.Initialize(); + // Init default game network settings + FrameSendRate = ClientConfiguration.Instance.DefaultFrameSendRate; + ProtocolVersion = ClientConfiguration.Instance.DefaultProtocolVersion; + MaxAhead = ClientConfiguration.Instance.DefaultMaxAhead; + // DisableSpectatorReadyChecking = GameOptionsIni.GetBooleanValue("General", "DisableSpectatorReadyChecking", false); PingTextures = new Texture2D[5]