From ae418366591b429fc7dd9785c872fb709636f28e Mon Sep 17 00:00:00 2001 From: Soar Qin Date: Thu, 26 Oct 2023 21:11:36 +0800 Subject: [PATCH] minor fixes --- CheatEnabler/FactoryPatch.cs | 6 +++++- OCBatchBuild/OrbitalCollectorBatchBuild.cs | 2 +- UXAssist/GamePatch.cs | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CheatEnabler/FactoryPatch.cs b/CheatEnabler/FactoryPatch.cs index 46eb871..7ea543a 100644 --- a/CheatEnabler/FactoryPatch.cs +++ b/CheatEnabler/FactoryPatch.cs @@ -156,7 +156,7 @@ public static class FactoryPatch private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) { var matcher = new CodeMatcher(instructions, generator); - matcher.MatchForward(false, + matcher.End().MatchBack(false, new CodeMatch(OpCodes.Ret) ); if (matcher.IsInvalid) @@ -167,7 +167,11 @@ public static class FactoryPatch matcher.Advance(-1); if (matcher.Opcode != OpCodes.Nop && (matcher.Opcode != OpCodes.Call || !matcher.Instruction.OperandIs(AccessTools.Method(typeof(GC), nameof(GC.Collect))))) + { + CheatEnabler.Logger.LogWarning($"Failed to patch CreatePrebuilds: last instruction is not `Nop` or `Call GC.Collect()`: {matcher.Instruction}"); return matcher.InstructionEnumeration(); + } + var labels = matcher.Labels; matcher.Labels = new List