From 674618664a72679812c1b51065f725fec99aa86d Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Mon, 19 Feb 2018 19:32:27 -0500 Subject: add unvalidated update tick event for specialised use cases (#446) --- src/SMAPI/Framework/ModLoading/AssemblyLoader.cs | 5 +++++ src/SMAPI/Framework/ModLoading/InstructionHandleResult.cs | 7 ++++++- src/SMAPI/Framework/SGame.cs | 6 ++++-- 3 files changed, 15 insertions(+), 3 deletions(-) (limited to 'src/SMAPI/Framework') diff --git a/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs b/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs index 3a7b214a..ccbd053e 100644 --- a/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs +++ b/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs @@ -285,6 +285,11 @@ namespace StardewModdingAPI.Framework.ModLoading this.Monitor.LogOnce(loggedMessages, $"{mod.DisplayName} seems to change the save serialiser. It may change your saves in such a way that they won't work without this mod in the future.", LogLevel.Warn); break; + case InstructionHandleResult.DetectedUnvalidatedUpdateTick: + this.Monitor.LogOnce(loggedMessages, $"{logPrefix}Detected reference to {handler.NounPhrase} in assembly {filename}."); + this.Monitor.LogOnce(loggedMessages, $"{mod.DisplayName} uses a specialised SMAPI event that may crash the game or corrupt your save file. If you encounter problems, try removing this mod first.", LogLevel.Warn); + break; + case InstructionHandleResult.DetectedDynamic: this.Monitor.LogOnce(loggedMessages, $"{logPrefix}Detected 'dynamic' keyword ({handler.NounPhrase}) in assembly {filename}."); this.Monitor.LogOnce(loggedMessages, $"{mod.DisplayName} uses the 'dynamic' keyword, which isn't compatible with Stardew Valley on Linux or Mac.", diff --git a/src/SMAPI/Framework/ModLoading/InstructionHandleResult.cs b/src/SMAPI/Framework/ModLoading/InstructionHandleResult.cs index 0ae598fc..6a7e0519 100644 --- a/src/SMAPI/Framework/ModLoading/InstructionHandleResult.cs +++ b/src/SMAPI/Framework/ModLoading/InstructionHandleResult.cs @@ -1,3 +1,5 @@ +using StardewModdingAPI.Events; + namespace StardewModdingAPI.Framework.ModLoading { /// Indicates how an instruction was handled. @@ -19,6 +21,9 @@ namespace StardewModdingAPI.Framework.ModLoading DetectedSaveSerialiser, /// The instruction is compatible, but uses the dynamic keyword which won't work on Linux/Mac. - DetectedDynamic + DetectedDynamic, + + /// The instruction is compatible, but references which may impact stability. + DetectedUnvalidatedUpdateTick } } diff --git a/src/SMAPI/Framework/SGame.cs b/src/SMAPI/Framework/SGame.cs index f080f3c5..73c87118 100644 --- a/src/SMAPI/Framework/SGame.cs +++ b/src/SMAPI/Framework/SGame.cs @@ -229,6 +229,7 @@ namespace StardewModdingAPI.Framework if (SGame._newDayTask != null) { base.Update(gameTime); + SpecialisedEvents.InvokeUnvalidatedUpdateTick(this.Monitor); return; } @@ -236,6 +237,7 @@ namespace StardewModdingAPI.Framework if (Game1.gameMode == Game1.loadingMode) { base.Update(gameTime); + SpecialisedEvents.InvokeUnvalidatedUpdateTick(this.Monitor); return; } @@ -267,6 +269,7 @@ namespace StardewModdingAPI.Framework // suppress non-save events base.Update(gameTime); + SpecialisedEvents.InvokeUnvalidatedUpdateTick(this.Monitor); return; } if (this.IsBetweenCreateEvents) @@ -289,9 +292,7 @@ namespace StardewModdingAPI.Framework ** Game loaded events *********/ if (this.FirstUpdate) - { GameEvents.InvokeInitialize(this.Monitor); - } /********* ** Locale changed events @@ -556,6 +557,7 @@ namespace StardewModdingAPI.Framework /********* ** Update events *********/ + SpecialisedEvents.InvokeUnvalidatedUpdateTick(this.Monitor); if (this.FirstUpdate) { this.FirstUpdate = false; -- cgit