Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions EXILED/Exiled.API/Features/Npc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ public static Npc Spawn(string name, RoleTypeId role = RoleTypeId.None, bool ign
});

if (ignored)
Round.IgnoredPlayers.Add(npc.ReferenceHub);
Round.IgnoredPlayers.Add(npc);

Dictionary.Add(npc.GameObject, npc);
return npc;
Expand Down Expand Up @@ -334,7 +334,7 @@ public void Destroy()
{
try
{
Round.IgnoredPlayers.Remove(ReferenceHub);
Round.IgnoredPlayers.Remove(this);
Dictionary.Remove(ReferenceHub.gameObject);
NetworkServer.Destroy(ReferenceHub.gameObject);
}
Expand Down
2 changes: 1 addition & 1 deletion EXILED/Exiled.API/Features/Round.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static class Round
/// <summary>
/// Gets a list of players who will be ignored from determining round end.
/// </summary>
public static HashSet<ReferenceHub> IgnoredPlayers { get; } = new(20); // TODO: Replace ReferenceHub to Player remind to change RoundEnd transpiler
public static HashSet<Player> IgnoredPlayers { get; } = new(20);

/// <summary>
/// Gets the time elapsed from the start of the round.
Expand Down
5 changes: 3 additions & 2 deletions EXILED/Exiled.Events/Patches/Events/Server/RoundEnd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,16 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi

Label jmp = generator.DefineLabel();

// if (Round.IgnoredPlayers.Contains(referencehub)
// if (Round.IgnoredPlayers.Contains(player)
// goto jmp;
newInstructions.InsertRange(
index,
new CodeInstruction[]
{
new(OpCodes.Call, PropertyGetter(typeof(Round), nameof(Round.IgnoredPlayers))),
new(OpCodes.Ldloc_S, 20),
new(OpCodes.Callvirt, Method(typeof(HashSet<ReferenceHub>), nameof(HashSet<ReferenceHub>.Contains))),
new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })),
new(OpCodes.Callvirt, Method(typeof(HashSet<Player>), nameof(HashSet<Player>.Contains))),
new(OpCodes.Brtrue_S, jmp),
});

Expand Down
7 changes: 4 additions & 3 deletions EXILED/Exiled.Events/Patches/Generic/LastTarget.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
// <copyright file="LastTarget.cs" company="ExMod Team">
// Copyright (c) ExMod Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
Expand Down Expand Up @@ -35,10 +35,11 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi

newInstructions.InsertRange(index, new CodeInstruction[]
{
// Round.IgnoredPlayers.Contains(allHub)
// Round.IgnoredPlayers.Contains(player)
new(OpCodes.Call, PropertyGetter(typeof(Round), nameof(Round.IgnoredPlayers))),
new(OpCodes.Ldloc_3),
new(OpCodes.Callvirt, Method(typeof(HashSet<ReferenceHub>), nameof(HashSet<ReferenceHub>.Contains))),
new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })),
new(OpCodes.Callvirt, Method(typeof(HashSet<Player>), nameof(HashSet<Player>.Contains))),

new(OpCodes.Brtrue_S, continueLabel),
});
Expand Down
5 changes: 3 additions & 2 deletions EXILED/Exiled.Events/Patches/Generic/RoundTargetCount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,12 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi

newInstructions.InsertRange(0, new CodeInstruction[]
{
// if (Round.IgnoredPlayers.Contains(hub))
// if (Round.IgnoredPlayers.Contains(player))
// return false;
new(OpCodes.Call, PropertyGetter(typeof(Round), nameof(Round.IgnoredPlayers))),
new(OpCodes.Ldarg_1),
new(OpCodes.Callvirt, Method(typeof(HashSet<ReferenceHub>), nameof(HashSet<ReferenceHub>.Contains))),
new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })),
new(OpCodes.Callvirt, Method(typeof(HashSet<Player>), nameof(HashSet<Player>.Contains))),
new(OpCodes.Brfalse_S, skip),

new(OpCodes.Ldc_I4_0),
Expand Down
Loading