Ensure replays end when the recorder disconnects.
When ReplayConnection fixes up disconnection packets, this allows the game to continue past the point of a player disconnecting. Unfortunately this also applies to the player who actually disconnected which means the replay continues in an invalid manner. To fix this - we now explicitly don't replace their packet in order to ensure such replays end at the correct time.
This commit is contained in:
@@ -56,13 +56,9 @@ namespace OpenRA.Network
|
|||||||
var frame = BitConverter.ToInt32(packet, 0);
|
var frame = BitConverter.ToInt32(packet, 0);
|
||||||
chunk.Packets.Add(Pair.New(client, packet));
|
chunk.Packets.Add(Pair.New(client, packet));
|
||||||
|
|
||||||
if (frame != int.MaxValue)
|
if (frame != int.MaxValue &&
|
||||||
{
|
(!lastClientsFrame.ContainsKey(client) || frame > lastClientsFrame[client]))
|
||||||
if (!lastClientsFrame.ContainsKey(client))
|
|
||||||
lastClientsFrame[client] = frame;
|
lastClientsFrame[client] = frame;
|
||||||
else if (frame > lastClientsFrame[client])
|
|
||||||
lastClientsFrame[client] = frame;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (packet.Length == 5 && packet[4] == 0xBF)
|
if (packet.Length == 5 && packet[4] == 0xBF)
|
||||||
continue; // disconnect
|
continue; // disconnect
|
||||||
@@ -91,6 +87,8 @@ namespace OpenRA.Network
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var lastClientToDisconnect = lastClientsFrame.MaxBy(kvp => kvp.Value).Key;
|
||||||
|
|
||||||
// 2nd parse : replace all disconnect packets without frame with real
|
// 2nd parse : replace all disconnect packets without frame with real
|
||||||
// disconnect frame
|
// disconnect frame
|
||||||
// NOTE: to modify/remove if a reconnect feature is set
|
// NOTE: to modify/remove if a reconnect feature is set
|
||||||
@@ -99,12 +97,16 @@ namespace OpenRA.Network
|
|||||||
foreach (var tmpPacketPair in tmpChunk.Packets)
|
foreach (var tmpPacketPair in tmpChunk.Packets)
|
||||||
{
|
{
|
||||||
var client = tmpPacketPair.First;
|
var client = tmpPacketPair.First;
|
||||||
|
|
||||||
|
// Don't replace the final disconnection packet - we still want this to end the replay.
|
||||||
|
if (client == lastClientToDisconnect)
|
||||||
|
continue;
|
||||||
|
|
||||||
var packet = tmpPacketPair.Second;
|
var packet = tmpPacketPair.Second;
|
||||||
if (packet.Length == 5 && packet[4] == 0xBF)
|
if (packet.Length == 5 && packet[4] == 0xBF)
|
||||||
{
|
{
|
||||||
int lastClientFrame = lastClientsFrame[client];
|
var lastClientFrame = lastClientsFrame[client];
|
||||||
byte[] lastFramePacket = BitConverter.GetBytes(lastClientFrame);
|
var lastFramePacket = BitConverter.GetBytes(lastClientFrame);
|
||||||
if (lastFramePacket.Length == 4)
|
|
||||||
Array.Copy(lastFramePacket, packet, lastFramePacket.Length);
|
Array.Copy(lastFramePacket, packet, lastFramePacket.Length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user