Skip to content

Commit

Permalink
consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
FoxWorn3365 committed Aug 1, 2024
1 parent f3b17ea commit 18db618
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions EXILED/Exiled.Events/Patches/Events/Scp079/Recontaining.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace Exiled.Events.Patches.Events.Scp079
using System.Collections.Generic;
using System.Reflection.Emit;

using Exiled.API.Features.Pools;
using Exiled.Events.Attributes;
using Exiled.Events.EventArgs.Scp079;
using Exiled.Events.Handlers;
Expand All @@ -31,11 +32,11 @@ internal class Recontaining
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
{
int index = 0;
List<CodeInstruction> newInstructions = new(instructions);
List<CodeInstruction> newInstructions = ListPool<CodeInstruction>.Pool.Get(instructions);

LocalBuilder ev = generator.DeclareLocal(typeof(RecontainingEventArgs));

Label proceed = generator.DefineLabel();
Label returnLabel = generator.DefineLabel();

newInstructions.InsertRange(index, new CodeInstruction[]
{
Expand All @@ -52,14 +53,17 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
// if (!ev.IsAllowed) return;
new(OpCodes.Ldarg_S, ev.LocalIndex),
new(OpCodes.Callvirt, Method(typeof(RecontainingEventArgs), nameof(RecontainingEventArgs.IsAllowed))),
new(OpCodes.Brtrue_S, proceed),
new(OpCodes.Brtrue_S, returnLabel),

new(OpCodes.Ret),

new CodeInstruction(OpCodes.Nop).WithLabels(proceed),
});

return newInstructions;
newInstructions[newInstructions.Count - 1].WithLabels(returnLabel);

for (int z = 0; z < newInstructions.Count; z++)
yield return newInstructions[z];

ListPool<CodeInstruction>.Pool.Return(newInstructions);
}
}
}

0 comments on commit 18db618

Please sign in to comment.