diff --git a/EXILED/Exiled.Events/Patches/Fixes/VoiceChatTpsFix.cs b/EXILED/Exiled.Events/Patches/Fixes/VoiceChatTpsFix.cs new file mode 100644 index 0000000000..06e0079511 --- /dev/null +++ b/EXILED/Exiled.Events/Patches/Fixes/VoiceChatTpsFix.cs @@ -0,0 +1,43 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Exiled Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.Patches.Fixes +{ + using System.Collections.Generic; + using System.Configuration; + using System.Reflection.Emit; + + using API.Features.Pools; + + using HarmonyLib; + + using VoiceChat.Networking; + + using static HarmonyLib.AccessTools; + + /// + /// Fixes method. + /// + [HarmonyPatch(typeof(VoiceTransceiver), nameof(VoiceTransceiver.ServerReceiveMessage))] + internal static class VoiceChatTpsFix + { + private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) + { + List newInstructions = ListPool.Pool.Get(instructions); + int offset = -1; + int index = newInstructions.FindIndex(instruction => instruction.opcode == OpCodes.Newarr) + offset; + + // set new array size to 480 + newInstructions[index].operand = 480; + + for (int z = 0; z < newInstructions.Count; z++) + yield return newInstructions[z]; + + ListPool.Pool.Return(newInstructions); + } + } +}