fix farmhand crash in some cases when host exits game
This commit is contained in:
parent
82ad4cef0d
commit
6221406890
|
@ -68,9 +68,6 @@ namespace StardewModdingAPI.Framework
|
||||||
/// <summary>Whether the after-load events were raised for this session.</summary>
|
/// <summary>Whether the after-load events were raised for this session.</summary>
|
||||||
private bool RaisedAfterLoadEvent;
|
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>
|
/// <summary>Whether the game is saving and SMAPI has already raised <see cref="SaveEvents.BeforeSave"/>.</summary>
|
||||||
private bool IsBetweenSaveEvents;
|
private bool IsBetweenSaveEvents;
|
||||||
|
|
||||||
|
@ -300,11 +297,12 @@ namespace StardewModdingAPI.Framework
|
||||||
if (this.FirstUpdate)
|
if (this.FirstUpdate)
|
||||||
this.OnGameInitialised();
|
this.OnGameInitialised();
|
||||||
|
|
||||||
|
|
||||||
/*********
|
/*********
|
||||||
** Update context
|
** 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)
|
if (Game1.dayOfMonth != 0) // wait until new-game intro finishes (world not fully initialised yet)
|
||||||
this.AfterLoadTimer--;
|
this.AfterLoadTimer--;
|
||||||
|
@ -367,17 +365,9 @@ namespace StardewModdingAPI.Framework
|
||||||
/*********
|
/*********
|
||||||
** Exit to title events
|
** Exit to title events
|
||||||
*********/
|
*********/
|
||||||
// before exit to title
|
|
||||||
if (Game1.exitToTitle)
|
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.Monitor.Log("Context: returned to title", LogLevel.Trace);
|
||||||
|
|
||||||
this.IsExitingToTitle = false;
|
|
||||||
this.CleanupAfterReturnToTitle();
|
|
||||||
this.Events.Save_AfterReturnToTitle.Raise();
|
this.Events.Save_AfterReturnToTitle.Raise();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1242,8 +1232,8 @@ namespace StardewModdingAPI.Framework
|
||||||
/****
|
/****
|
||||||
** Methods
|
** Methods
|
||||||
****/
|
****/
|
||||||
/// <summary>Perform any cleanup needed when the player unloads a save and returns to the title screen.</summary>
|
/// <summary>Perform any cleanup needed when a save is unloaded.</summary>
|
||||||
private void CleanupAfterReturnToTitle()
|
private void MarkWorldNotReady()
|
||||||
{
|
{
|
||||||
Context.IsWorldReady = false;
|
Context.IsWorldReady = false;
|
||||||
this.AfterLoadTimer = 5;
|
this.AfterLoadTimer = 5;
|
||||||
|
|
Loading…
Reference in New Issue