From e459b2fcde57558578b89429296bee53aa6dc95c Mon Sep 17 00:00:00 2001 From: RaidMax Date: Thu, 2 Jun 2022 18:24:13 -0500 Subject: [PATCH] Add per game anticheat configuration option for issue #203 --- Plugins/Stats/Config/AnticheatConfiguration.cs | 5 ++++- Plugins/Stats/Helpers/StatManager.cs | 18 +++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/Plugins/Stats/Config/AnticheatConfiguration.cs b/Plugins/Stats/Config/AnticheatConfiguration.cs index f0a9de6f9..ed6b8ea76 100644 --- a/Plugins/Stats/Config/AnticheatConfiguration.cs +++ b/Plugins/Stats/Config/AnticheatConfiguration.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using static IW4MAdmin.Plugins.Stats.Cheat.Detection; using static SharedLibraryCore.Server; @@ -7,7 +8,9 @@ namespace Stats.Config public class AnticheatConfiguration { public bool Enable { get; set; } + [Obsolete] public IDictionary ServerDetectionTypes { get; set; } = new Dictionary(); + public IDictionary GameDetectionTypes { get; set; } = new Dictionary(); public IList IgnoredClientIds { get; set; } = new List(); public IDictionary> IgnoredDetectionSpecification{ get; set; } = new Dictionary> { diff --git a/Plugins/Stats/Helpers/StatManager.cs b/Plugins/Stats/Helpers/StatManager.cs index b77413fba..36a1bfe50 100644 --- a/Plugins/Stats/Helpers/StatManager.cs +++ b/Plugins/Stats/Helpers/StatManager.cs @@ -818,7 +818,8 @@ namespace IW4MAdmin.Plugins.Stats.Helpers private bool ShouldUseDetection(Server server, DetectionType detectionType, long clientId) { - var detectionTypes = Plugin.Config.Configuration().AnticheatConfiguration.ServerDetectionTypes; + var serverDetectionTypes = Plugin.Config.Configuration().AnticheatConfiguration.ServerDetectionTypes; + var gameDetectionTypes = Plugin.Config.Configuration().AnticheatConfiguration.GameDetectionTypes; var ignoredClients = Plugin.Config.Configuration().AnticheatConfiguration.IgnoredClientIds; if (ignoredClients.Contains(clientId)) @@ -826,10 +827,9 @@ namespace IW4MAdmin.Plugins.Stats.Helpers return false; } - try { - if (!detectionTypes[server.EndPoint].Contains(detectionType)) + if (!serverDetectionTypes[server.EndPoint].Contains(detectionType)) { return false; } @@ -838,6 +838,18 @@ namespace IW4MAdmin.Plugins.Stats.Helpers catch (KeyNotFoundException) { } + + try + { + if (!gameDetectionTypes[server.GameName].Contains(detectionType)) + { + return false; + } + } + catch + { + // ignored + } return true; }