Skip to content

Commit

Permalink
Fixed transpiler to work on VS runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
shdwp committed Apr 7, 2020
1 parent 3328100 commit bf5abd9
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions UIExtenderLibModule/Prefab/Patches/WidgetPrefabLoadPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Xml;
using System.Xml.XmlConfiguration;
using HarmonyLib;
using TaleWorlds.GauntletUI.PrefabSystem;

Expand All @@ -27,11 +29,8 @@ internal static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruct
additions.Add(new CodeInstruction(OpCodes.Call, processIfNeeded));
additions.Add(new CodeInstruction(OpCodes.Pop));

var xmlSettingsCtor = "System.Xml.XmlReaderSettings..ctor()";
var widgetPrefabCtor = "TaleWorlds.GauntletUI.PrefabSystem.WidgetPrefab..ctor()";

var from = input.TakeWhile(i => !(i.opcode == OpCodes.Newobj && (i.operand as ConstructorInfo).FullDescription() == xmlSettingsCtor)).Count() + 2;
var to = from + input.Skip(from).TakeWhile(i => !(i.opcode == OpCodes.Newobj && (i.operand as ConstructorInfo).FullDescription() == widgetPrefabCtor)).Count();
var from = input.TakeWhile(i => !(i.opcode == OpCodes.Newobj && (i.operand as ConstructorInfo).DeclaringType == typeof(XmlReaderSettings))).Count() + 2;
var to = from + input.Skip(from).TakeWhile(i => !(i.opcode == OpCodes.Newobj && (i.operand as ConstructorInfo).DeclaringType == typeof(WidgetPrefab))).Count();
var count = to - from;

instructions.RemoveRange(from, count);
Expand Down

0 comments on commit bf5abd9

Please sign in to comment.