Allow the server to ack no or multiple packets in the same frame.

This commit is contained in:
Paul Chote
2021-09-25 15:09:23 +01:00
committed by abcdefg30
parent a13d046304
commit 2d08f2bbfd
4 changed files with 40 additions and 13 deletions

View File

@@ -38,6 +38,7 @@ namespace OpenRA.Server
// - Order-specific data - see OpenRA.Game/Server/Order.cs for details
// - 0x10: Order acknowledgement (sent from the server to a client in response to a packet with world orders)
// - Int32 containing the frame number that the client should apply the orders it sent
// - byte containing the number of sent order packets to apply
// - 0x20: Ping
// - Int64 containing the server timestamp when the ping was generated
//
@@ -73,6 +74,6 @@ namespace OpenRA.Server
// The protocol for server and world orders
// This applies after the handshake has completed, and is provided to support
// alternative server implementations that wish to support multiple versions in parallel
public const int Orders = 16;
public const int Orders = 17;
}
}

View File

@@ -627,13 +627,14 @@ namespace OpenRA.Server
return ms.GetBuffer();
}
byte[] CreateAckFrame(int frame)
byte[] CreateAckFrame(int frame, byte count)
{
var ms = new MemoryStream(13);
ms.WriteArray(BitConverter.GetBytes(5));
var ms = new MemoryStream(14);
ms.WriteArray(BitConverter.GetBytes(6));
ms.WriteArray(BitConverter.GetBytes(0));
ms.WriteArray(BitConverter.GetBytes(frame));
ms.WriteByte((byte)OrderType.Ack);
ms.WriteByte(count);
return ms.GetBuffer();
}
@@ -813,7 +814,7 @@ namespace OpenRA.Server
if (data.Length == 0 || data[0] != (byte)OrderType.SyncHash)
{
frame += OrderLatency;
DispatchFrameToClient(conn, conn.PlayerIndex, CreateAckFrame(frame));
DispatchFrameToClient(conn, conn.PlayerIndex, CreateAckFrame(frame, 1));
// Track the last frame for each client so the disconnect handling can write
// an EndOfOrders marker with the correct frame number.