1
0
mirror of https://github.com/soarqin/DSP_Mods.git synced 2025-12-09 04:53:30 +08:00

minor fixes

This commit is contained in:
2023-10-26 21:11:36 +08:00
parent 09f7b1855f
commit ae41836659
3 changed files with 8 additions and 4 deletions

View File

@@ -156,7 +156,7 @@ public static class FactoryPatch
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
{ {
var matcher = new CodeMatcher(instructions, generator); var matcher = new CodeMatcher(instructions, generator);
matcher.MatchForward(false, matcher.End().MatchBack(false,
new CodeMatch(OpCodes.Ret) new CodeMatch(OpCodes.Ret)
); );
if (matcher.IsInvalid) if (matcher.IsInvalid)
@@ -167,7 +167,11 @@ public static class FactoryPatch
matcher.Advance(-1); matcher.Advance(-1);
if (matcher.Opcode != OpCodes.Nop && (matcher.Opcode != OpCodes.Call || !matcher.Instruction.OperandIs(AccessTools.Method(typeof(GC), nameof(GC.Collect))))) 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(); return matcher.InstructionEnumeration();
}
var labels = matcher.Labels; var labels = matcher.Labels;
matcher.Labels = new List<Label>(); matcher.Labels = new List<Label>();
matcher.Insert( matcher.Insert(

View File

@@ -33,8 +33,8 @@ public static class GamePatch
_gamePatch = null; _gamePatch = null;
} }
[HarmonyPrefix, HarmonyPatch(typeof(Application), nameof(Application.Quit), new Type[]{})] [HarmonyPrefix, HarmonyPatch(typeof(GameMain), nameof(GameMain.HandleApplicationQuit))]
private static void Application_Quit_Prefix() private static void GameMain_HandleApplicationQuit_Prefix()
{ {
var wnd = WinApi.FindWindow(GameWindowClass, GameWindowTitle); var wnd = WinApi.FindWindow(GameWindowClass, GameWindowTitle);
if (wnd == IntPtr.Zero) return; if (wnd == IntPtr.Zero) return;