diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2021-08-29 23:01:47 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2021-09-01 19:36:43 -0400 |
commit | 6edcfb1358e470a636a9e97780e05f2a0dcb6752 (patch) | |
tree | 759fb18b436811349865974ed396309bb5f2fc52 /src/SMAPI/Framework/ModLoading | |
parent | ec5fbb06113b29342e6d4b213144f4dc3e358b03 (diff) | |
download | SMAPI-6edcfb1358e470a636a9e97780e05f2a0dcb6752.tar.gz SMAPI-6edcfb1358e470a636a9e97780e05f2a0dcb6752.tar.bz2 SMAPI-6edcfb1358e470a636a9e97780e05f2a0dcb6752.zip |
tweak new code
Diffstat (limited to 'src/SMAPI/Framework/ModLoading')
3 files changed, 10 insertions, 12 deletions
diff --git a/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs b/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs index ae42909c..7668e8a9 100644 --- a/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs +++ b/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs @@ -336,11 +336,11 @@ namespace StardewModdingAPI.Framework.ModLoading IInstructionHandler[] handlers = new InstructionMetadata().GetHandlers(this.ParanoidMode, platformChanged, this.RewriteMods).ToArray(); RecursiveRewriter rewriter = new RecursiveRewriter( module: module, - rewriteModule: (module) => + rewriteModule: curModule => { bool rewritten = false; foreach (IInstructionHandler handler in handlers) - rewritten |= handler.Handle(module); + rewritten |= handler.Handle(curModule); return rewritten; }, rewriteType: (type, replaceWith) => diff --git a/src/SMAPI/Framework/ModLoading/Framework/RecursiveRewriter.cs b/src/SMAPI/Framework/ModLoading/Framework/RecursiveRewriter.cs index 52f4003c..4f14a579 100644 --- a/src/SMAPI/Framework/ModLoading/Framework/RecursiveRewriter.cs +++ b/src/SMAPI/Framework/ModLoading/Framework/RecursiveRewriter.cs @@ -37,7 +37,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Framework /// <summary>The module to rewrite.</summary> public ModuleDefinition Module { get; } - /// <summary>Handle or rewrite a type reference if needed.</summary> + /// <summary>Handle or rewrite a module definition if needed.</summary> public RewriteModuleDelegate RewriteModuleImpl { get; } /// <summary>Handle or rewrite a type reference if needed.</summary> @@ -52,6 +52,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Framework *********/ /// <summary>Construct an instance.</summary> /// <param name="module">The module to rewrite.</param> + /// <param name="rewriteModule">Handle or rewrite a module if needed.</param> /// <param name="rewriteType">Handle or rewrite a type reference if needed.</param> /// <param name="rewriteInstruction">Handle or rewrite a CIL instruction if needed.</param> public RecursiveRewriter(ModuleDefinition module, RewriteModuleDelegate rewriteModule, RewriteTypeDelegate rewriteType, RewriteInstructionDelegate rewriteInstruction) @@ -72,7 +73,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Framework try { - changed |= this.RewriteModuleImpl( this.Module ); + changed |= this.RewriteModuleImpl(this.Module); foreach (var type in types) changed |= this.RewriteTypeDefinition(type); diff --git a/src/SMAPI/Framework/ModLoading/Rewriters/ArchitectureAssemblyRewriter.cs b/src/SMAPI/Framework/ModLoading/Rewriters/ArchitectureAssemblyRewriter.cs index 216c042a..cc830216 100644 --- a/src/SMAPI/Framework/ModLoading/Rewriters/ArchitectureAssemblyRewriter.cs +++ b/src/SMAPI/Framework/ModLoading/Rewriters/ArchitectureAssemblyRewriter.cs @@ -1,13 +1,9 @@ -using System; -using HarmonyLib; using Mono.Cecil; -using Mono.Cecil.Cil; using StardewModdingAPI.Framework.ModLoading.Framework; -using StardewModdingAPI.Framework.ModLoading.RewriteFacades; namespace StardewModdingAPI.Framework.ModLoading.Rewriters { - /// <summary>Rewrites Harmony 1.x assembly references to work with Harmony 2.x.</summary> + /// <summary>Removes the 32-bit-only from loaded assemblies.</summary> internal class ArchitectureAssemblyRewriter : BaseInstructionHandler { /********* @@ -19,14 +15,15 @@ namespace StardewModdingAPI.Framework.ModLoading.Rewriters /// <inheritdoc /> - public override bool Handle( ModuleDefinition module ) + public override bool Handle(ModuleDefinition module) { - if ( module.Attributes.HasFlag( ModuleAttributes.Required32Bit ) ) + if (module.Attributes.HasFlag(ModuleAttributes.Required32Bit)) { - module.Attributes = module.Attributes & ~ModuleAttributes.Required32Bit; + module.Attributes &= ~ModuleAttributes.Required32Bit; this.MarkRewritten(); return true; } + return false; } |