Example #1
0
        public void Tick( World world )
        {
            if( !IsReadyForNextFrame )
                throw new InvalidOperationException();

            Connection.Send( localOrders.Serialize( FrameNumber + FramesAhead ) );
            localOrders.Clear();

            var frameData = clientQuitTimes
                .Where( x => FrameNumber <= x.Value )
                .OrderBy( x => x.Key )
                .ToDictionary( k => k.Key, v => frameClientData[ FrameNumber ][ v.Key ] );
            var sync = new List<int>();
            sync.Add( world.SyncHash() );

            foreach( var order in frameData.SelectMany( o => o.Value.ToOrderList( world ).Select( a => new { Client = o.Key, Order = a } ) ) )
            {
                UnitOrders.ProcessOrder( world, order.Client, order.Order );
                sync.Add( world.SyncHash() );
            }

            var ss = sync.SerializeSync( FrameNumber );
            Connection.Send( ss );
            WriteToReplay( frameData, ss );

            CheckSync( ss );

            ++FrameNumber;
        }
Example #2
0
        public void Tick()
        {
            if (!IsReadyForNextFrame)
                throw new InvalidOperationException();

            Connection.Send(NetFrameNumber + FramesAhead, localOrders.Select(o => o.Serialize()).ToList());
            localOrders.Clear();

            var sync = new List<int>();
            sync.Add(world.SyncHash());

            foreach (var order in frameData.OrdersForFrame(world, NetFrameNumber))
            {
                UnitOrders.ProcessOrder(this, world, order.Client, order.Order);
                sync.Add(world.SyncHash());
            }

            var ss = sync.SerializeSync();
            Connection.SendSync(NetFrameNumber, ss);

            syncReport.UpdateSyncReport();

            ++NetFrameNumber;
        }