Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trello is no more & more NW Fix & Fix IL Code on dev #28

Merged
merged 16 commits into from
Aug 10, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// </copyright>
// -----------------------------------------------------------------------

namespace Exiled.Events.EventArgs.Player
namespace Exiled.Events.EventArgs.Player // TODO: Wrong namespace should be Server
{
using API.Features;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public FinishingRecallEventArgs(Player target, Player scp049, BasicRagdoll ragdo
Scp049 = Player.Role.As<Scp049Role>();
Target = target;
Ragdoll = Ragdoll.Get(ragdoll);
IsAllowed = isAllowed && Target.Role is SpectatorRole spectatorRole && spectatorRole.IsReadyToRespawn;
IsAllowed = isAllowed;
}

/// <inheritdoc/>
Expand Down
2 changes: 1 addition & 1 deletion EXILED/Exiled.Events/Handlers/Internal/MapGenerated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static void OnMapGenerated()
Map.ClearCache();
PrefabHelper.LoadPrefabs();

// TODO: Fix For (https://trello.com/c/cUwpZDLs/5003-config-teamrespawnqueue-in-configgameplay-is-not-working-as-expected)
// TODO: Fix For (https://git.scpslgame.com/northwood-qa/scpsl-bug-reporting/-/issues/377)
PlayerRoles.RoleAssign.HumanSpawner.Handlers[PlayerRoles.Team.ChaosInsurgency] = new PlayerRoles.RoleAssign.OneRoleHumanSpawner(PlayerRoles.RoleTypeId.ChaosConscript);
PlayerRoles.RoleAssign.HumanSpawner.Handlers[PlayerRoles.Team.OtherAlive] = new PlayerRoles.RoleAssign.OneRoleHumanSpawner(PlayerRoles.RoleTypeId.Tutorial);
PlayerRoles.RoleAssign.HumanSpawner.Handlers[PlayerRoles.Team.Dead] = new PlayerRoles.RoleAssign.OneRoleHumanSpawner(PlayerRoles.RoleTypeId.Spectator);
Expand Down
2 changes: 1 addition & 1 deletion EXILED/Exiled.Events/Handlers/Internal/Round.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public static void OnVerified(VerifiedEventArgs ev)
{
RoleAssigner.CheckLateJoin(ev.Player.ReferenceHub, ClientInstanceMode.ReadyClient);

// TODO: Remove if this has been fixed for https://trello.com/c/CzPD304L/5983-networking-blackout-is-not-synchronized-for-the-new-players
// TODO: Remove if this has been fixed for https://git.scpslgame.com/northwood-qa/scpsl-bug-reporting/-/issues/52
foreach (Room room in Room.List.Where(current => current.AreLightsOff))
{
ev.Player.SendFakeSyncVar(room.RoomLightControllerNetIdentity, typeof(RoomLightController), nameof(RoomLightController.NetworkLightsEnabled), true);
Expand Down
4 changes: 2 additions & 2 deletions EXILED/Exiled.Events/Patches/Events/Player/Escaping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
{
OpCode opcode = newInstructions[i].opcode;
if (opcode == OpCodes.Stloc_0)
newInstructions[i] = new(OpCodes.Stloc_S, fpcRole.LocalIndex);
newInstructions[i] = new CodeInstruction(OpCodes.Stloc_S, fpcRole.LocalIndex).WithLabels(newInstructions[i].labels);
else if (opcode == OpCodes.Ldloc_0)
newInstructions[i] = new(OpCodes.Ldloc_S, fpcRole.LocalIndex);
newInstructions[i] = new CodeInstruction(OpCodes.Ldloc_S, fpcRole.LocalIndex).WithLabels(newInstructions[i].labels);
else if (opcode == OpCodes.Ldc_I4_0 && i > customExit)
newInstructions[i].opcode = OpCodes.Ldc_I4_5;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,8 @@ namespace Exiled.Events.Patches.Events.Scp049
/// <summary>
/// Patches <see cref="Scp049ResurrectAbility.ServerComplete" />.
/// Adds the <see cref="Handlers.Scp049.FinishingRecall" /> event.
/// Fix bug than Overwatch can get force respawn by Scp049
/// Bug reported to NW https://trello.com/c/V0uHP2eV/5745-overwatch-overwatch-can-get-respawned-by-scp-049.
/// The fix is directly inside the <see cref="FinishingRecallEventArgs"/>.
/// </summary>
// [EventPatch(typeof(Handlers.Scp049), nameof(Handlers.Scp049.FinishingRecall))]
[EventPatch(typeof(Handlers.Scp049), nameof(Handlers.Scp049.FinishingRecall))]
[HarmonyPatch(typeof(Scp049ResurrectAbility), nameof(Scp049ResurrectAbility.ServerComplete))]
internal static class FinishingRecall
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,10 @@
int serverEffectLocationStart = -1;
int enableEffect = newInstructions.FindLastIndex(
instruction => instruction.LoadsField(Field(typeof(ReferenceHub), nameof(ReferenceHub.playerEffectsController)))) + serverEffectLocationStart;
newInstructions[enableEffect].WithLabels(enableEffectLabel);
newInstructions.InsertRange(

newInstructions[enableEffect].WithLabels(enableEffectLabel);

Check failure on line 86 in EXILED/Exiled.Events/Patches/Events/Scp330/InteractingScp330.cs

View workflow job for this annotation

GitHub Actions / build

Check failure on line 86 in EXILED/Exiled.Events/Patches/Events/Scp330/InteractingScp330.cs

View workflow job for this annotation

GitHub Actions / build

Check failure on line 86 in EXILED/Exiled.Events/Patches/Events/Scp330/InteractingScp330.cs

View workflow job for this annotation

GitHub Actions / build

Check failure on line 86 in EXILED/Exiled.Events/Patches/Events/Scp330/InteractingScp330.cs

View workflow job for this annotation

GitHub Actions / build

Check failure on line 86 in EXILED/Exiled.Events/Patches/Events/Scp330/InteractingScp330.cs

View workflow job for this annotation

GitHub Actions / build


newInstructions.InsertRange(

Check failure on line 88 in EXILED/Exiled.Events/Patches/Events/Scp330/InteractingScp330.cs

View workflow job for this annotation

GitHub Actions / build

Check failure on line 88 in EXILED/Exiled.Events/Patches/Events/Scp330/InteractingScp330.cs

View workflow job for this annotation

GitHub Actions / build

Check failure on line 88 in EXILED/Exiled.Events/Patches/Events/Scp330/InteractingScp330.cs

View workflow job for this annotation

GitHub Actions / build

Check failure on line 88 in EXILED/Exiled.Events/Patches/Events/Scp330/InteractingScp330.cs

View workflow job for this annotation

GitHub Actions / build

Check failure on line 88 in EXILED/Exiled.Events/Patches/Events/Scp330/InteractingScp330.cs

View workflow job for this annotation

GitHub Actions / build

addShouldSeverIndex,
new[]
{
Expand Down
2 changes: 1 addition & 1 deletion EXILED/Exiled.Events/Patches/Events/Server/Reporting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
LocalBuilder evReportingCheater = generator.DeclareLocal(typeof(ReportingCheaterEventArgs));

int offset = 2;
int index = newInstructions.FindLastIndex(instruction => instruction.opcode == OpCodes.Ldarg_S && instruction.operand == (object)4) + offset;
int index = newInstructions.FindLastIndex(instruction => instruction.opcode == OpCodes.Ldarg_S && instruction.operand is byte and 4) + offset;

Label ret = generator.DefineLabel();

Expand Down
72 changes: 72 additions & 0 deletions EXILED/Exiled.Events/Patches/Fixes/Fix106RegenerationWithScp244.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// -----------------------------------------------------------------------
// <copyright file="Fix106RegenerationWithScp244.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 CustomPlayerEffects;
using HarmonyLib;
using InventorySystem.Items.Usables.Scp244.Hypothermia;
using PlayerRoles;
using PlayerRoles.PlayableScps.Scp106;

using static HarmonyLib.AccessTools;

/// <summary>
/// Patches the <see cref="Hypothermia.Update()"/> delegate.
/// Fix than SCP-106 regenerates slower in SCP-244 even if they are in stalk.
/// Bug reported to NW (https://git.scpslgame.com/northwood-qa/scpsl-bug-reporting/-/issues/367).
/// </summary>
[HarmonyPatch(typeof(Hypothermia), nameof(Hypothermia.Update))]
internal class Fix106RegenerationWithScp244
{
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
{
List<CodeInstruction> newInstructions = ListPool<CodeInstruction>.Pool.Get(instructions);

LocalBuilder scp106Role = generator.DeclareLocal(typeof(Scp106Role));
Label continueLabel = generator.DefineLabel();

int offset = 1;
int index = newInstructions.FindLastIndex(x => x.operand == (object)Method(typeof(SpawnProtected), nameof(SpawnProtected.CheckPlayer))) + offset;

Label skip = (Label)newInstructions[index].operand;

index += offset;

newInstructions[index].labels.Add(continueLabel);

newInstructions.InsertRange(index, new[]
{
// Scp106Role scp106Role = base.Hub.roleManager.CurrentRole as Scp106Role;
new CodeInstruction(OpCodes.Ldarg_0),
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)),
new CodeInstruction(OpCodes.Stloc_S, scp106Role.LocalIndex),

// if (scp106Role is null) goto continueLabel
new CodeInstruction(OpCodes.Ldloc_S, scp106Role.LocalIndex),
new CodeInstruction(OpCodes.Brfalse_S, continueLabel),

// if (!scp106Role.IsSubmerged) goto skip
new CodeInstruction(OpCodes.Ldloc_S, scp106Role.LocalIndex),
new CodeInstruction(OpCodes.Callvirt, PropertyGetter(typeof(Scp106Role), nameof(Scp106Role.IsSubmerged))),
new CodeInstruction(OpCodes.Brtrue_S, skip),
});

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

ListPool<CodeInstruction>.Pool.Return(newInstructions);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace Exiled.Events.Patches.Fixes
/// <summary>
/// Patches the <see cref="Scp096HitHandler.CheckDoorHit(Collider)"/> delegate.
/// Fixes open doors getting easily broke.
/// Bug reported to NW (https://trello.com/c/6Nz7Isjm/4637-scp096-easily-breaking-opened-doors).
/// Bug reported to NW (https://git.scpslgame.com/northwood-qa/scpsl-bug-reporting/-/issues/198).
/// </summary>
[HarmonyPatch(typeof(Scp096HitHandler), nameof(Scp096HitHandler.CheckDoorHit))]
internal class NWFixScp096BreakingDoor
Expand Down
2 changes: 1 addition & 1 deletion EXILED/Exiled.Events/Patches/Fixes/Scp3114AttackAhpFix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace Exiled.Events.Patches.Fixes
/// <summary>
/// Patches the <see cref="Scp3114Slap.DamagePlayers()"/> delegate.
/// Fix than Scp3114Slap was giving humeshield even if player was not hit by Scp3114.
/// Bug reported to NW (https://trello.com/c/1AwpM8XE/5814-scp3114-is-able-to-get-humeshield-with-godmod-player).
/// Bug reported to NW (https://git.scpslgame.com/northwood-qa/scpsl-bug-reporting/-/issues/119).
/// </summary>
[HarmonyPatch(typeof(Scp3114Slap), nameof(Scp3114Slap.DamagePlayers))]
internal class Scp3114AttackAhpFix
Expand Down
124 changes: 124 additions & 0 deletions EXILED/Exiled.Events/Patches/Fixes/Scp3114FriendlyFireFix.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
// -----------------------------------------------------------------------
// <copyright file="Scp3114FriendlyFireFix.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
{
#pragma warning disable SA1402 // File may only contain a single type
using System.Collections.Generic;
using System.Reflection.Emit;

using API.Features.Pools;

using Exiled.API.Features;

using Footprinting;
using HarmonyLib;
using InventorySystem.Items.Pickups;
using InventorySystem.Items.ThrowableProjectiles;
using PlayerRoles;
using PlayerStatsSystem;

using static HarmonyLib.AccessTools;

/// <summary>
/// Patches the <see cref="Scp2176Projectile.ServerShatter()"/> delegate.
/// Fix Throwing a ghostlight with Scp in the room stun 079.
/// Bug reported to NW (https://git.scpslgame.com/northwood-qa/scpsl-bug-reporting/-/issues/55).
/// </summary>
[HarmonyPatch(typeof(Scp2176Projectile), nameof(Scp2176Projectile.ServerShatter))]
internal class Scp3114FriendlyFireFix
{
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
{
List<CodeInstruction> newInstructions = ListPool<CodeInstruction>.Pool.Get(instructions);

Label cnt = generator.DefineLabel();

int offset = 0;
int index = newInstructions.FindIndex(x => x.LoadsField(Field(typeof(RoomLightController), nameof(RoomLightController.Instances)))) + offset;

Label skip = newInstructions[index].labels[0];

offset = -3;
index += offset;

newInstructions.InsertRange(index, new[]
{
// if (this.PreviousOwner.Role.GetTeam() is Team.SCPs)
new CodeInstruction(OpCodes.Ldarg_0).MoveLabelsFrom(newInstructions[index]),
new(OpCodes.Ldfld, Field(typeof(Scp2176Projectile), nameof(Scp2176Projectile.PreviousOwner))),
new(OpCodes.Ldfld, Field(typeof(Footprint), nameof(Footprint.Role))),
new(OpCodes.Call, Method(typeof(PlayerRolesUtils), nameof(PlayerRolesUtils.GetTeam), new[] { typeof(RoleTypeId) })),
new(OpCodes.Ldc_I4_0),
new(OpCodes.Ceq),

new(OpCodes.Brfalse_S, cnt),

new(OpCodes.Pop),
new(OpCodes.Br_S, skip),

new CodeInstruction(OpCodes.Nop).WithLabels(cnt),
});

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

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

/// <summary>
/// Patches the <see cref="CollisionDetectionPickup.ProcessCollision(UnityEngine.Collision)"/> delegate.
/// Fix Throwing a ghostlight with Scp in the room stun 079.
/// Bug reported to NW (https://git.scpslgame.com/northwood-qa/scpsl-bug-reporting/-/issues/55).
/// </summary>
[HarmonyPatch(typeof(CollisionDetectionPickup), nameof(CollisionDetectionPickup.ProcessCollision))]
internal class Scp3114FriendlyFireFix2 : AttackerDamageHandler
{
#pragma warning disable SA1600 // Elements should be documented
public Scp3114FriendlyFireFix2(Footprint attacker, float damage)
{
Attacker = attacker;
Damage = damage;
AllowSelfDamage = false;
ServerLogsText = "Scp3114 Fix";
}

public override Footprint Attacker { get; set; }

public override bool AllowSelfDamage { get; }

public override float Damage { get; set; }

public override string ServerLogsText { get; }
#pragma warning restore SA1600 // Elements should be documented

private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
{
List<CodeInstruction> newInstructions = ListPool<CodeInstruction>.Pool.Get(instructions);

int offset = 0;
int index = newInstructions.FindLastIndex(x => x.opcode == OpCodes.Ldnull) + offset;

// replace null with new Scp3114FriendlyFireFix2(this.PreviousOwner, num2)
newInstructions.RemoveAt(index);
newInstructions.InsertRange(index, new CodeInstruction[]
{
// new Scp3114FriendlyFireFix2(this.PreviousOwner, num2)
new(OpCodes.Ldarg_0),
new(OpCodes.Ldfld, Field(typeof(CollisionDetectionPickup), nameof(CollisionDetectionPickup.PreviousOwner))),
new(OpCodes.Ldloc_3),
new(OpCodes.Newobj, GetDeclaredConstructors(typeof(Scp3114FriendlyFireFix2))[0]),
});

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

ListPool<CodeInstruction>.Pool.Return(newInstructions);
}
}
}
2 changes: 2 additions & 0 deletions EXILED/Exiled.Events/Patches/Fixes/SlownessFix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace Exiled.Events.Patches.Fixes

/// <summary>
/// Patches <see cref="FpcMotor.DesiredMove"/> getter to fix Slowness effect.
/// reported to NW (https://git.scpslgame.com/northwood-qa/scpsl-bug-reporting/-/issues/378).
/// </summary>
[HarmonyPatch(typeof(FpcMotor), nameof(FpcMotor.DesiredMove), MethodType.Getter)]
internal class SlownessFix
Expand All @@ -41,6 +42,7 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi

/// <summary>
/// Patches <see cref="FpcMotor.UpdatePosition"/> method to fix Slowness effect.
/// reported to NW (https://git.scpslgame.com/northwood-qa/scpsl-bug-reporting/-/issues/378).
/// </summary>
[HarmonyPatch(typeof(FpcMotor), nameof(FpcMotor.UpdatePosition))]
#pragma warning disable SA1402 // File may only contain a single type
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), new[] { typeof(string) }));
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);
}
}
}
Loading