/// <summary> /// Creates instance of Active client state. /// </summary> /// <param name="gameClient"></param> /// <param name="snapshotId"></param> /// <param name="initialSnapshot"></param> public Active ( GameClient gameClient, uint snapshotId, byte[] initialSnapshot, long svTicks ) : base(gameClient, ClientState.Active) { queue = new SnapshotQueue(32); queue.Push( new Snapshot( new TimeSpan(0), snapshotId, initialSnapshot) ); lastServerTicks = svTicks; lastSnapshotID = snapshotId; lastSnapshotFrame = snapshotId; Message = ""; #if USE_DEJITTER jitter = new JitterBuffer( gameClient.Game, svTicks ); #endif stopwatch = new Stopwatch(); stopwatch.Start(); clientTicks = stopwatch.Elapsed.Ticks; gameClient.FeedSnapshot( new GameTime(0,svTicks,0L), initialSnapshot, 0 ); }
/// <summary> /// Updates everything related to network and game logic. /// </summary> void UpdateNetworkAndLogic ( GameTime svTime, NetServer server, SnapshotQueue snapshotQueue ) { #if DEBUG server.Configuration.SimulatedLoss = Game.Network.SimulatePacketsLoss; server.Configuration.SimulatedMinimumLatency = Game.Network.SimulateMinLatency; server.Configuration.SimulatedRandomLatency = Game.Network.SimulateRandomLatency; #endif // read input messages : DispatchIM( svTime, snapshotQueue, server ); // update pings : UpdatePings( server ); // update frame and get snapshot : var snapshot = Update( svTime ); // push snapshot to queue : snapshotQueue.Push( svTime.Total, snapshot ); // send snapshot to clients : SendSnapshot( server, snapshotQueue, svTime.Total.Ticks ); // send notifications to clients : SendNotifications( server ); // execute server's command queue : Game.Invoker.ExecuteQueue( svTime, CommandAffinity.Server ); // crash test for server : CrashServer.CrashTest(); FreezeServer.FreezeTest(); SlowdownServer.SlowTest(); }