From b9b3c96f9989f2fc475ca8ca82f7d447f495ae7c Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Mon, 21 May 2018 20:30:51 +0300 Subject: [PATCH] Fixed Timing.TotalTime not being updated in the dedicated server. Caused clients never timing out, AIObjectiveFixLeaks not working at all, reactor usage not being logged and possibly other issues. --- Barotrauma/BarotraumaServer/Source/GameMain.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Barotrauma/BarotraumaServer/Source/GameMain.cs b/Barotrauma/BarotraumaServer/Source/GameMain.cs index 5210a6c9c..0c33cf204 100644 --- a/Barotrauma/BarotraumaServer/Source/GameMain.cs +++ b/Barotrauma/BarotraumaServer/Source/GameMain.cs @@ -139,25 +139,27 @@ namespace Barotrauma { DebugConsole.NewMessage("WARNING: Stopwatch frequency under 1500 ticks per second. Expect significant syncing accuracy issues.", Color.Yellow); } - + Stopwatch stopwatch = Stopwatch.StartNew(); long prevTicks = stopwatch.ElapsedTicks; while (ShouldRun) { long currTicks = stopwatch.ElapsedTicks; - Timing.Accumulator += (double)(currTicks - prevTicks) / frequency; + double elapsedTime = (currTicks - prevTicks) / frequency; + Timing.Accumulator += elapsedTime; + Timing.TotalTime += elapsedTime; prevTicks = currTicks; - while (Timing.Accumulator>=Timing.Step) + while (Timing.Accumulator >= Timing.Step) { DebugConsole.Update(); if (Screen.Selected != null) Screen.Selected.Update((float)Timing.Step); Server.Update((float)Timing.Step); CoroutineManager.Update((float)Timing.Step, (float)Timing.Step); - + Timing.Accumulator -= Timing.Step; } - int frameTime = (int)(((double)(stopwatch.ElapsedTicks - prevTicks) / frequency)*1000.0); - Thread.Sleep(Math.Max(((int)(Timing.Step * 1000.0) - frameTime)/2,0)); + int frameTime = (int)(((double)(stopwatch.ElapsedTicks - prevTicks) / frequency) * 1000.0); + Thread.Sleep(Math.Max(((int)(Timing.Step * 1000.0) - frameTime) / 2, 0)); } stopwatch.Stop();