Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions EXILED/Exiled.Events/Patches/Events/Server/RoundEnd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,11 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
});

// Get the whole leadingteam logic
offset = -20;
index = newInstructions.FindIndex(x => x.StoresField(Field(PrivateType, LeadingTeam))) + offset;
int offset2 = -1;
int index2 = newInstructions.FindIndex(x => x.LoadsField(Field(PrivateType, LeadingTeam))) + offset2;
offset = 2;
index = newInstructions.FindLastIndex(x => x.LoadsField(Field(typeof(RoundSummary), nameof(RoundSummary.IsRoundEnded)))) + offset;
int offset2 = -2;
int index2 = newInstructions.FindIndex(i => i.opcode == OpCodes.Newobj && (ConstructorInfo)i.operand == GetDeclaredConstructors(typeof(LabApi.Events.Arguments.ServerEvents.RoundEndingEventArgs))[0]) + offset2;

List<CodeInstruction> leadingTeamLogic = newInstructions.GetRange(index, index2 - index);
List<Label> moveLabel = newInstructions[index2].ExtractLabels();
newInstructions.RemoveRange(index, index2 - index);
Expand All @@ -108,7 +109,7 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi

newInstructions.InsertRange(
index,
new CodeInstruction[]
new[]
{
// this.LeadingTeam
new CodeInstruction(OpCodes.Ldarg_0).WithLabels(moveLabel),
Expand All @@ -118,8 +119,8 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
new(OpCodes.Ldarg_0),
new(OpCodes.Ldfld, Field(PrivateType, NewList)),

// this._roundEnded
new(OpCodes.Ldarg_0),
// roundSummary.IsRoundEnded
new(OpCodes.Ldloc_1),
new(OpCodes.Ldfld, Field(typeof(RoundSummary), nameof(RoundSummary.IsRoundEnded))),

// EndingRoundEventArgs evEndingRound = new(LeadingTeam, RoundSummary.SumInfo_ClassList, bool);
Expand All @@ -131,7 +132,7 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
new(OpCodes.Stloc_S, evEndingRound.LocalIndex),

// this.IsRoundEnded = ev.IsAllowed
new(OpCodes.Ldarg_0),
new(OpCodes.Ldloc_1),
new(OpCodes.Ldloc_S, evEndingRound.LocalIndex),
new(OpCodes.Callvirt, PropertyGetter(typeof(EndingRoundEventArgs), nameof(EndingRoundEventArgs.IsAllowed))),
new(OpCodes.Stfld, Field(typeof(RoundSummary), nameof(RoundSummary.IsRoundEnded))),
Expand Down
Loading