Skip to content

Commit

Permalink
Ban event improvements & Port TPS Fix to Dev
Browse files Browse the repository at this point in the history
  • Loading branch information
xNexusACS committed Oct 28, 2024
1 parent bad7226 commit 3dbe837
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
5 changes: 5 additions & 0 deletions Exiled.Events/EventArgs/Player/BannedEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,10 @@ public BannedEventArgs(Player target, Player issuer, BanDetails details, BanHand
/// Gets a value indicating whether the ban is forced or not.
/// </summary>
public bool IsForced { get; }

/// <summary>
/// Gets a value indicating whether the ban is an offline ban or not.
/// </summary>
public bool IsOffline => Details.OriginalName == "Unknown - offline ban";
}
}
4 changes: 2 additions & 2 deletions Exiled.Events/Patches/Events/Player/Banned.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
new(OpCodes.Call, Method(typeof(Handlers.Player), nameof(Handlers.Player.OnBanned))),
});

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

ListPool<CodeInstruction>.Pool.Return(newInstructions);
}
Expand Down
41 changes: 41 additions & 0 deletions Exiled.Events/Patches/Fixes/VoiceChatTpsFix.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// -----------------------------------------------------------------------
// <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.Reflection.Emit;

using API.Features.Core.Generic.Pools;

using HarmonyLib;

using VoiceChat.Networking;

/// <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);

const int offset = -1;
int index = newInstructions.FindIndex(instruction => instruction.opcode == OpCodes.Newarr) + offset;

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

foreach (CodeInstruction instruction in newInstructions)
yield return instruction;

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

0 comments on commit 3dbe837

Please sign in to comment.