@@ -87,10 +87,11 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
8787 } ) ;
8888
8989 // Get the whole leadingteam logic
90- offset = - 20 ;
91- index = newInstructions . FindIndex ( x => x . StoresField ( Field ( PrivateType , LeadingTeam ) ) ) + offset ;
92- int offset2 = - 1 ;
93- int index2 = newInstructions . FindIndex ( x => x . LoadsField ( Field ( PrivateType , LeadingTeam ) ) ) + offset2 ;
90+ offset = 2 ;
91+ index = newInstructions . FindLastIndex ( x => x . LoadsField ( Field ( typeof ( RoundSummary ) , nameof ( RoundSummary . IsRoundEnded ) ) ) ) + offset ;
92+ int offset2 = - 2 ;
93+ int index2 = newInstructions . FindIndex ( i => i . opcode == OpCodes . Newobj && ( ConstructorInfo ) i . operand == GetDeclaredConstructors ( typeof ( LabApi . Events . Arguments . ServerEvents . RoundEndingEventArgs ) ) [ 0 ] ) + offset2 ;
94+
9495 List < CodeInstruction > leadingTeamLogic = newInstructions . GetRange ( index , index2 - index ) ;
9596 List < Label > moveLabel = newInstructions [ index2 ] . ExtractLabels ( ) ;
9697 newInstructions . RemoveRange ( index , index2 - index ) ;
@@ -108,7 +109,7 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
108109
109110 newInstructions . InsertRange (
110111 index ,
111- new CodeInstruction [ ]
112+ new [ ]
112113 {
113114 // this.LeadingTeam
114115 new CodeInstruction ( OpCodes . Ldarg_0 ) . WithLabels ( moveLabel ) ,
@@ -118,8 +119,8 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
118119 new ( OpCodes . Ldarg_0 ) ,
119120 new ( OpCodes . Ldfld , Field ( PrivateType , NewList ) ) ,
120121
121- // this._roundEnded
122- new ( OpCodes . Ldarg_0 ) ,
122+ // roundSummary.IsRoundEnded
123+ new ( OpCodes . Ldloc_1 ) ,
123124 new ( OpCodes . Ldfld , Field ( typeof ( RoundSummary ) , nameof ( RoundSummary . IsRoundEnded ) ) ) ,
124125
125126 // EndingRoundEventArgs evEndingRound = new(LeadingTeam, RoundSummary.SumInfo_ClassList, bool);
@@ -131,7 +132,7 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
131132 new ( OpCodes . Stloc_S , evEndingRound . LocalIndex ) ,
132133
133134 // this.IsRoundEnded = ev.IsAllowed
134- new ( OpCodes . Ldarg_0 ) ,
135+ new ( OpCodes . Ldloc_1 ) ,
135136 new ( OpCodes . Ldloc_S , evEndingRound . LocalIndex ) ,
136137 new ( OpCodes . Callvirt , PropertyGetter ( typeof ( EndingRoundEventArgs ) , nameof ( EndingRoundEventArgs . IsAllowed ) ) ) ,
137138 new ( OpCodes . Stfld , Field ( typeof ( RoundSummary ) , nameof ( RoundSummary . IsRoundEnded ) ) ) ,
0 commit comments