Skip to content

Commit

Permalink
Allow customizing default values for game networking settings in config
Browse files Browse the repository at this point in the history
It was possible to force them to specific values via ForcedSpawnIniOptions but this overwrote host-changed settings
  • Loading branch information
Starkku committed Jan 3, 2025
1 parent a0f2d15 commit 81da2a3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
19 changes: 19 additions & 0 deletions ClientCore/ClientConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,25 @@ public IEnumerable<string> SupplementalMapFileExtensions

#endregion

#region Game networking defaults

/// <summary>
/// Default value for FrameSendRate setting written in spawn.ini.
/// </summary>
public int DefaultFrameSendRate => clientDefinitionsIni.GetIntValue(SETTINGS, nameof(DefaultFrameSendRate), 7);

/// <summary>
/// Default value for Protocol setting written in spawn.ini.
/// </summary>
public int DefaultProtocolVersion => clientDefinitionsIni.GetIntValue(SETTINGS, nameof(DefaultProtocolVersion), 2);

/// <summary>
/// Default value for MaxAhead setting written in spawn.ini.
/// </summary>
public int DefaultMaxAhead => clientDefinitionsIni.GetIntValue(SETTINGS, nameof(DefaultMaxAhead), 0);

#endregion

public List<string> GetIRCServers()
{
List<string> servers = [];
Expand Down
15 changes: 10 additions & 5 deletions DXMainClient/DXGUI/Multiplayer/GameLobby/MultiplayerGameLobby.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,

This comment has been minimized.

Copy link
@SadPencil

SadPencil Jan 3, 2025

Member

Suggest using different L10N key names for those 3

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,
Expand Down Expand Up @@ -91,7 +91,7 @@ protected bool Locked

protected TopBar TopBar;

protected int FrameSendRate { get; set; } = 7;
protected int FrameSendRate { get; set; }

/// <summary>
/// Controls the MaxAhead parameter. The default value of 0 means that
Expand All @@ -100,7 +100,7 @@ protected bool Locked
/// </summary>
protected int MaxAhead { get; set; }

protected int ProtocolVersion { get; set; } = 2;
protected int ProtocolVersion { get; set; }

protected List<ChatBoxCommand> chatBoxCommands;

Expand All @@ -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]
Expand Down

0 comments on commit 81da2a3

Please sign in to comment.