From c1780fa7b7716650de7910e61ccbb7bf02f718a6 Mon Sep 17 00:00:00 2001 From: juanjp600 Date: Thu, 22 Jun 2017 00:24:30 -0300 Subject: [PATCH] Server sleep time is slightly smarter + loading debug messages --- BarotraumaClient/Source/GUI/LoadingScreen.cs | 1 + BarotraumaClient/Source/GameMain.cs | 2 ++ BarotraumaServer/Source/GameMain.cs | 10 ++++++++-- BarotraumaShared/Source/DebugConsole.cs | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/BarotraumaClient/Source/GUI/LoadingScreen.cs b/BarotraumaClient/Source/GUI/LoadingScreen.cs index cd0a87430..d05d63c65 100644 --- a/BarotraumaClient/Source/GUI/LoadingScreen.cs +++ b/BarotraumaClient/Source/GUI/LoadingScreen.cs @@ -44,6 +44,7 @@ namespace Barotrauma set { loadState = value; + DebugConsole.NewMessage("Loading: " + value.ToString() + "%",Color.Yellow); DrawLoadingText = true; } } diff --git a/BarotraumaClient/Source/GameMain.cs b/BarotraumaClient/Source/GameMain.cs index bc4e78848..c8c6b5921 100644 --- a/BarotraumaClient/Source/GameMain.cs +++ b/BarotraumaClient/Source/GameMain.cs @@ -192,6 +192,7 @@ namespace Barotrauma private IEnumerable Load() { + DebugConsole.NewMessage("LOADING COROUTINE", Color.Lime); GUI.GraphicsDevice = base.GraphicsDevice; GUI.Init(Content); @@ -269,6 +270,7 @@ namespace Barotrauma TitleScreen.LoadState = 100.0f; hasLoaded = true; + DebugConsole.NewMessage("LOADING COROUTINE FINISHED", Color.Lime); yield return CoroutineStatus.Success; } diff --git a/BarotraumaServer/Source/GameMain.cs b/BarotraumaServer/Source/GameMain.cs index d04f6bd47..4a3a4a2e5 100644 --- a/BarotraumaServer/Source/GameMain.cs +++ b/BarotraumaServer/Source/GameMain.cs @@ -100,14 +100,20 @@ namespace Barotrauma NetLobbyScreen = new NetLobbyScreen(); Server = new GameServer("Dedicated Server Test", 14242, false, "asd", false, 10); + + DateTime prevTime = DateTime.Now; + while (true) { + prevTime = DateTime.Now; + 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); - - Thread.Sleep((int)(Timing.Step * 1000.0)); + + int frameTime = DateTime.Now.Subtract(prevTime).Milliseconds; + Thread.Sleep(Math.Max((int)(Timing.Step * 1000.0) - frameTime,0)); } } diff --git a/BarotraumaShared/Source/DebugConsole.cs b/BarotraumaShared/Source/DebugConsole.cs index 50aac47be..0d52cf7bd 100644 --- a/BarotraumaShared/Source/DebugConsole.cs +++ b/BarotraumaShared/Source/DebugConsole.cs @@ -29,7 +29,7 @@ namespace Barotrauma static partial class DebugConsole { - const int MaxMessages = 20000; + const int MaxMessages = 200; public static List Messages = new List();