Skip to content
This repository has been archived by the owner on Jan 19, 2025. It is now read-only.

Commit

Permalink
final fix
Browse files Browse the repository at this point in the history
  • Loading branch information
VALERA771 committed Apr 2, 2024
1 parent 67fe593 commit a751ac8
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions Exiled.Events/Patches/Events/Map/ElevatorMovingAndArrived.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi

int index = newInstructions.FindIndex(x => x.Calls(PropertyGetter(typeof(NetworkServer), nameof(NetworkServer.active))));

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

newInstructions.InsertRange(
index,
Expand All @@ -56,9 +56,14 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
new(OpCodes.Call, Method(typeof(Handlers.Map), nameof(Handlers.Map.OnElevatorMoving))),

// if (!ev.IsAllowed)
// return;
// return false;
new(OpCodes.Callvirt, PropertyGetter(typeof(ElevatorMovingEventArgs), nameof(ElevatorMovingEventArgs.IsAllowed))),
new(OpCodes.Brfalse_S, returnLabel),
new(OpCodes.Brtrue_S, continueLabel),

new(OpCodes.Ldc_I4_0),
new(OpCodes.Ret),

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

int offset = 1;
Expand All @@ -79,8 +84,6 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
new(OpCodes.Call, Method(typeof(Handlers.Map), nameof(Handlers.Map.OnElevatorArrived))),
});

newInstructions[newInstructions.Count - 1].labels.Add(returnLabel);

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

Expand Down

0 comments on commit a751ac8

Please sign in to comment.