Skip to content
This repository has been archived by the owner on Jan 19, 2025. It is now read-only.

Commit

Permalink
Added Tps Fix For VoiceChat (#2789)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mar1ki authored Oct 27, 2024
1 parent 4244325 commit 5e7a255
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions Exiled.Events/Patches/Fixes/VoiceChatTpsFix.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// -----------------------------------------------------------------------
// <copyright file="VoiceChatTpsFix.cs" company="Exiled Team">
// Copyright (c) Exiled Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
// </copyright>
// -----------------------------------------------------------------------

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;

/// <summary>
/// Fixes <see cref="VoiceTransceiver.ServerReceiveMessage(Mirror.NetworkConnection, VoiceChat.Networking.VoiceMessage)"/> method.
/// </summary>
[HarmonyPatch(typeof(VoiceTransceiver), nameof(VoiceTransceiver.ServerReceiveMessage))]
internal static class VoiceChatTpsFix
{
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
{
List<CodeInstruction> newInstructions = ListPool<CodeInstruction>.Pool.Get(instructions);
int offset = -1;
int index = newInstructions.FindIndex(instruction => instruction.opcode == OpCodes.Newarr) + offset;

// new array length 480
newInstructions[index].operand = 480;

for (int z = 0; z < newInstructions.Count; z++)
yield return newInstructions[z];

ListPool<CodeInstruction>.Pool.Return(newInstructions);
}
}
}

0 comments on commit 5e7a255

Please sign in to comment.