Change where we send orders
This commit is contained in:
committed by
Matthias Mailänder
parent
20e5219cf4
commit
616d9421d6
@@ -585,7 +585,7 @@ namespace OpenRA
|
||||
|
||||
var isNetTick = LocalTick % NetTickScale == 0;
|
||||
|
||||
if (!isNetTick || orderManager.IsReadyForNextFrame)
|
||||
if (!isNetTick || orderManager.SendNetFrameOrdersAndCheckReady())
|
||||
{
|
||||
++orderManager.LocalFrameNumber;
|
||||
|
||||
|
||||
@@ -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<int, byte[]> syncForFrame = new Dictionary<int, byte[]>();
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user