Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
louis1706 committed Aug 3, 2024
1 parent 877469e commit d88d592
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
{
// Scp106Role scp106Role = base.Hub.roleManager.CurrentRole as Scp106Role;
new CodeInstruction(OpCodes.Ldarg_0),
new CodeInstruction(OpCodes.Call, PropertyGetter(typeof(StatusEffectBase), nameof(StatusEffectBase.Hub))),
new CodeInstruction(OpCodes.Callvirt, PropertyGetter(typeof(StatusEffectBase), nameof(StatusEffectBase.Hub))),
new CodeInstruction(OpCodes.Ldfld, Field(typeof(ReferenceHub), nameof(ReferenceHub.roleManager))),
new CodeInstruction(OpCodes.Callvirt, PropertyGetter(typeof(PlayerRoleManager), nameof(PlayerRoleManager.CurrentRole))),
new CodeInstruction(OpCodes.Isinst, typeof(Scp106Role)),
Expand Down
45 changes: 45 additions & 0 deletions EXILED/Exiled.Events/Patches/Fixes/WarheadConfigLockGateFix.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// -----------------------------------------------------------------------
// <copyright file="WarheadConfigLockGateFix.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.Pools;
using Footprinting;
using HarmonyLib;
using Interactables.Interobjects.DoorUtils;
using InventorySystem;
using InventorySystem.Items.Firearms.Ammo;
using InventorySystem.Items.Pickups;

using static HarmonyLib.AccessTools;

/// <summary>
/// Patches <see cref="DoorEventOpenerExtension.Trigger"/> delegate.
/// Fix than NW config "lock_gates_on_countdown"
/// reported https://git.scpslgame.com/northwood-qa/scpsl-bug-reporting/-/issues/316.
/// </summary>
[HarmonyPatch(typeof(DoorEventOpenerExtension), nameof(DoorEventOpenerExtension.Trigger))]
internal class WarheadConfigLockGateFix
{
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
{
List<CodeInstruction> newInstructions = ListPool<CodeInstruction>.Pool.Get(instructions);

// replace Contains with StartWith
int index = newInstructions.FindIndex(x => x.operand == (object)Method(typeof(string), nameof(string.Contains)));
newInstructions[index].operand = Method(typeof(string), nameof(string.StartsWith), new System.Type[] { typeof(string) });

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

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

0 comments on commit d88d592

Please sign in to comment.