Overhaul player disconnect notifications.

This commit is contained in:
Paul Chote
2021-09-04 15:09:30 +01:00
committed by abcdefg30
parent b8e343bee9
commit 54c08748e0
12 changed files with 99 additions and 60 deletions

View File

@@ -79,16 +79,19 @@ namespace OpenRA.Network
return ms.GetBuffer();
}
public static bool TryParseDisconnect(byte[] packet, out int clientId)
public static bool TryParseDisconnect((int FromClient, byte[] Data) packet, out (int Frame, int ClientId) disconnect)
{
if (packet.Length == Order.DisconnectOrderLength + 4 && packet[4] == (byte)OrderType.Disconnect)
// Valid Disconnect packets are only ever generated by the server
if (packet.FromClient != 0 || packet.Data.Length != Order.DisconnectOrderLength + 4 || packet.Data[4] != (byte)OrderType.Disconnect)
{
clientId = BitConverter.ToInt32(packet, 5);
return true;
disconnect = (0, 0);
return false;
}
clientId = 0;
return false;
var frame = BitConverter.ToInt32(packet.Data, 0);
var clientId = BitConverter.ToInt32(packet.Data, 5);
disconnect = (frame, clientId);
return true;
}
public static bool TryParseSync(byte[] packet, out (int Frame, int SyncHash, ulong DefeatState) data)