diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index 05879f4573..5e30816c94 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -585,7 +585,7 @@ namespace OpenRA var isNetTick = LocalTick % NetTickScale == 0; - if (!isNetTick || orderManager.IsReadyForNextFrame) + if (!isNetTick || orderManager.SendNetFrameOrdersAndCheckReady()) { ++orderManager.LocalFrameNumber; diff --git a/OpenRA.Game/Network/OrderManager.cs b/OpenRA.Game/Network/OrderManager.cs index 8018e82450..ece15b5b37 100644 --- a/OpenRA.Game/Network/OrderManager.cs +++ b/OpenRA.Game/Network/OrderManager.cs @@ -38,7 +38,7 @@ namespace OpenRA.Network public int NetFrameNumber { get; private set; } public int LocalFrameNumber; public int FramesAhead = 0; - public bool IsReadyForNextFrame { get; private set; } + bool isReadyForNextFrame; int lastFrameSent; public long LastTickTime = Game.RunTime; @@ -78,7 +78,7 @@ namespace OpenRA.Network // Technically redundant since we will attempt to send orders before the next frame SendOrders(); - IsReadyForNextFrame = false; + isReadyForNextFrame = false; } public OrderManager(ConnectionTarget endpoint, string password, IConnection conn) @@ -111,17 +111,8 @@ namespace OpenRA.Network chatCache.Add(new ChatLine(name, nameColor, text, textColor)); } - /* - * Send all frame orders that are ready if we can (game is started and our next available send frame is free), - * Send all immediate orders, - * Receive and dispatch immediate orders, check incoming sync matchs, and buffer received frame orders, - * Update our ready status for the next frame for Tick(). - */ public void TickImmediate() { - // Send our frame orders if we should - SendOrders(); - if (localImmediateOrders.Count != 0 && GameSaveLastFrame < NetFrameNumber + FramesAhead) Connection.SendImmediate(localImmediateOrders.Select(o => o.Serialize())); localImmediateOrders.Clear(); @@ -153,9 +144,6 @@ namespace OpenRA.Network return; } } - - if (!IsReadyForNextFrame) - IsReadyForNextFrame = NetFrameNumber >= 1 && frameData.IsReadyForFrame(NetFrameNumber); } Dictionary syncForFrame = new Dictionary(); @@ -204,13 +192,24 @@ namespace OpenRA.Network } } + public bool SendNetFrameOrdersAndCheckReady() + { + // Send our frame orders if we should + SendOrders(); + + if (!isReadyForNextFrame) + isReadyForNextFrame = NetFrameNumber >= 1 && frameData.IsReadyForFrame(NetFrameNumber); + + return isReadyForNextFrame; + } + /* * Only available if TickImmediate() is called first and we are ready to dispatch received orders locally. * Process all incoming orders for this frame, handle sync hashes and step our net frame. */ public void Tick() { - if (!IsReadyForNextFrame) + if (!isReadyForNextFrame) throw new InvalidOperationException(); foreach (var order in frameData.OrdersForFrame(World, NetFrameNumber)) @@ -226,7 +225,7 @@ namespace OpenRA.Network syncReport.UpdateSyncReport(); ++NetFrameNumber; - IsReadyForNextFrame = false; + isReadyForNextFrame = false; } public void Dispose()