From 867793925514ab0a4fcce15729dc6155f64c10ab Mon Sep 17 00:00:00 2001
From: "@Someone" <45270312+Someone-193@users.noreply.github.com>
Date: Fri, 1 Aug 2025 18:41:58 -0400
Subject: [PATCH 1/2] Fix 3114 Dancing + minor docs fix
---
EXILED/Exiled.API/Features/Player.cs | 2 +-
.../Patches/Events/Scp3114/Dancing.cs | 48 +++++--------------
2 files changed, 12 insertions(+), 38 deletions(-)
diff --git a/EXILED/Exiled.API/Features/Player.cs b/EXILED/Exiled.API/Features/Player.cs
index 197812f710..884230151f 100644
--- a/EXILED/Exiled.API/Features/Player.cs
+++ b/EXILED/Exiled.API/Features/Player.cs
@@ -608,7 +608,7 @@ public ScpSpawnPreferences.SpawnPreferences ScpPreferences
public bool HasFlashlightModuleEnabled => CurrentItem is Firearm firearm && firearm.FlashlightEnabled;
///
- /// Gets a value indicating whether the player is jumping.
+ /// Gets or sets a value indicating whether the player is jumping.
///
public bool IsJumping
{
diff --git a/EXILED/Exiled.Events/Patches/Events/Scp3114/Dancing.cs b/EXILED/Exiled.Events/Patches/Events/Scp3114/Dancing.cs
index 60e5863c99..53798e1a31 100644
--- a/EXILED/Exiled.Events/Patches/Events/Scp3114/Dancing.cs
+++ b/EXILED/Exiled.Events/Patches/Events/Scp3114/Dancing.cs
@@ -7,8 +7,6 @@
namespace Exiled.Events.Patches.Events.Scp3114
{
-#pragma warning disable SA1402 // File may only contain a single type
-
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Emit;
@@ -35,7 +33,7 @@ private static IEnumerable Transpiler(IEnumerable newInstructions = ListPool.Pool.Get(instructions);
- int index = newInstructions.FindIndex(x => x.opcode == OpCodes.Brfalse_S);
+ int index = newInstructions.FindIndex(x => x.opcode == OpCodes.Brfalse);
Label continueLabel = generator.DefineLabel();
@@ -58,7 +56,7 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable x.opcode == OpCodes.Ldc_I4_0);
- ListPool.Pool.Return(newInstructions);
- }
- }
+ newInstructions.RemoveRange(index, 3);
- ///
- /// Patches
- /// to add event.
- ///
- [HarmonyPatch(typeof(Scp3114Dance), nameof(Scp3114Dance.ServerWriteRpc))]
- internal class ChooseDanceType
- {
- private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator)
- {
- List newInstructions = ListPool.Pool.Get(instructions);
-
- int offset = -4;
- int index = newInstructions.FindIndex(x => x.operand == (object)Method(typeof(NetworkWriter), nameof(NetworkWriter.WriteByte))) + offset;
-
- newInstructions.RemoveRange(index, 4);
-
- // replace "writer.WriteByte((byte)UnityEngine.Random.Range(0, 255))"
- // with "writer.WriteByte(ChooseDanceType.DanceType)"
- newInstructions.InsertRange(index, new CodeInstruction[]
+ newInstructions.InsertRange(
+ index,
+ new[]
{
- // Handle(Player.Get(this.Owner));
- new(OpCodes.Ldarg_0),
-
- new(OpCodes.Call, Method(typeof(ChooseDanceType), nameof(Handle))),
+ new CodeInstruction(OpCodes.Ldloc, ev),
+ new(OpCodes.Call, PropertyGetter(typeof(DancingEventArgs), nameof(DancingEventArgs.DanceType))),
});
for (int z = 0; z < newInstructions.Count; z++)
@@ -114,8 +91,5 @@ private static IEnumerable Transpiler(IEnumerable.Pool.Return(newInstructions);
}
-
- private static byte Handle(Scp3114Dance scp3114Dance)
- => (byte)Player.Get(scp3114Dance.Owner).Role.As().DanceType;
}
}
\ No newline at end of file
From 764e50ffa5e4bea05fc6ab7cf6f1775656117021 Mon Sep 17 00:00:00 2001
From: "@Someone" <45270312+Someone-193@users.noreply.github.com>
Date: Fri, 1 Aug 2025 21:07:49 -0400
Subject: [PATCH 2/2] Fix PrefabManager, ChangingAttachments Transpiler,
Escaping and Escaped transpiler, and Shooting transpiler
---
.../Handlers/Internal/ClientStarted.cs | 20 +++++++++++++++++--
.../Events/Item/ChangingAttachments.cs | 4 ++--
.../Events/Player/EscapingAndEscaped.cs | 18 ++++++++---------
.../Patches/Events/Player/Shooting.cs | 4 ----
4 files changed, 29 insertions(+), 17 deletions(-)
diff --git a/EXILED/Exiled.Events/Handlers/Internal/ClientStarted.cs b/EXILED/Exiled.Events/Handlers/Internal/ClientStarted.cs
index 46e1f5881d..7fd6df8af0 100644
--- a/EXILED/Exiled.Events/Handlers/Internal/ClientStarted.cs
+++ b/EXILED/Exiled.Events/Handlers/Internal/ClientStarted.cs
@@ -33,14 +33,30 @@ public static void OnClientStarted()
foreach (KeyValuePair prefab in NetworkClient.prefabs)
{
- if(!prefabs.ContainsKey(prefab.Key) && prefab.Value.TryGetComponent(out Component component))
+ if (!prefabs.ContainsKey(prefab.Key))
+ {
+ if (!prefab.Value.TryGetComponent(out NetworkBehaviour component))
+ {
+ Log.Error($"Failed to get component for prefab: {prefab.Value.name} ({prefab.Key})");
+ continue;
+ }
+
prefabs.Add(prefab.Key, (prefab.Value, component));
+ }
}
foreach (NetworkIdentity ragdollPrefab in RagdollManager.AllRagdollPrefabs)
{
- if(!prefabs.ContainsKey(ragdollPrefab.assetId) && ragdollPrefab.gameObject.TryGetComponent(out Component component))
+ if (!prefabs.ContainsKey(ragdollPrefab.assetId))
+ {
+ if (!ragdollPrefab.TryGetComponent(out BasicRagdoll component))
+ {
+ Log.Error($"Failed to get component for ragdoll prefab: {ragdollPrefab.name}");
+ continue;
+ }
+
prefabs.Add(ragdollPrefab.assetId, (ragdollPrefab.gameObject, component));
+ }
}
for (int i = 0; i < EnumUtils.Values.Length; i++)
diff --git a/EXILED/Exiled.Events/Patches/Events/Item/ChangingAttachments.cs b/EXILED/Exiled.Events/Patches/Events/Item/ChangingAttachments.cs
index e4069148ff..6e45fbd152 100644
--- a/EXILED/Exiled.Events/Patches/Events/Item/ChangingAttachments.cs
+++ b/EXILED/Exiled.Events/Patches/Events/Item/ChangingAttachments.cs
@@ -50,7 +50,7 @@ private static IEnumerable Transpiler(IEnumerable i.IsLdarg(1)) - 1;
+ int index = newInstructions.FindIndex(i => i.opcode == OpCodes.Stloc_2) - 2;
List