From 17adf3dc7bf2221597c9439222c8ae01749fda0b Mon Sep 17 00:00:00 2001 From: "@Someone" <45270312+Someone-193@users.noreply.github.com> Date: Fri, 16 Jan 2026 12:34:09 -0500 Subject: [PATCH 1/3] Revert old fix and add new one --- .../Exiled.Events/Handlers/Internal/Round.cs | 2 +- .../Patches/Fixes/Fix1344Dupe.cs | 60 +++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 EXILED/Exiled.Events/Patches/Fixes/Fix1344Dupe.cs diff --git a/EXILED/Exiled.Events/Handlers/Internal/Round.cs b/EXILED/Exiled.Events/Handlers/Internal/Round.cs index 9b5b6240d..8cad547ff 100644 --- a/EXILED/Exiled.Events/Handlers/Internal/Round.cs +++ b/EXILED/Exiled.Events/Handlers/Internal/Round.cs @@ -82,7 +82,7 @@ public static void OnRestartingRound() /// public static void OnChangingRole(ChangingRoleEventArgs ev) { - if (!ev.Player.IsHost && ev.NewRole == RoleTypeId.Spectator && ev.Reason is not(SpawnReason.Destroyed or SpawnReason.Died) && Events.Instance.Config.ShouldDropInventory) + if (!ev.Player.IsHost && ev.NewRole == RoleTypeId.Spectator && ev.Reason is not SpawnReason.Destroyed && Events.Instance.Config.ShouldDropInventory) ev.Player.Inventory.ServerDropEverything(); } diff --git a/EXILED/Exiled.Events/Patches/Fixes/Fix1344Dupe.cs b/EXILED/Exiled.Events/Patches/Fixes/Fix1344Dupe.cs new file mode 100644 index 000000000..b831da35a --- /dev/null +++ b/EXILED/Exiled.Events/Patches/Fixes/Fix1344Dupe.cs @@ -0,0 +1,60 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) ExMod Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.Patches.Fixes +{ + using System.Collections.Generic; + using System.Reflection.Emit; + + using Exiled.API.Features.Pools; + using HarmonyLib; + using InventorySystem; + using InventorySystem.Items; + using InventorySystem.Items.Usables.Scp1344; + + using static HarmonyLib.AccessTools; + + /// + /// Patches the method. + /// Fixes the dupe where 2 copies of SCP-1344 can be dropped at once. + /// Bug not reported to NW yet (rare in vanilla servers). + /// + [HarmonyPatch(typeof(Scp1344Item), nameof(Scp1344Item.OnPlayerInventoryDropped))] + public class Fix1344Dupe + { + private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) + { + List newInstructions = ListPool.Pool.Get(instructions); + + Label returnLabel = generator.DefineLabel(); + + newInstructions[newInstructions.Count - 1].labels.Add(returnLabel); + + int offset = 1; + int index = newInstructions.FindIndex(x => x.opcode == OpCodes.Ret) + offset; + + newInstructions.InsertRange(index, new[] + { + new CodeInstruction(OpCodes.Ldarg_0).MoveLabelsFrom(newInstructions[index]), + new(OpCodes.Callvirt, PropertyGetter(typeof(Scp1344Item), nameof(Scp1344Item.OwnerInventory))), + new(OpCodes.Ldfld, Field(typeof(Inventory), nameof(Inventory.UserInventory))), + new(OpCodes.Ldfld, Field(typeof(InventoryInfo), nameof(InventoryInfo.Items))), + + new(OpCodes.Ldarg_0), + new(OpCodes.Callvirt, PropertyGetter(typeof(Scp1344Item), nameof(Scp1344Item.ItemSerial))), + + new(OpCodes.Callvirt, Method(typeof(Dictionary), nameof(Dictionary.ContainsKey))), + new(OpCodes.Brfalse_S, returnLabel), + }); + + for (int z = 0; z < newInstructions.Count; z++) + yield return newInstructions[z]; + + ListPool.Pool.Return(newInstructions); + } + } +} \ No newline at end of file From 8d75f916b4a485a7aefa039f47acb9ec20a48ac0 Mon Sep 17 00:00:00 2001 From: "@Someone" <45270312+Someone-193@users.noreply.github.com> Date: Fri, 16 Jan 2026 12:44:56 -0500 Subject: [PATCH 2/3] docs --- EXILED/Exiled.Events/Patches/Fixes/Fix1344Dupe.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/EXILED/Exiled.Events/Patches/Fixes/Fix1344Dupe.cs b/EXILED/Exiled.Events/Patches/Fixes/Fix1344Dupe.cs index b831da35a..624a52872 100644 --- a/EXILED/Exiled.Events/Patches/Fixes/Fix1344Dupe.cs +++ b/EXILED/Exiled.Events/Patches/Fixes/Fix1344Dupe.cs @@ -39,14 +39,17 @@ private static IEnumerable Transpiler(IEnumerable), nameof(Dictionary.ContainsKey))), new(OpCodes.Brfalse_S, returnLabel), }); From cc05c8fc131157c491c0af5dfe2e97b9c308b6d4 Mon Sep 17 00:00:00 2001 From: "@Someone" <45270312+Someone-193@users.noreply.github.com> Date: Fri, 16 Jan 2026 12:45:16 -0500 Subject: [PATCH 3/3] more docs --- EXILED/Exiled.Events/Patches/Fixes/Fix1344Dupe.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EXILED/Exiled.Events/Patches/Fixes/Fix1344Dupe.cs b/EXILED/Exiled.Events/Patches/Fixes/Fix1344Dupe.cs index 624a52872..1bd3f62bf 100644 --- a/EXILED/Exiled.Events/Patches/Fixes/Fix1344Dupe.cs +++ b/EXILED/Exiled.Events/Patches/Fixes/Fix1344Dupe.cs @@ -20,7 +20,7 @@ namespace Exiled.Events.Patches.Fixes /// /// Patches the method. - /// Fixes the dupe where 2 copies of SCP-1344 can be dropped at once. + /// Fixes the dupe where 2 copies of SCP-1344 can be created when a player dies. /// Bug not reported to NW yet (rare in vanilla servers). /// [HarmonyPatch(typeof(Scp1344Item), nameof(Scp1344Item.OnPlayerInventoryDropped))]