/// <summary> /// Per-frame server processing function /// </summary> public static void Process() { if (!ConVar.GetValue <bool>("sv_running")) { return; } CellManager.Recenter(from client in _clients where client != null && client.Entity != null select client.Entity.Position); _residualTime += Game.FrameMsec; // 20 FPS = 50msec intervals while (_residualTime > 50) { _residualTime -= 50; _serverTime += 50; ProcessGame(); } }
public static void Process() { // limit FPS and handle events int minMsec = (com_maxFPS.GetValue <int>() > 0) ? (1000 / com_maxFPS.GetValue <int>()) : 1; uint msec = 0; do { _frameTime = EventSystem.HandleEvents(); msec = _frameTime - _lastTime; } while (msec < minMsec); // handle time scaling var scale = timescale.GetValue <float>(); msec = (uint)(msec * scale); if (msec < 1) { msec = 1; } else if (msec > 5000) { msec = 5000; } if (msec > 500) { Log.Write(LogLevel.Info, "Hitch warning: {0} msec frame time", msec); } DeltaTime = msec / 1000f; FrameMsec = msec; _lastTime = _frameTime; // process the command buffer Command.ExecuteBuffer(); // handle network stuff NetManager.Process(); // process game stuff Server.Process(); // process client Client.Process(); // more stuff (needs to be moved) Camera.Process(); if (!sv_running.GetValue <bool>()) { CellManager.Recenter(new[] { Camera.MainCamera.Position }); } Renderer2D.InitPerFrame(); FontManager.SetColor(Color.White); // camera moving DebugCamera.Process(); ConsoleRenderer.Process(); // render stuff if (Renderer.MakeDeviceAvailable()) { Renderer.Clear(); if (Client.State == Client.ClientState.Ingame) { DeferredRenderer.Render3DStuff(Renderer.Device); } Renderer2D.Render(Renderer.Device); Renderer.Device.Present(); } }