From 186ab4cca7c1b3ae67a68bf6a3a3b1e7cdcb7687 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Wed, 4 Jul 2018 14:19:58 -0400 Subject: fix game freeze if the window loses focus while loading --- src/SMAPI/Framework/SGame.cs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'src/SMAPI/Framework/SGame.cs') diff --git a/src/SMAPI/Framework/SGame.cs b/src/SMAPI/Framework/SGame.cs index def0943c..240e9a97 100644 --- a/src/SMAPI/Framework/SGame.cs +++ b/src/SMAPI/Framework/SGame.cs @@ -223,17 +223,15 @@ namespace StardewModdingAPI.Framework return; } - // Load saves synchronously to avoid issues due to mod events triggering + // Run loaders synchronously to avoid issues due to mod events triggering // concurrently with game code. - if (Game1.gameMode == Game1.loadingMode) + if (Game1.currentLoader != null) { - this.Monitor.Log("Running game loader...", LogLevel.Trace); - while (Game1.gameMode == Game1.loadingMode) - { - base.Update(gameTime); - this.Events.Specialised_UnvalidatedUpdateTick.Raise(); - } - this.Monitor.Log("Game loader OK.", LogLevel.Trace); + this.Monitor.Log("Game loader synchronising...", LogLevel.Trace); + while (Game1.currentLoader?.MoveNext() == true) + continue; + Game1.currentLoader = null; + this.Monitor.Log("Game loader done.", LogLevel.Trace); } // While a background task is in progress, the game may make changes to the game -- cgit