summaryrefslogtreecommitdiff
path: root/src/SMAPI
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-07-28 00:51:45 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-07-28 00:51:45 -0400
commitb4f307e1ba88df072efed3b94975fa45789ae1ef (patch)
tree338a0092813aa39a9ee632e0b73dce9f5ad2f21d /src/SMAPI
parent6a6c484b9867524d2eaa617da4dde36fec8c3110 (diff)
downloadSMAPI-b4f307e1ba88df072efed3b94975fa45789ae1ef.tar.gz
SMAPI-b4f307e1ba88df072efed3b94975fa45789ae1ef.tar.bz2
SMAPI-b4f307e1ba88df072efed3b94975fa45789ae1ef.zip
fix rewritten Harmony 1.x code not raising 'detected game patch' flag (#711)
Diffstat (limited to 'src/SMAPI')
-rw-r--r--src/SMAPI/Framework/ModLoading/Rewriters/Harmony1AssemblyRewriter.cs15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/SMAPI/Framework/ModLoading/Rewriters/Harmony1AssemblyRewriter.cs b/src/SMAPI/Framework/ModLoading/Rewriters/Harmony1AssemblyRewriter.cs
index 3197c151..7a3b428d 100644
--- a/src/SMAPI/Framework/ModLoading/Rewriters/Harmony1AssemblyRewriter.cs
+++ b/src/SMAPI/Framework/ModLoading/Rewriters/Harmony1AssemblyRewriter.cs
@@ -32,7 +32,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Rewriters
{
Type targetType = this.GetMappedType(type);
replaceWith(module.ImportReference(targetType));
- this.MarkRewritten();
+ this.OnChanged();
this.ReplacedTypes = true;
return true;
}
@@ -46,14 +46,20 @@ namespace StardewModdingAPI.Framework.ModLoading.Rewriters
// rewrite Harmony 1.x methods to Harmony 2.0
MethodReference methodRef = RewriteHelper.AsMethodReference(instruction);
if (this.TryRewriteMethodsToFacade(module, methodRef))
+ {
+ this.OnChanged();
return true;
+ }
// rewrite renamed fields
FieldReference fieldRef = RewriteHelper.AsFieldReference(instruction);
if (fieldRef != null)
{
if (fieldRef.DeclaringType.FullName == "HarmonyLib.HarmonyMethod" && fieldRef.Name == "prioritiy")
+ {
fieldRef.Name = nameof(HarmonyMethod.priority);
+ this.OnChanged();
+ }
}
return false;
@@ -63,6 +69,13 @@ namespace StardewModdingAPI.Framework.ModLoading.Rewriters
/*********
** Private methods
*********/
+ /// <summary>Update the mod metadata when any Harmony 1.x code is migrated.</summary>
+ private void OnChanged()
+ {
+ this.MarkRewritten();
+ this.MarkFlag(InstructionHandleResult.DetectedGamePatch);
+ }
+
/// <summary>Rewrite methods to use Harmony facades if needed.</summary>
/// <param name="module">The assembly module containing the method reference.</param>
/// <param name="methodRef">The method reference to map.</param>