Skip to content

Commit

Permalink
fix: ArgumentOutOfRangeException when calling GetArgTargetResult (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
qstage authored Jan 23, 2025
1 parent 0f71e1a commit 2c06407
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class Target
private static bool ConstTargetType(string target, out TargetType targetType)
{
targetType = TargetType.Invalid;
if (!target.StartsWith("@"))
if (!target.StartsWith('@'))
{
return false;
}
Expand All @@ -50,13 +50,13 @@ private bool IdTargetType(string target,
{
targetType = TargetType.Invalid;
slug = null!;
if (!target.StartsWith("#"))
if (!target.StartsWith('#'))
{
return false;
}

slug = target.TrimStart('#');
if (slug.StartsWith("STEAM")) targetType = TargetType.IdSteamEscaped;
if (slug.StartsWith("STEAM") && slug.Contains(':')) targetType = TargetType.IdSteamEscaped;
else if (!ulong.TryParse(slug, out _)) targetType = TargetType.ExplicitName;
else if (slug.Length == 17) targetType = TargetType.IdSteam64;
else targetType = TargetType.IdUserid;
Expand Down Expand Up @@ -101,10 +101,9 @@ private bool TargetPredicate(CCSPlayerController player, CCSPlayerController? ca
TargetType.GroupNotMe => player.SteamID != caller?.SteamID,
TargetType.PlayerMe => player.SteamID == caller?.SteamID,
TargetType.IdUserid => player.UserId.ToString() == Slug,
TargetType.IdSteamEscaped => ((SteamID)player.SteamID).SteamId2 == Slug,
TargetType.IdSteam64 => ((SteamID)player.SteamID).SteamId64.ToString() == Slug,
TargetType.ExplicitName => player.PlayerName.Contains(Slug, StringComparison.OrdinalIgnoreCase),
TargetType.ImplicitName => player.PlayerName.Contains(Slug, StringComparison.OrdinalIgnoreCase),
TargetType.IdSteamEscaped when player.SteamID != 0 => (SteamID)player.SteamID == (SteamID)Slug,
TargetType.IdSteam64 => player.SteamID.ToString() == Slug,
TargetType.ExplicitName or TargetType.ImplicitName => player.PlayerName.Contains(Slug, StringComparison.OrdinalIgnoreCase),
_ => false
};
}
Expand Down

0 comments on commit 2c06407

Please sign in to comment.