Skip to content

Commit

Permalink
Fix IL ERROR
Browse files Browse the repository at this point in the history
  • Loading branch information
louis1706 committed May 18, 2024
1 parent 62eab24 commit e5da49c
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions Exiled.Events/Patches/Events/Scp106/Attacking.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
{
List<CodeInstruction> newInstructions = ListPool<CodeInstruction>.Pool.Get(instructions);

int offset = 2;
int index = newInstructions.FindIndex(x => x.Calls(Method(typeof(Scp106Attack), nameof(Scp106Attack.SendCooldown)))) + offset;
Label continueLabel = generator.DefineLabel();
int offset = 3;
int index = newInstructions.FindIndex(x => x.Calls(Method(typeof(Scp106Attack), nameof(Scp106Attack.VerifyShot)))) + offset;
Label ret = generator.DefineLabel();

newInstructions.InsertRange(
index,
Expand Down Expand Up @@ -63,13 +63,9 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
// if (!ev.IsAllowed)
// return;
new(OpCodes.Callvirt, PropertyGetter(typeof(AttackingEventArgs), nameof(AttackingEventArgs.IsAllowed))),
new(OpCodes.Brtrue_S, continueLabel),

new(OpCodes.Leave, newInstructions[newInstructions.Count - 1].labels.First()),

new CodeInstruction(OpCodes.Nop).WithLabels(continueLabel),
new(OpCodes.Brfalse_S, ret),
});

newInstructions[newInstructions.Count - 1].labels.Add(ret);
for (int z = 0; z < newInstructions.Count; z++)
yield return newInstructions[z];

Expand Down

0 comments on commit e5da49c

Please sign in to comment.