summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2018-04-30 22:47:15 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2018-04-30 22:47:15 -0400
commit622140689042fd53b164e51a1872b9c2bdc71ed8 (patch)
tree2ce26fb65a83a40ebab32529aaa7ca591baff536
parent82ad4cef0ddca024db6df6d80358e54d965538dc (diff)
downloadSMAPI-622140689042fd53b164e51a1872b9c2bdc71ed8.tar.gz
SMAPI-622140689042fd53b164e51a1872b9c2bdc71ed8.tar.bz2
SMAPI-622140689042fd53b164e51a1872b9c2bdc71ed8.zip
fix farmhand crash in some cases when host exits game
-rw-r--r--src/SMAPI/Framework/SGame.cs20
1 files changed, 5 insertions, 15 deletions
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
/// <summary>Whether the after-load events were raised for this session.</summary>
private bool RaisedAfterLoadEvent;
- /// <summary>Whether the game is returning to the menu.</summary>
- private bool IsExitingToTitle;
-
/// <summary>Whether the game is saving and SMAPI has already raised <see cref="SaveEvents.BeforeSave"/>.</summary>
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
****/
- /// <summary>Perform any cleanup needed when the player unloads a save and returns to the title screen.</summary>
- private void CleanupAfterReturnToTitle()
+ /// <summary>Perform any cleanup needed when a save is unloaded.</summary>
+ private void MarkWorldNotReady()
{
Context.IsWorldReady = false;
this.AfterLoadTimer = 5;