Skip to content

Commit 4a2cbaf

Browse files
committed
WeirdFix
1 parent db53ca7 commit 4a2cbaf

File tree

7 files changed

+16
-9
lines changed

7 files changed

+16
-9
lines changed

EXILED/Exiled.CustomItems/Patches/PlayerInventorySee.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace Exiled.CustomItems.Patches
99
{
1010
using System.Collections.Generic;
11+
using System.Linq;
1112
using System.Reflection;
1213
using System.Reflection.Emit;
1314

@@ -52,7 +53,7 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
5253
index,
5354
new[]
5455
{
55-
new(OpCodes.Call, Method(typeof(Item), nameof(Item.Get), new[] { typeof(ItemBase), })),
56+
new(OpCodes.Call, GetDeclaredMethods(typeof(Item)).First(x => !x.IsGenericMethod && x.Name is nameof(Item.Get) && x.GetParameters().Length is 1 && x.GetParameters()[0].ParameterType == typeof(ItemBase))),
5657
new(OpCodes.Dup),
5758
new(OpCodes.Stloc_S, item.LocalIndex),
5859
new(OpCodes.Brfalse_S, continueLabel),

EXILED/Exiled.Events/Patches/Events/Item/ChangingAttachments.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace Exiled.Events.Patches.Events.Item
99
{
1010
using System.Collections.Generic;
11+
using System.Linq;
1112
using System.Reflection.Emit;
1213

1314
using API.Features;
@@ -69,7 +70,7 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
6970

7071
// Item::Get(firearm)
7172
new(OpCodes.Ldloc_1),
72-
new(OpCodes.Call, Method(typeof(Item), nameof(Item.Get), new[] { typeof(InventorySystem.Items.ItemBase) })),
73+
new(OpCodes.Call, GetDeclaredMethods(typeof(Item)).First(x => !x.IsGenericMethod && x.Name is nameof(Item.Get) && x.GetParameters().Length is 1 && x.GetParameters()[0].ParameterType == typeof(InventorySystem.Items.ItemBase))),
7374
new(OpCodes.Castclass, typeof(Firearm)),
7475

7576
// AttachmentsChangeRequest::AttachmentsCode

EXILED/Exiled.Events/Patches/Events/Map/Scp244Spawning.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace Exiled.Events.Patches.Events.Map
99
{
1010
using System.Collections.Generic;
11+
using System.Linq;
1112
using System.Reflection.Emit;
1213

1314
using Exiled.API.Features.Pickups;
@@ -61,7 +62,7 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
6162
new(OpCodes.Callvirt, PropertyGetter(typeof(List<RoomIdentifier>), "Item")),
6263

6364
new(OpCodes.Ldloc_S, pickup.LocalIndex),
64-
new(OpCodes.Call, Method(typeof(Pickup), nameof(Pickup.Get), new[] { typeof(ItemPickupBase) })),
65+
new(OpCodes.Call, GetDeclaredMethods(typeof(Pickup)).First(x => !x.IsGenericMethod && x.Name is nameof(Pickup.Get) && x.GetParameters().Length is 1 && x.GetParameters()[0].ParameterType == typeof(ItemPickupBase))),
6566

6667
new(OpCodes.Newobj, GetDeclaredConstructors(typeof(Scp244SpawningEventArgs))[0]),
6768
new(OpCodes.Dup),

EXILED/Exiled.Events/Patches/Events/Player/DroppingItem.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace Exiled.Events.Patches.Events.Player
99
{
1010
using System.Collections.Generic;
11+
using System.Linq;
1112
using System.Reflection.Emit;
1213

1314
using API.Features.Pools;
@@ -119,7 +120,7 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
119120

120121
// Pickup::Get(ItemPickupBase)
121122
new(OpCodes.Ldloc_1),
122-
new(OpCodes.Call, Method(typeof(Pickup), nameof(Pickup.Get), new[] { typeof(ItemPickupBase) })),
123+
new(OpCodes.Call, GetDeclaredMethods(typeof(Item)).First(x => !x.IsGenericMethod && x.Name is nameof(Item.Get) && x.GetParameters().Length is 1 && x.GetParameters()[0].ParameterType == typeof(InventorySystem.Items.ItemBase))),
123124

124125
// ev.IsThrown
125126
new(OpCodes.Ldloc_S, ev.LocalIndex),

EXILED/Exiled.Events/Patches/Events/Player/FirearmRequestReceived.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace Exiled.Events.Patches.Events.Player
99
{
1010
using System.Collections.Generic;
11+
using System.Linq;
1112
using System.Reflection;
1213
using System.Reflection.Emit;
1314

@@ -69,7 +70,7 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
6970
// if (Firearm == null)
7071
// return;
7172
new CodeInstruction(OpCodes.Ldloc_1),
72-
new(OpCodes.Call, Method(typeof(API.Features.Items.Item), nameof(API.Features.Items.Item.Get), new[] { typeof(ItemBase) })),
73+
new(OpCodes.Call, GetDeclaredMethods(typeof(API.Features.Items.Item)).First(x => !x.IsGenericMethod && x.Name is nameof(API.Features.Items.Item.Get) && x.GetParameters().Length is 1 && x.GetParameters()[0].ParameterType == typeof(ItemBase))),
7374
new(OpCodes.Isinst, typeof(Firearm)),
7475
new(OpCodes.Dup),
7576
new(OpCodes.Stloc_S, firearm.LocalIndex),

EXILED/Exiled.Events/Patches/Fixes/GrenadePropertiesFix.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace Exiled.Events.Patches.Fixes
99
{
1010
using System.Collections.Generic;
11+
using System.Linq;
1112
using System.Reflection.Emit;
1213

1314
using API.Features.Items;
@@ -58,7 +59,7 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
5859
{
5960
// if (Item.Get(this) is Throwable throwable) goto cnt;
6061
new CodeInstruction(OpCodes.Ldarg_0),
61-
new(OpCodes.Call, Method(typeof(Item), nameof(Item.Get), new[] { typeof(ItemBase) })),
62+
new(OpCodes.Call, GetDeclaredMethods(typeof(Item)).First(x => !x.IsGenericMethod && x.Name is nameof(Item.Get) && x.GetParameters().Length is 1 && x.GetParameters()[0].ParameterType == typeof(ItemBase))),
6263
new(OpCodes.Isinst, typeof(Throwable)),
6364
new(OpCodes.Dup),
6465
new(OpCodes.Stloc_S, throwable.LocalIndex),

EXILED/Exiled.Events/Patches/Generic/PickupControlPatch.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ namespace Exiled.Events.Patches.Generic
99
{
1010
using System;
1111
using System.Collections.Generic;
12+
using System.Linq;
1213
using System.Reflection.Emit;
1314

1415
using API.Features.Pickups;
@@ -48,11 +49,11 @@ private static IEnumerable<CodeInstruction> Transpiler(
4849
{
4950
// pickup = Pickup.Get(pickupBase);
5051
new(OpCodes.Ldloc_0),
51-
new(OpCodes.Call, Method(typeof(Pickup), nameof(Pickup.Get), new[] { typeof(ItemPickupBase) })),
52+
new(OpCodes.Call, GetDeclaredMethods(typeof(Pickup)).First(x => !x.IsGenericMethod && x.Name is nameof(Pickup.Get) && x.GetParameters().Length is 1 && x.GetParameters()[0].ParameterType == typeof(ItemPickupBase))),
5253

5354
// Item.Get(itemBase);
5455
new(OpCodes.Ldarg_0),
55-
new(OpCodes.Call, Method(typeof(Item), nameof(Item.Get), new[] { typeof(ItemBase) })),
56+
new(OpCodes.Call, GetDeclaredMethods(typeof(Item)).First(x => !x.IsGenericMethod && x.Name is nameof(Item.Get) && x.GetParameters().Length is 1 && x.GetParameters()[0].ParameterType == typeof(ItemBase))),
5657

5758
// pickup.ReadItemInfo(item);
5859
new(OpCodes.Callvirt, Method(typeof(Pickup), nameof(Pickup.ReadItemInfo))),
@@ -79,7 +80,7 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
7980
{
8081
// Pickup.Get(pickupBase)
8182
new(OpCodes.Ldarg_0),
82-
new(OpCodes.Call, Method(typeof(Pickup), nameof(Pickup.Get), new[] { typeof(ItemPickupBase) })),
83+
new(OpCodes.Call, GetDeclaredMethods(typeof(Pickup)).First(x => !x.IsGenericMethod && x.Name is nameof(Pickup.Get) && x.GetParameters().Length is 1 && x.GetParameters()[0].ParameterType == typeof(ItemPickupBase))),
8384
new(OpCodes.Pop),
8485
});
8586

0 commit comments

Comments
 (0)