Skip to content

Commit

Permalink
WeirdFix
Browse files Browse the repository at this point in the history
  • Loading branch information
louis1706 committed Aug 1, 2024
1 parent db53ca7 commit 4a2cbaf
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 9 deletions.
3 changes: 2 additions & 1 deletion EXILED/Exiled.CustomItems/Patches/PlayerInventorySee.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace Exiled.CustomItems.Patches
{
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;

Expand Down Expand Up @@ -52,7 +53,7 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
index,
new[]
{
new(OpCodes.Call, Method(typeof(Item), nameof(Item.Get), new[] { typeof(ItemBase), })),
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))),
new(OpCodes.Dup),
new(OpCodes.Stloc_S, item.LocalIndex),
new(OpCodes.Brfalse_S, continueLabel),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace Exiled.Events.Patches.Events.Item
{
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Emit;

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

// Item::Get(firearm)
new(OpCodes.Ldloc_1),
new(OpCodes.Call, Method(typeof(Item), nameof(Item.Get), new[] { typeof(InventorySystem.Items.ItemBase) })),
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))),
new(OpCodes.Castclass, typeof(Firearm)),

// AttachmentsChangeRequest::AttachmentsCode
Expand Down
3 changes: 2 additions & 1 deletion EXILED/Exiled.Events/Patches/Events/Map/Scp244Spawning.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace Exiled.Events.Patches.Events.Map
{
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Emit;

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

new(OpCodes.Ldloc_S, pickup.LocalIndex),
new(OpCodes.Call, Method(typeof(Pickup), nameof(Pickup.Get), new[] { typeof(ItemPickupBase) })),
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))),

new(OpCodes.Newobj, GetDeclaredConstructors(typeof(Scp244SpawningEventArgs))[0]),
new(OpCodes.Dup),
Expand Down
3 changes: 2 additions & 1 deletion EXILED/Exiled.Events/Patches/Events/Player/DroppingItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace Exiled.Events.Patches.Events.Player
{
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Emit;

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

// Pickup::Get(ItemPickupBase)
new(OpCodes.Ldloc_1),
new(OpCodes.Call, Method(typeof(Pickup), nameof(Pickup.Get), new[] { typeof(ItemPickupBase) })),
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))),

// ev.IsThrown
new(OpCodes.Ldloc_S, ev.LocalIndex),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace Exiled.Events.Patches.Events.Player
{
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;

Expand Down Expand Up @@ -69,7 +70,7 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
// if (Firearm == null)
// return;
new CodeInstruction(OpCodes.Ldloc_1),
new(OpCodes.Call, Method(typeof(API.Features.Items.Item), nameof(API.Features.Items.Item.Get), new[] { typeof(ItemBase) })),
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))),
new(OpCodes.Isinst, typeof(Firearm)),
new(OpCodes.Dup),
new(OpCodes.Stloc_S, firearm.LocalIndex),
Expand Down
3 changes: 2 additions & 1 deletion EXILED/Exiled.Events/Patches/Fixes/GrenadePropertiesFix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace Exiled.Events.Patches.Fixes
{
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Emit;

using API.Features.Items;
Expand Down Expand Up @@ -58,7 +59,7 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
{
// if (Item.Get(this) is Throwable throwable) goto cnt;
new CodeInstruction(OpCodes.Ldarg_0),
new(OpCodes.Call, Method(typeof(Item), nameof(Item.Get), new[] { typeof(ItemBase) })),
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))),
new(OpCodes.Isinst, typeof(Throwable)),
new(OpCodes.Dup),
new(OpCodes.Stloc_S, throwable.LocalIndex),
Expand Down
7 changes: 4 additions & 3 deletions EXILED/Exiled.Events/Patches/Generic/PickupControlPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace Exiled.Events.Patches.Generic
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Emit;

using API.Features.Pickups;
Expand Down Expand Up @@ -48,11 +49,11 @@ private static IEnumerable<CodeInstruction> Transpiler(
{
// pickup = Pickup.Get(pickupBase);
new(OpCodes.Ldloc_0),
new(OpCodes.Call, Method(typeof(Pickup), nameof(Pickup.Get), new[] { typeof(ItemPickupBase) })),
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))),

// Item.Get(itemBase);
new(OpCodes.Ldarg_0),
new(OpCodes.Call, Method(typeof(Item), nameof(Item.Get), new[] { typeof(ItemBase) })),
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))),

// pickup.ReadItemInfo(item);
new(OpCodes.Callvirt, Method(typeof(Pickup), nameof(Pickup.ReadItemInfo))),
Expand All @@ -79,7 +80,7 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
{
// Pickup.Get(pickupBase)
new(OpCodes.Ldarg_0),
new(OpCodes.Call, Method(typeof(Pickup), nameof(Pickup.Get), new[] { typeof(ItemPickupBase) })),
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))),
new(OpCodes.Pop),
});

Expand Down

0 comments on commit 4a2cbaf

Please sign in to comment.