From 4a62f96debb1150556226155d09b7873cc8a1eeb Mon Sep 17 00:00:00 2001 From: Yamato Date: Sat, 7 Dec 2024 01:16:19 +0100 Subject: [PATCH 1/6] IDK why don't work --- .../EventArgs/Server/EndingRoundEventArgs.cs | 27 ++------- .../Patches/Events/Server/RoundEnd.cs | 58 ++++++++++--------- 2 files changed, 37 insertions(+), 48 deletions(-) diff --git a/EXILED/Exiled.Events/EventArgs/Server/EndingRoundEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Server/EndingRoundEventArgs.cs index bbdce5c087..2d5f14fa80 100644 --- a/EXILED/Exiled.Events/EventArgs/Server/EndingRoundEventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Server/EndingRoundEventArgs.cs @@ -21,16 +21,19 @@ public class EndingRoundEventArgs : IDeniableEvent /// /// /// + /// + /// + /// /// /// /// /// /// /// - public EndingRoundEventArgs(RoundSummary.SumInfo_ClassList classList, bool isForceEnded, bool isAllowed) + public EndingRoundEventArgs(RoundSummary.SumInfo_ClassList classList, LeadingTeam leadingTeam, bool isForceEnded, bool isAllowed) { ClassList = classList; - LeadingTeam = GetLeadingTeam(classList); + LeadingTeam = leadingTeam; IsForceEnded = isForceEnded; IsAllowed = isAllowed; } @@ -54,25 +57,5 @@ public EndingRoundEventArgs(RoundSummary.SumInfo_ClassList classList, bool isFor /// Gets or sets a value indicating whether the round is going to finish or not. /// public bool IsAllowed { get; set; } - - private LeadingTeam GetLeadingTeam(RoundSummary.SumInfo_ClassList classList) - { - // NW logic - int facilityForces = classList.mtf_and_guards + classList.scientists; - int chaosInsurgency = classList.chaos_insurgents + classList.class_ds; - int anomalies = classList.scps_except_zombies + classList.zombies; - int num4 = facilityForces > 0 ? 1 : 0; - bool flag1 = chaosInsurgency > 0; - bool flag2 = anomalies > 0; - RoundSummary.LeadingTeam leadingTeam = RoundSummary.LeadingTeam.Draw; - if (num4 != 0) - leadingTeam = RoundSummary.EscapedScientists >= RoundSummary.EscapedClassD ? RoundSummary.LeadingTeam.FacilityForces : RoundSummary.LeadingTeam.Draw; - else if (flag2 || flag2 & flag1) - leadingTeam = RoundSummary.EscapedClassD > RoundSummary.SurvivingSCPs ? RoundSummary.LeadingTeam.ChaosInsurgency : (RoundSummary.SurvivingSCPs > RoundSummary.EscapedScientists ? RoundSummary.LeadingTeam.Anomalies : RoundSummary.LeadingTeam.Draw); - else if (flag1) - leadingTeam = RoundSummary.EscapedClassD >= RoundSummary.EscapedScientists ? RoundSummary.LeadingTeam.ChaosInsurgency : RoundSummary.LeadingTeam.Draw; - - return (LeadingTeam)leadingTeam; - } } } \ No newline at end of file diff --git a/EXILED/Exiled.Events/Patches/Events/Server/RoundEnd.cs b/EXILED/Exiled.Events/Patches/Events/Server/RoundEnd.cs index 489e015a19..a5038f20b0 100644 --- a/EXILED/Exiled.Events/Patches/Events/Server/RoundEnd.cs +++ b/EXILED/Exiled.Events/Patches/Events/Server/RoundEnd.cs @@ -70,6 +70,9 @@ private static IEnumerable Transpiler(IEnumerable), nameof(HashSet.Contains))), new(OpCodes.Brtrue_S, jmp), + new(OpCodes.Pop), + new(OpCodes.Stfld, Field(PrivateType, LeadingTeam)), + new(OpCodes.Stfld, Field(PrivateType, LeadingTeam)), }); offset = 4; @@ -77,18 +80,39 @@ private static IEnumerable Transpiler(IEnumerable x.StoresField(Field(PrivateType, LeadingTeam))) + offset; + int offset2 = 1; + int index2 = newInstructions.FindLastIndex(x => x.StoresField(Field(PrivateType, LeadingTeam))) + offset2; + Log.Error($"Index A {index} Index B {index2} opcode a suprimé {index2 - index}"); + List leadingTeamLogic = newInstructions.GetRange(index, index2 - index); + List