Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 14.18 KB | None | 0 0
  1. Error:
  2.  
  3. [20:26:35] [8/ERROR] [tML]: An error occurred while loading EndoAvalon
  4. The mod(s) have been automatically been disabled.
  5. System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidProgramException: JIT Compiler encountered an internal limitation.
  6.    at System.Runtime.CompilerServices.RuntimeHelpers._CompileMethod(IRuntimeMethodInfo method)
  7.    --- End of inner exception stack trace ---
  8.    at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
  9.    at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
  10.    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
  11.    at MonoMod.RuntimeDetour.Platforms.DetourRuntimeNETPlatform.GetMethodHandle(MethodBase method)
  12.    at MonoMod.RuntimeDetour.Platforms.DetourRuntimeILPlatform.Pin(MethodBase method)
  13.    at MonoMod.RuntimeDetour.DetourHelper.Pin[T](T method)
  14.    at MonoMod.RuntimeDetour.DetourHelper.GetNativeStart(MethodBase method)
  15.    at MonoMod.RuntimeDetour.Detour._TopApply()
  16.    at MonoMod.RuntimeDetour.Detour..ctor(MethodBase from, MethodBase to)
  17.    at MonoMod.RuntimeDetour.HookGen.HookEndpoint.UpdateILManipulated(Boolean force)
  18.    at MonoMod.RuntimeDetour.HookGen.HookEndpoint.Modify(Delegate callback)
  19.    at MonoMod.RuntimeDetour.HookGen.HookEndpointManager.Modify(MethodBase method, Delegate callback)
  20.    at IL.Terraria.Main.add_DrawMenu(Manipulator )
  21.    at EndoAvalon.EndoAvalon.AddHooks() in EndoAvalon.cs:line 135
  22.    at EndoAvalon.EndoAvalon.Load() in EndoAvalon.cs:line 108
  23.    at Terraria.ModLoader.ModContent.<>c.<Load>b__30_0(Mod mod)
  24.    at Terraria.ModLoader.ModContent.LoadModContent(Action`1 loadAction)
  25.    at Terraria.ModLoader.ModContent.Load()
  26.    at Terraria.ModLoader.ModLoader.Load()
  27. [20:26:35] [8/INFO] [tML]: Disabling Mod: EndoAvalon
  28.  
  29. Code:
  30.  
  31.         public static void HookEvilMenu(ILContext il)
  32.         {
  33.             var rightTarget = false;
  34.             var c = new ILCursor(il);
  35.             while (!rightTarget)
  36.             {
  37.                 if (!c.TryGotoNext(i => i.MatchLdcI4(-71)))
  38.                     throw new Exception("Couldn't find case: -71");
  39.                 if (!c.Next.Next.MatchBneUn(out _))
  40.                     continue;
  41.                 if (!c.Next.Next.Next.MatchLdcI4(200))
  42.                     continue;
  43.                 rightTarget = true;
  44.             }
  45.             c.TryGotoNext(i => i.MatchLdcI4(3));
  46.             int buttonVerticalSpacingIndex = -1;
  47.             c.TryGotoNext(i => i.MatchLdloc(out buttonVerticalSpacingIndex));
  48.             if (buttonVerticalSpacingIndex == -1)
  49.                 throw new Exception("Couldn't find the variable index for buttonVerticalSpacing");
  50.             c.TryGotoNext(i => i.MatchLdcI4(4));
  51.             c.TryGotoNext(i => i.MatchLdcI4(70));
  52.             c.Remove();
  53.             c.Emit(Ldc_I4_S, (sbyte) 30);
  54.             c.TryGotoNext(i => i.MatchStelemI4());
  55.             c.Emit(Ldloc_S, (byte) buttonVerticalSpacingIndex);
  56.             c.Emit(Ldc_I4_5);
  57.             c.Emit(Ldc_I4_S, (sbyte) 70);
  58.             c.Emit(Stelem_I4);
  59.             c.TryGotoNext(i => i.MatchLdcI4(5));
  60.             c.Remove();
  61.             c.Emit(Ldc_I4_6);
  62.             var buttonNames = -1;
  63.             c.TryGotoNext(i => i.MatchLdloc(out buttonNames));
  64.             if (buttonNames == -1)
  65.                 throw new Exception("Couldn't find the variable index for buttonNames");
  66.             FieldReference selectedMenu = null;
  67.             c.TryGotoNext(i => i.MatchLdarg(0));
  68.             c.TryGotoNext(i => i.MatchLdfld(out selectedMenu));
  69.             if (selectedMenu == null)
  70.                 throw new Exception("Couldn't find the private variable selectedMenu");
  71.             var index9 = il.AddVariable(typeof(int));
  72.             c.TryGotoNext(i => i.MatchLdstr("UI.Back"));
  73.             c.TryGotoPrev(i => i.MatchAdd());
  74.             c.Emit(Stloc_S, (byte) index9);
  75.             c.Emit(Ldloc_S, (byte) buttonNames);
  76.             c.Emit(Ldloc_S, (byte) index9);
  77.             c.Emit(Ldstr, "Contagion");
  78.             c.Emit(Call, typeof(Language).GetMethod("GetTextValue", new[] {typeof(string)}));
  79.             c.Emit(Stelem_Ref);
  80.             c.Emit(Ldarg_0);
  81.             c.Emit(Ldfld, selectedMenu);
  82.             c.Emit(Ldloc_S, (byte) index9);
  83.             var endif = il.DefineLabel();
  84.             c.Emit(Bne_Un_S, endif);
  85.             c.Emit(Ldc_I4_2);
  86.             c.Emit(Stsfld, typeof(WorldGen).GetField(nameof(WorldGen.WorldGenParam_Evil)));
  87.             c.Emit(Ldc_I4_S, (sbyte) 10);
  88.             c.Emit(Ldc_I4_M1);
  89.             c.Emit(Ldc_I4_M1);
  90.             c.Emit(Ldc_I4_1);
  91.             c.Emit(Ldc_R4, 1f);
  92.             c.Emit(Ldc_R4, 0f);
  93.             c.Emit(Call, typeof(Main).GetMethod("PlaySound", new[] {typeof(Int32), typeof(Int32), typeof(Int32), typeof(Int32), typeof(float), typeof(float)}));
  94.             c.Emit(Pop);
  95.             c.Emit(Ldc_I4_7);
  96.             c.Emit(Stfld, typeof(Main).GetField(nameof(Main.menuMode)));
  97.             c.MarkLabel(endif);
  98.             c.Emit(Ldloc_S, (byte) index9);
  99.             c.Emit(Ldc_I4_1);
  100.             c.Emit(Add);
  101.         }
  102.  
  103. ILCode:
  104.  
  105.     IL_2b36: ldc.i4       200 // 0x000000c8
  106.     IL_2b3b: stloc.s      offY
  107.  
  108.     // [35742 19 - 35742 31]
  109.     IL_2b3d: ldc.i4.s     60 // 0x3c
  110.     IL_2b3f: stloc.s      spacing
  111.  
  112.     // [35743 19 - 35743 48]
  113.     IL_2b41: ldloc.s      buttonVerticalSpacing
  114.     IL_2b43: ldc.i4.1
  115.     IL_2b44: ldc.i4.s     30 // 0x1e
  116.     IL_2b46: stelem.i4
  117.  
  118.     // [35744 19 - 35744 48]
  119.     IL_2b47: ldloc.s      buttonVerticalSpacing
  120.     IL_2b49: ldc.i4.2
  121.     IL_2b4a: ldc.i4.s     30 // 0x1e
  122.     IL_2b4c: stelem.i4
  123.  
  124.     // [35745 19 - 35745 48]
  125.     IL_2b4d: ldloc.s      buttonVerticalSpacing
  126.     IL_2b4f: ldc.i4.3
  127.     IL_2b50: ldc.i4.s     30 // 0x1e
  128.     IL_2b52: stelem.i4
  129.  
  130.     // [35746 19 - 35746 48]
  131.     IL_2b53: ldloc.s      buttonVerticalSpacing
  132.     IL_2b55: ldc.i4.4
  133.     IL_2b56: ldc.i4.s     70 // 0x46
  134.     IL_2b58: stelem.i4
  135.  
  136.     // [35747 19 - 35747 33]
  137.     IL_2b59: ldc.i4.5
  138.     IL_2b5a: stloc.s      numButtons
  139.  
  140.     // [35748 19 - 35748 33]
  141.     IL_2b5c: ldc.i4.0
  142.     IL_2b5d: stloc.s      index4
  143.  
  144.     // [35749 19 - 35749 61]
  145.     IL_2b5f: ldloc.s      buttonNames
  146.     IL_2b61: ldloc.s      index4
  147.     IL_2b63: ldsfld       class Terraria.Localization.LocalizedText[] Terraria.Lang::misc
  148.     IL_2b68: ldc.i4.s     100 // 0x64
  149.     IL_2b6a: ldelem.ref
  150.     IL_2b6b: callvirt     instance string Terraria.Localization.LocalizedText::get_Value()
  151.     IL_2b70: stelem.ref
  152.  
  153.     // [35750 19 - 35750 44]
  154.     IL_2b71: ldloc.s      flagArray1
  155.     IL_2b73: ldloc.s      index4
  156.     IL_2b75: ldc.i4.1
  157.     IL_2b76: stelem.i1
  158.  
  159.     // [35751 19 - 35751 42]
  160.     IL_2b77: ldloc.s      index4
  161.     IL_2b79: ldc.i4.1
  162.     IL_2b7a: add
  163.     IL_2b7b: stloc.s      index5
  164.  
  165.     // [35752 19 - 35752 61]
  166.     IL_2b7d: ldloc.s      buttonNames
  167.     IL_2b7f: ldloc.s      index5
  168.     IL_2b81: ldsfld       class Terraria.Localization.LocalizedText[] Terraria.Lang::misc
  169.     IL_2b86: ldc.i4.s     101 // 0x65
  170.     IL_2b88: ldelem.ref
  171.     IL_2b89: callvirt     instance string Terraria.Localization.LocalizedText::get_Value()
  172.     IL_2b8e: stelem.ref
  173.  
  174.     // [35753 19 - 35753 51]
  175.     IL_2b8f: ldarg.0      // this
  176.     IL_2b90: ldfld        int32 Terraria.Main::selectedMenu
  177.     IL_2b95: ldloc.s      index5
  178.     IL_2b97: bne.un.s     IL_2bba
  179.  
  180.     // [35755 21 - 35755 52]
  181.     IL_2b99: ldc.i4.0
  182.     IL_2b9a: stsfld       int32 Terraria.WorldGen::WorldGenParam_Evil
  183.  
  184.     // [35756 21 - 35756 60]
  185.     IL_2b9f: ldc.i4.s     10 // 0x0a
  186.     IL_2ba1: ldc.i4.m1
  187.     IL_2ba2: ldc.i4.m1
  188.     IL_2ba3: ldc.i4.1
  189.     IL_2ba4: ldc.r4       1
  190.     IL_2ba9: ldc.r4       0.0
  191.     IL_2bae: call         class [Microsoft.Xna.Framework]Microsoft.Xna.Framework.Audio.SoundEffectInstance Terraria.Main::PlaySound(int32, int32, int32, int32, float32, float32)
  192.     IL_2bb3: pop
  193.  
  194.     // [35757 21 - 35757 38]
  195.     IL_2bb4: ldc.i4.7
  196.     IL_2bb5: stsfld       int32 Terraria.Main::menuMode
  197.  
  198.     // [35759 19 - 35759 42]
  199.     IL_2bba: ldloc.s      index5
  200.     IL_2bbc: ldc.i4.1
  201.     IL_2bbd: add
  202.     IL_2bbe: stloc.s      index6
  203.  
  204.     // [35760 19 - 35760 61]
  205.     IL_2bc0: ldloc.s      buttonNames
  206.     IL_2bc2: ldloc.s      index6
  207.     IL_2bc4: ldsfld       class Terraria.Localization.LocalizedText[] Terraria.Lang::misc
  208.     IL_2bc9: ldc.i4.s     102 // 0x66
  209.     IL_2bcb: ldelem.ref
  210.     IL_2bcc: callvirt     instance string Terraria.Localization.LocalizedText::get_Value()
  211.     IL_2bd1: stelem.ref
  212.  
  213.     // [35761 19 - 35761 51]
  214.     IL_2bd2: ldarg.0      // this
  215.     IL_2bd3: ldfld        int32 Terraria.Main::selectedMenu
  216.     IL_2bd8: ldloc.s      index6
  217.     IL_2bda: bne.un.s     IL_2bfd
  218.  
  219.     // [35763 21 - 35763 52]
  220.     IL_2bdc: ldc.i4.1
  221.     IL_2bdd: stsfld       int32 Terraria.WorldGen::WorldGenParam_Evil
  222.  
  223.     // [35764 21 - 35764 60]
  224.     IL_2be2: ldc.i4.s     10 // 0x0a
  225.     IL_2be4: ldc.i4.m1
  226.     IL_2be5: ldc.i4.m1
  227.     IL_2be6: ldc.i4.1
  228.     IL_2be7: ldc.r4       1
  229.     IL_2bec: ldc.r4       0.0
  230.     IL_2bf1: call         class [Microsoft.Xna.Framework]Microsoft.Xna.Framework.Audio.SoundEffectInstance Terraria.Main::PlaySound(int32, int32, int32, int32, float32, float32)
  231.     IL_2bf6: pop
  232.  
  233.     // [35765 21 - 35765 38]
  234.     IL_2bf7: ldc.i4.7
  235.     IL_2bf8: stsfld       int32 Terraria.Main::menuMode
  236.  
  237.     // [35767 19 - 35767 42]
  238.     IL_2bfd: ldloc.s      index6
  239.     IL_2bff: ldc.i4.1
  240.     IL_2c00: add
  241.     IL_2c01: stloc.s      index7
  242.  
  243.     // [35768 19 - 35768 61]
  244.     IL_2c03: ldloc.s      buttonNames
  245.     IL_2c05: ldloc.s      index7
  246.     IL_2c07: ldsfld       class Terraria.Localization.LocalizedText[] Terraria.Lang::misc
  247.     IL_2c0c: ldc.i4.s     103 // 0x67
  248.     IL_2c0e: ldelem.ref
  249.     IL_2c0f: callvirt     instance string Terraria.Localization.LocalizedText::get_Value()
  250.     IL_2c14: stelem.ref
  251.  
  252.     // [35769 19 - 35769 51]
  253.     IL_2c15: ldarg.0      // this
  254.     IL_2c16: ldfld        int32 Terraria.Main::selectedMenu
  255.     IL_2c1b: ldloc.s      index7
  256.     IL_2c1d: bne.un.s     IL_2c40
  257.  
  258.     // [35771 21 - 35771 53]
  259.     IL_2c1f: ldc.i4.m1
  260.     IL_2c20: stsfld       int32 Terraria.WorldGen::WorldGenParam_Evil
  261.  
  262.     // [35772 21 - 35772 60]
  263.     IL_2c25: ldc.i4.s     10 // 0x0a
  264.     IL_2c27: ldc.i4.m1
  265.     IL_2c28: ldc.i4.m1
  266.     IL_2c29: ldc.i4.1
  267.     IL_2c2a: ldc.r4       1
  268.     IL_2c2f: ldc.r4       0.0
  269.     IL_2c34: call         class [Microsoft.Xna.Framework]Microsoft.Xna.Framework.Audio.SoundEffectInstance Terraria.Main::PlaySound(int32, int32, int32, int32, float32, float32)
  270.     IL_2c39: pop
  271.  
  272.     // [35773 21 - 35773 38]
  273.     IL_2c3a: ldc.i4.7
  274.     IL_2c3b: stsfld       int32 Terraria.Main::menuMode
  275.  
  276.     // [35775 19 - 35775 42]
  277.     IL_2c40: ldloc.s      index7
  278.     IL_2c42: ldc.i4.1
  279.     IL_2c43: add
  280.     IL_2c44: stloc.s      index8
  281.  
  282.     // [35776 19 - 35776 73]
  283.     IL_2c46: ldloc.s      buttonNames
  284.     IL_2c48: ldloc.s      index8
  285.     IL_2c4a: ldstr        "UI.Back"
  286.     IL_2c4f: call         string Terraria.Localization.Language::GetTextValue(string)
  287.     IL_2c54: stelem.ref
  288.  
  289.     // [35777 19 - 35777 68]
  290.     IL_2c55: ldarg.0      // this
  291.     IL_2c56: ldfld        int32 Terraria.Main::selectedMenu
  292.     IL_2c5b: ldloc.s      index8
  293.     IL_2c5d: ceq
  294.     IL_2c5f: ldloc.s      backButtonDown
  295.     IL_2c61: or
  296.     IL_2c62: brfalse.s    IL_2c83
  297.  
  298.     // [35779 21 - 35779 43]
  299.     IL_2c64: ldc.i4.0
  300.     IL_2c65: stloc.s      backButtonDown
  301.  
  302.     // [35780 21 - 35780 60]
  303.     IL_2c67: ldc.i4.s     11 // 0x0b
  304.     IL_2c69: ldc.i4.m1
  305.     IL_2c6a: ldc.i4.m1
  306.     IL_2c6b: ldc.i4.1
  307.     IL_2c6c: ldc.r4       1
  308.     IL_2c71: ldc.r4       0.0
  309.     IL_2c76: call         class [Microsoft.Xna.Framework]Microsoft.Xna.Framework.Audio.SoundEffectInstance Terraria.Main::PlaySound(int32, int32, int32, int32, float32, float32)
  310.     IL_2c7b: pop
  311.  
  312.     // [35781 21 - 35781 39]
  313.     IL_2c7c: ldc.i4.s     -7 // 0xf9
  314.     IL_2c7e: stsfld       int32 Terraria.Main::menuMode
  315.  
  316.     // [35783 19 - 35783 40]
  317.     IL_2c83: ldloc.s      index8
  318.     IL_2c85: ldc.i4.1
  319.     IL_2c86: add
  320.     IL_2c87: stloc.s      num8
  321.  
  322.     // [35784 19 - 35784 34]
  323.     IL_2c89: call         void Terraria.Main::clrInput()
  324.  
  325. C#:
  326.  
  327.                 case -71:
  328.                   offY = 200;
  329.                   spacing = 60;
  330.                   buttonVerticalSpacing[1] = 30;
  331.                   buttonVerticalSpacing[2] = 30;
  332.                   buttonVerticalSpacing[3] = 30;
  333.                   buttonVerticalSpacing[4] = 70;
  334.                   numButtons = 5;
  335.                   int index4 = 0;
  336.                   buttonNames[index4] = Lang.misc[100].Value;
  337.                   flagArray1[index4] = true;
  338.                   int index5 = index4 + 1;
  339.                   buttonNames[index5] = Lang.misc[101].Value;
  340.                   if (this.selectedMenu == index5)
  341.                   {
  342.                     WorldGen.WorldGenParam_Evil = 0;
  343.                     Main.PlaySound(10, -1, -1, 1, 1f, 0.0f);
  344.                     Main.menuMode = 7;
  345.                   }
  346.                   int index6 = index5 + 1;
  347.                   buttonNames[index6] = Lang.misc[102].Value;
  348.                   if (this.selectedMenu == index6)
  349.                   {
  350.                     WorldGen.WorldGenParam_Evil = 1;
  351.                     Main.PlaySound(10, -1, -1, 1, 1f, 0.0f);
  352.                     Main.menuMode = 7;
  353.                   }
  354.                   int index7 = index6 + 1;
  355.                   buttonNames[index7] = Lang.misc[103].Value;
  356.                   if (this.selectedMenu == index7)
  357.                   {
  358.                     WorldGen.WorldGenParam_Evil = -1;
  359.                     Main.PlaySound(10, -1, -1, 1, 1f, 0.0f);
  360.                     Main.menuMode = 7;
  361.                   }
  362.                   int index8 = index7 + 1;
  363.                   buttonNames[index8] = Language.GetTextValue("UI.Back");
  364.                   if (this.selectedMenu == index8 | backButtonDown)
  365.                   {
  366.                     backButtonDown = false;
  367.                     Main.PlaySound(11, -1, -1, 1, 1f, 0.0f);
  368.                     Main.menuMode = -7;
  369.                   }
  370.                   int num8 = index8 + 1;
  371.                   Main.clrInput();
  372.                   break;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement