minor fix for Mods compatibility

This commit is contained in:
soarqin committed 2023-09-25 15:44:19 +08:00
1 parent f7a058e388
commit 80df6b3727
1 file changed
+10 -1
+10 -1
View File
@@ -370,8 +370,17 @@ public static class FactoryPatch
{
var matcher = new CodeMatcher(instructions, generator);
matcher.MatchForward(false,
new CodeMatch(OpCodes.Call, AccessTools.Method(typeof(GC), nameof(GC.Collect)))
new CodeMatch(OpCodes.Ret)
);
if (matcher.IsInvalid)
{
CheatEnabler.Logger.LogWarning($"Failed to patch CreatePrebuilds");
return matcher.InstructionEnumeration();
}
matcher.Advance(-1);
if (matcher.Opcode != OpCodes.Nop && (matcher.Opcode != OpCodes.Call || !matcher.Instruction.OperandIs(AccessTools.Method(typeof(GC), nameof(GC.Collect)))))
return matcher.InstructionEnumeration();
var labels = matcher.Labels;
matcher.Labels = null;
matcher.Insert(