diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index 7c3d691ce2..ba20f490e3 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -244,13 +244,17 @@ namespace OpenRA return sb.ToString(); } - public static void DumpSyncReport() + public static void DumpSyncReport( int frame ) { - foreach (var f in syncReports) + var f = syncReports.FirstOrDefault(a => a.First == frame); + if (f == null) { - Log.Write("Sync for net frame {0} -------------", f.First); - Log.Write("{0}", f.Second); + Log.Write("No sync report available!"); + return; } + + Log.Write("Sync for net frame {0} -------------", f.First); + Log.Write("{0}", f.Second); } public static void Tick() diff --git a/OpenRA.Game/Network/OrderManager.cs b/OpenRA.Game/Network/OrderManager.cs index 82db8b2b1b..0c18d922ff 100755 --- a/OpenRA.Game/Network/OrderManager.cs +++ b/OpenRA.Game/Network/OrderManager.cs @@ -109,35 +109,35 @@ namespace OpenRA.Network Dictionary syncForFrame = new Dictionary(); - void CheckSync( byte[] packet ) + void CheckSync(byte[] packet) { - var frame = BitConverter.ToInt32( packet, 0 ); + var frame = BitConverter.ToInt32(packet, 0); byte[] existingSync; - if( syncForFrame.TryGetValue( frame, out existingSync ) ) + if (syncForFrame.TryGetValue(frame, out existingSync)) { - if( packet.Length != existingSync.Length ) + if (packet.Length != existingSync.Length) { - Game.DumpSyncReport(); - OutOfSync( frame ); + Game.DumpSyncReport(frame); + OutOfSync(frame); } else { - for( int i = 0 ; i < packet.Length ; i++ ) + for (int i = 0; i < packet.Length; i++) { - if( packet[ i ] != existingSync[ i ] ) + if (packet[i] != existingSync[i]) { - Game.DumpSyncReport(); + Game.DumpSyncReport(frame); - if ( i < SyncHeaderSize ) + if (i < SyncHeaderSize) OutOfSync(frame, "Tick"); else - OutOfSync( frame , (i - SyncHeaderSize) / 4); + OutOfSync(frame, (i - SyncHeaderSize) / 4); } } } } else - syncForFrame.Add( frame, packet ); + syncForFrame.Add(frame, packet); } void OutOfSync( int frame , int index)