From 622140689042fd53b164e51a1872b9c2bdc71ed8 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Mon, 30 Apr 2018 22:47:15 -0400 Subject: fix farmhand crash in some cases when host exits game --- src/SMAPI/Framework/SGame.cs | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/SMAPI/Framework/SGame.cs b/src/SMAPI/Framework/SGame.cs index d9e90896..767b49c7 100644 --- a/src/SMAPI/Framework/SGame.cs +++ b/src/SMAPI/Framework/SGame.cs @@ -68,9 +68,6 @@ namespace StardewModdingAPI.Framework /// Whether the after-load events were raised for this session. private bool RaisedAfterLoadEvent; - /// Whether the game is returning to the menu. - private bool IsExitingToTitle; - /// Whether the game is saving and SMAPI has already raised . private bool IsBetweenSaveEvents; @@ -300,11 +297,12 @@ namespace StardewModdingAPI.Framework if (this.FirstUpdate) this.OnGameInitialised(); - /********* ** Update context *********/ - if (Context.IsSaveLoaded && !SaveGame.IsProcessing /*still loading save*/ && this.AfterLoadTimer >= 0 && Game1.currentLocation != null) + if (Context.IsWorldReady && !Context.IsSaveLoaded) + this.MarkWorldNotReady(); + else if (Context.IsSaveLoaded && !SaveGame.IsProcessing /*still loading save*/ && this.AfterLoadTimer >= 0 && Game1.currentLocation != null) { if (Game1.dayOfMonth != 0) // wait until new-game intro finishes (world not fully initialised yet) this.AfterLoadTimer--; @@ -367,17 +365,9 @@ namespace StardewModdingAPI.Framework /********* ** Exit to title events *********/ - // before exit to title if (Game1.exitToTitle) - this.IsExitingToTitle = true; - - // after exit to title - if (Context.IsWorldReady && this.IsExitingToTitle && Game1.activeClickableMenu is TitleMenu) { this.Monitor.Log("Context: returned to title", LogLevel.Trace); - - this.IsExitingToTitle = false; - this.CleanupAfterReturnToTitle(); this.Events.Save_AfterReturnToTitle.Raise(); } @@ -1242,8 +1232,8 @@ namespace StardewModdingAPI.Framework /**** ** Methods ****/ - /// Perform any cleanup needed when the player unloads a save and returns to the title screen. - private void CleanupAfterReturnToTitle() + /// Perform any cleanup needed when a save is unloaded. + private void MarkWorldNotReady() { Context.IsWorldReady = false; this.AfterLoadTimer = 5; -- cgit