summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZaneYork <ZaneYork@qq.com>2020-05-29 14:25:01 +0800
committerZaneYork <ZaneYork@qq.com>2020-05-29 14:25:01 +0800
commitf817039a3a71e6e67c3bebb5e7fbd189c9a5da87 (patch)
tree4da3f9fbb89d44aefcb01a09d8fe8b8bc85988c3 /src
parent01b6e4ac3252a3ac8aa8046b5b97000fce13d576 (diff)
downloadSMAPI-f817039a3a71e6e67c3bebb5e7fbd189c9a5da87.tar.gz
SMAPI-f817039a3a71e6e67c3bebb5e7fbd189c9a5da87.tar.bz2
SMAPI-f817039a3a71e6e67c3bebb5e7fbd189c9a5da87.zip
Bug fix: make it possible for multi patch(When one patch replace an instruction, another patch didn't aware it due to the variable capture)
Diffstat (limited to 'src')
-rw-r--r--src/SMAPI/Framework/ModLoading/AssemblyLoader.cs3
-rw-r--r--src/SMAPI/Framework/ModLoading/Framework/RecursiveRewriter.cs4
2 files changed, 4 insertions, 3 deletions
diff --git a/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs b/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs
index eadb2997..dbb5f696 100644
--- a/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs
+++ b/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs
@@ -4,6 +4,7 @@ using System.IO;
using System.Linq;
using System.Reflection;
using Mono.Cecil;
+using Mono.Cecil.Cil;
using StardewModdingAPI.Framework.Exceptions;
using StardewModdingAPI.Framework.ModLoading.Framework;
using StardewModdingAPI.Metadata;
@@ -304,7 +305,7 @@ namespace StardewModdingAPI.Framework.ModLoading
rewritten |= handler.Handle(module, type, replaceWith);
return rewritten;
},
- rewriteInstruction: (instruction, cil, replaceWith) =>
+ rewriteInstruction: (ref Instruction instruction, ILProcessor cil, Action<Instruction> replaceWith) =>
{
bool rewritten = false;
foreach (IInstructionHandler handler in handlers)
diff --git a/src/SMAPI/Framework/ModLoading/Framework/RecursiveRewriter.cs b/src/SMAPI/Framework/ModLoading/Framework/RecursiveRewriter.cs
index a0f075bd..c774c038 100644
--- a/src/SMAPI/Framework/ModLoading/Framework/RecursiveRewriter.cs
+++ b/src/SMAPI/Framework/ModLoading/Framework/RecursiveRewriter.cs
@@ -23,7 +23,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Framework
/// <param name="cil">The CIL instruction processor.</param>
/// <param name="replaceWith">Replaces the CIL instruction with the given instruction.</param>
/// <returns>Returns whether the instruction was changed.</returns>
- public delegate bool RewriteInstructionDelegate(Instruction instruction, ILProcessor cil, Action<Instruction> replaceWith);
+ public delegate bool RewriteInstructionDelegate(ref Instruction instruction, ILProcessor cil, Action<Instruction> replaceWith);
/*********
@@ -144,7 +144,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Framework
// instruction itself
// (should be done after the above type rewrites to ensure valid types)
- rewritten |= this.RewriteInstructionImpl(instruction, cil, newInstruction =>
+ rewritten |= this.RewriteInstructionImpl(ref instruction, cil, newInstruction =>
{
rewritten = true;
cil.Replace(instruction, newInstruction);