From bca9ce99733d8cbae4005d5993c0b2667d4d9229 Mon Sep 17 00:00:00 2001 From: Misaka-ZeroTwo <45165615+Misaka-ZeroTwo@users.noreply.github.com> Date: Thu, 28 Nov 2024 20:49:00 -0500 Subject: [PATCH 1/2] Update RestartingRound.cs --- .../Patches/Events/Server/RestartingRound.cs | 66 ++++--------------- 1 file changed, 11 insertions(+), 55 deletions(-) diff --git a/EXILED/Exiled.Events/Patches/Events/Server/RestartingRound.cs b/EXILED/Exiled.Events/Patches/Events/Server/RestartingRound.cs index 39dc587c12..ab4ef8b267 100644 --- a/EXILED/Exiled.Events/Patches/Events/Server/RestartingRound.cs +++ b/EXILED/Exiled.Events/Patches/Events/Server/RestartingRound.cs @@ -12,7 +12,10 @@ namespace Exiled.Events.Patches.Events.Server using System.Reflection.Emit; using API.Features.Pools; + using CustomPlayerEffects.Danger; + using Exiled.API.Enums; using Exiled.Events.Attributes; + using Exiled.Events.EventArgs.Player; using GameCore; using HarmonyLib; @@ -20,70 +23,23 @@ namespace Exiled.Events.Patches.Events.Server using RoundRestarting; using static HarmonyLib.AccessTools; + using static PlayerList; /// /// Patches . /// Adds the event. /// [EventPatch(typeof(Handlers.Server), nameof(Handlers.Server.RestartingRound))] - [HarmonyPatch(typeof(RoundRestart), nameof(RoundRestart.InitiateRoundRestart))] + [HarmonyPatch(typeof(RoundRestart), nameof(RoundRestart.IsRoundRestarting), MethodType.Setter)] internal static class RestartingRound { - private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) + // TODO: Convert to transpiler and bring back old features + private static void Prefix(bool value) { - List newInstructions = ListPool.Pool.Get(instructions); + if (!value || value == RoundRestart.IsRoundRestarting) + return; - newInstructions.InsertRange( - 0, - new CodeInstruction[] - { - // Handlers.Server.OnRestartingRound() - new(OpCodes.Call, Method(typeof(Handlers.Server), nameof(Handlers.Server.OnRestartingRound))), - - // API.Features.Log.Debug("Round restarting", Loader.ShouldDebugBeShown) - new(OpCodes.Ldstr, "Round restarting"), - new(OpCodes.Call, Method(typeof(API.Features.Log), nameof(API.Features.Log.Debug), new[] { typeof(string) })), - }); - - const int offset = 1; - int index = newInstructions.FindIndex(instruction => instruction.opcode == OpCodes.Brfalse); - - newInstructions.InsertRange( - index + offset, - new CodeInstruction[] - { - // if (ServerStatic.StopNextRound == ServerStatic.NextRoundAction.Restart) -> goto normal round restart - new(OpCodes.Call, PropertyGetter(typeof(ServerStatic), nameof(ServerStatic.StopNextRound))), - new(OpCodes.Ldc_I4_1), - new(OpCodes.Beq_S, newInstructions[index].operand), - - // if (ShouldServerRestart()) -> goto normal round restart - new(OpCodes.Call, Method(typeof(RestartingRound), nameof(ShouldServerRestart))), - new(OpCodes.Brtrue, newInstructions[index].operand), - }); - - for (int z = 0; z < newInstructions.Count; z++) - yield return newInstructions[z]; - - ListPool.Pool.Return(newInstructions); - } - - private static bool ShouldServerRestart() - { - bool flag = false; - - try - { - int num = ConfigFile.ServerConfig.GetInt("restart_after_rounds"); - - flag = num > 0 && RoundRestart.UptimeRounds >= num; - } - catch (Exception ex) - { - ServerConsole.AddLog("Failed to check the restart_after_rounds config value: " + ex.Message, ConsoleColor.Red); - } - - return flag; + Handlers.Server.OnRestartingRound(); } } -} \ No newline at end of file +} From f51aa6ad282f9e3449fa85380256b458a13cccd5 Mon Sep 17 00:00:00 2001 From: Misaka_ZeroTwo <45165615+Misaka-ZeroTwo@users.noreply.github.com> Date: Fri, 29 Nov 2024 01:20:58 -0500 Subject: [PATCH 2/2] Update InteractingScp330EventArgs.cs --- .../Exiled.Events/EventArgs/Scp330/InteractingScp330EventArgs.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/EXILED/Exiled.Events/EventArgs/Scp330/InteractingScp330EventArgs.cs b/EXILED/Exiled.Events/EventArgs/Scp330/InteractingScp330EventArgs.cs index 1f39abedb7..dc39d420c5 100644 --- a/EXILED/Exiled.Events/EventArgs/Scp330/InteractingScp330EventArgs.cs +++ b/EXILED/Exiled.Events/EventArgs/Scp330/InteractingScp330EventArgs.cs @@ -34,6 +34,7 @@ public InteractingScp330EventArgs(Player player, int usage) ShouldSever = usage >= 2; ShouldPlaySound = true; IsAllowed = Player.IsHuman; + Candy = Scp330Candies.GetRandom(); if (Scp330Bag.TryGetBag(player.ReferenceHub, out Scp330Bag scp330Bag)) {