From 2f638a4c012a1c30b8e154e020a3898cf3f8f88e Mon Sep 17 00:00:00 2001 From: Regalis Date: Thu, 30 Mar 2017 21:54:58 +0300 Subject: [PATCH] The initial loading screen is closed if an exception is thrown during loading. Causes the game to crash due to the unloaded content, but that's better than letting the game hang on the loading screen. --- Subsurface/Source/GameMain.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Subsurface/Source/GameMain.cs b/Subsurface/Source/GameMain.cs index f508d48c2..8b64febd1 100644 --- a/Subsurface/Source/GameMain.cs +++ b/Subsurface/Source/GameMain.cs @@ -69,6 +69,7 @@ namespace Barotrauma public static GameSettings Config; + private CoroutineHandle loadingCoroutine; private bool hasLoaded; private GameTime fixedTime; @@ -203,7 +204,7 @@ namespace Barotrauma loadingScreenOpen = true; TitleScreen = new LoadingScreen(GraphicsDevice); - CoroutineManager.StartCoroutine(Load()); + loadingCoroutine = CoroutineManager.StartCoroutine(Load()); } public IEnumerable Load() @@ -333,6 +334,14 @@ namespace Barotrauma { loadingScreenOpen = false; } + + if (!hasLoaded && !CoroutineManager.IsCoroutineRunning(loadingCoroutine)) + { + DebugConsole.ThrowError("Loading was interrupted due to an error"); + loadingScreenOpen = false; + loadingCoroutine = null; + hasLoaded = true; + } } else if (hasLoaded) {