From e94de480e084dee6c5567d7049678a5eafaf3a24 Mon Sep 17 00:00:00 2001 From: LadyAliceMargatroid Date: Fri, 7 Feb 2025 08:31:13 -0800 Subject: [PATCH] Zaggy1024 patch so "your latest version works perfectly in editor with just this change to GenerateMainPathDebugPatch" --- .../Patches/DungeonGeneratorPatch.cs | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/DunGenPlus/DunGenPlus/Patches/DungeonGeneratorPatch.cs b/DunGenPlus/DunGenPlus/Patches/DungeonGeneratorPatch.cs index 1707fcb..3df0a34 100644 --- a/DunGenPlus/DunGenPlus/Patches/DungeonGeneratorPatch.cs +++ b/DunGenPlus/DunGenPlus/Patches/DungeonGeneratorPatch.cs @@ -259,18 +259,28 @@ namespace DunGenPlus.Patches { tileProxyNullSequence.AddBasicLocal(OpCodes.Ldloc_S, 14); tileProxyNullSequence.AddBasic(OpCodes.Brtrue); + FieldInfo indexField = null; + foreach(var instruction in instructions){ + if (instruction.operand is FieldInfo field && field.Name.StartsWith("")) + indexField = field; + if (tileProxyNullSequence.VerifyStage(instruction)) { - var specialFunction = typeof(DunGenPlusGenerator).GetMethod("PrintAddTileErrorQuick", BindingFlags.Static | BindingFlags.Public); - var field = typeof(DungeonGenerator).Assembly.GetType("DunGen.DungeonGenerator+d__100").GetField("5__8", BindingFlags.NonPublic | BindingFlags.Instance); yield return instruction; - yield return new CodeInstruction(OpCodes.Ldloc_1); - yield return new CodeInstruction(OpCodes.Ldarg_0); - yield return new CodeInstruction(OpCodes.Ldfld, field); + if (indexField != null) { + var specialFunction = typeof(DunGenPlusGenerator).GetMethod("PrintAddTileErrorQuick", BindingFlags.Static | BindingFlags.Public); - yield return new CodeInstruction(OpCodes.Call, specialFunction); + yield return new CodeInstruction(OpCodes.Ldloc_1); + yield return new CodeInstruction(OpCodes.Ldarg_0); + yield return new CodeInstruction(OpCodes.Ldfld, indexField); + + yield return new CodeInstruction(OpCodes.Call, specialFunction); + } + else { + Plugin.logger.LogWarning("Failed to find current tile index field in the main path enumerator"); + } continue; }