public void Run() { Stopwatch time = Stopwatch.StartNew(); double lag = 0; double timePerTick = 1000.0 / 60.0; while (running) { double elapsed = time.ElapsedMillisDouble(); time.Restart(); lag += elapsed; while (lag >= timePerTick) { TickNet(); if (!paused && PlayingPlayers.Any(p => !p.IsArbiter && p.status == PlayerStatus.Playing)) { Tick(); } lag -= timePerTick; } Thread.Sleep(10); } Stop(); }
private void SendLatencies() { var writer = new ByteWriter(); writer.WriteByte((byte)PlayerListAction.Latencies); writer.WriteInt32(PlayingPlayers.Count()); foreach (var player in PlayingPlayers) { writer.WriteInt32(player.Latency); writer.WriteInt32(player.ticksBehind); } SendToAll(Packets.Server_PlayerList, writer.ToArray()); }
private void SendLatencies() { SendToAll(Packets.Server_PlayerList, new object[] { (byte)PlayerListAction.Latencies, PlayingPlayers.Select(p => p.Latency).ToArray() }); }