From 2424ddc79aaee44bdec0b1085afdea7b0599719a Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 4 Sep 2021 13:21:43 +0100 Subject: [PATCH] Move NetTickScale (now NetFrameInterval) control to the server. --- OpenRA.Game/Game.cs | 1 - OpenRA.Game/Network/OrderManager.cs | 8 +++++--- OpenRA.Game/Network/Session.cs | 3 +++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index 02f87a76e5..1c50bb9461 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -30,7 +30,6 @@ namespace OpenRA { public static class Game { - public const int NetTickScale = 3; // 120 ms net tick for 40 ms local tick public const int TimestepJankThreshold = 250; // Don't catch up for delays larger than 250ms public static InstalledMods Mods { get; private set; } diff --git a/OpenRA.Game/Network/OrderManager.cs b/OpenRA.Game/Network/OrderManager.cs index 0801246dc2..61d08edda3 100644 --- a/OpenRA.Game/Network/OrderManager.cs +++ b/OpenRA.Game/Network/OrderManager.cs @@ -280,7 +280,7 @@ namespace OpenRA.Network { var shouldTick = true; - if (IsNetTick) + if (IsNetFrame) { // Check whether or not we will be ready for a tick next frame // We don't need to include ourselves in the equation because we can always generate orders this frame @@ -293,7 +293,7 @@ namespace OpenRA.Network } var willTick = shouldTick; - if (willTick && IsNetTick) + if (willTick && IsNetFrame) { willTick = IsReadyForNextFrame; if (willTick) @@ -306,6 +306,8 @@ namespace OpenRA.Network return willTick; } - bool IsNetTick => LocalFrameNumber % Game.NetTickScale == 0; + // The server may request clients to batch multiple frames worth of orders into a single packet + // to improve robustness against network jitter at the expense of input latency + bool IsNetFrame => LocalFrameNumber % LobbyInfo.GlobalSettings.NetFrameInterval == 0; } } diff --git a/OpenRA.Game/Network/Session.cs b/OpenRA.Game/Network/Session.cs index 64dff89ba7..307ea49daf 100644 --- a/OpenRA.Game/Network/Session.cs +++ b/OpenRA.Game/Network/Session.cs @@ -218,6 +218,9 @@ namespace OpenRA.Network public bool Dedicated; public bool GameSavesEnabled; + // 120ms network frame interval for 40ms local tick + public int NetFrameInterval = 3; + [FieldLoader.Ignore] public Dictionary LobbyOptions = new Dictionary();