diff --git a/OpenRA.Game/Network/ReplayConnection.cs b/OpenRA.Game/Network/ReplayConnection.cs index 2ead909415..c37781411d 100755 --- a/OpenRA.Game/Network/ReplayConnection.cs +++ b/OpenRA.Game/Network/ReplayConnection.cs @@ -10,35 +10,26 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; -using System.IO; namespace OpenRA.Network { public class ReplayConnection : IConnection { - //uint nextFrame = 1; FileStream replayStream; + List sync = new List(); - public ReplayConnection( string replayFilename ) - { - replayStream = File.OpenRead( replayFilename ); - } + public ReplayConnection( string replayFilename ) { replayStream = File.OpenRead( replayFilename ); } - public int LocalClientId - { - get { return 0; } - } - - public ConnectionState ConnectionState - { - get { return ConnectionState.Connected; } - } + public int LocalClientId { get { return 0; } } + public ConnectionState ConnectionState { get { return ConnectionState.Connected; } } // do nothing; ignore locally generated orders public void Send( int frame, List orders ) { } public void SendImmediate( List orders ) { } + public void SendSync( int frame, byte[] syncData ) { var ms = new MemoryStream(); @@ -47,8 +38,6 @@ namespace OpenRA.Network sync.Add( ms.ToArray() ); } - List sync = new List(); - public void Receive( Action packetFn ) { while( sync.Count != 0 ) @@ -56,9 +45,11 @@ namespace OpenRA.Network packetFn( LocalClientId, sync[ 0 ] ); sync.RemoveAt( 0 ); } + if( replayStream == null ) return; var reader = new BinaryReader( replayStream ); + while( replayStream.Position < replayStream.Length ) { var client = reader.ReadInt32(); @@ -66,6 +57,7 @@ namespace OpenRA.Network var packet = reader.ReadBytes( packetLen ); packetFn( client, packet ); } + replayStream = null; } diff --git a/OpenRA.Game/Network/ReplayRecorderConnection.cs b/OpenRA.Game/Network/ReplayRecorderConnection.cs index 0d36322d25..ffc147678e 100644 --- a/OpenRA.Game/Network/ReplayRecorderConnection.cs +++ b/OpenRA.Game/Network/ReplayRecorderConnection.cs @@ -10,9 +10,9 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; -using System.IO; namespace OpenRA.Network {