summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2018-02-19 19:32:27 -0500
committerJesse Plamondon-Willard <github@jplamondonw.com>2018-02-19 19:32:27 -0500
commit674618664a72679812c1b51065f725fec99aa86d (patch)
treed511d598bf0adfcf38817d3fd7098bb3854e5863 /src/SMAPI/Framework
parent5060739d62dfce0c72a5d3eeb93332aad7aa929f (diff)
downloadSMAPI-674618664a72679812c1b51065f725fec99aa86d.tar.gz
SMAPI-674618664a72679812c1b51065f725fec99aa86d.tar.bz2
SMAPI-674618664a72679812c1b51065f725fec99aa86d.zip
add unvalidated update tick event for specialised use cases (#446)
Diffstat (limited to 'src/SMAPI/Framework')
-rw-r--r--src/SMAPI/Framework/ModLoading/AssemblyLoader.cs5
-rw-r--r--src/SMAPI/Framework/ModLoading/InstructionHandleResult.cs7
-rw-r--r--src/SMAPI/Framework/SGame.cs6
3 files changed, 15 insertions, 3 deletions
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
{
/// <summary>Indicates how an instruction was handled.</summary>
@@ -19,6 +21,9 @@ namespace StardewModdingAPI.Framework.ModLoading
DetectedSaveSerialiser,
/// <summary>The instruction is compatible, but uses the <c>dynamic</c> keyword which won't work on Linux/Mac.</summary>
- DetectedDynamic
+ DetectedDynamic,
+
+ /// <summary>The instruction is compatible, but references <see cref="SpecialisedEvents.InvokeUnvalidatedUpdateTick"/> which may impact stability.</summary>
+ 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;