From f52edf9e0b267e79f88c492e7d7e34f63744f21c Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 29 Apr 2017 21:46:01 -0400 Subject: fix mod events triggering during game save in Stardew Valley 1.2 --- src/StardewModdingAPI/Framework/SGame.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/StardewModdingAPI/Framework') diff --git a/src/StardewModdingAPI/Framework/SGame.cs b/src/StardewModdingAPI/Framework/SGame.cs index 7e04c391..fe7d3aa3 100644 --- a/src/StardewModdingAPI/Framework/SGame.cs +++ b/src/StardewModdingAPI/Framework/SGame.cs @@ -223,6 +223,16 @@ namespace StardewModdingAPI.Framework return; } + // While the game is writing to the save file in the background, mods can unexpectedly + // fail since they don't have exclusive access to resources (e.g. collection changed + // during enumeration errors). To avoid problems, events are not invoked while a save + // is in progress. + if (Context.IsSaving) + { + base.Update(gameTime); + return; + } + // raise game loaded if (this.FirstUpdate) { -- cgit