summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI/Framework')
-rw-r--r--src/SMAPI/Framework/ModLoading/AssemblyLoader.cs4
-rw-r--r--src/SMAPI/Framework/ModLoading/Framework/RecursiveRewriter.cs5
-rw-r--r--src/SMAPI/Framework/ModLoading/Rewriters/ArchitectureAssemblyRewriter.cs13
-rw-r--r--src/SMAPI/Framework/SCore.cs2
4 files changed, 11 insertions, 13 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;
}
diff --git a/src/SMAPI/Framework/SCore.cs b/src/SMAPI/Framework/SCore.cs
index c1aa3721..61fb77b2 100644
--- a/src/SMAPI/Framework/SCore.cs
+++ b/src/SMAPI/Framework/SCore.cs
@@ -1732,7 +1732,7 @@ namespace StardewModdingAPI.Framework
{
errorReasonPhrase = "its DLL couldn't be loaded.";
#if SMAPI_FOR_WINDOWS_64BIT_HACK
- if (!EnvironmentUtility.Is64BitAssembly(assemblyPath))
+ if (ex is BadImageFormatException && !EnvironmentUtility.Is64BitAssembly(assemblyPath))
errorReasonPhrase = "it needs to be updated for 64-bit mode.";
#endif
errorDetails = $"Error: {ex.GetLogSummary()}";