From e669d0be82e6290e58f02ffde6655946a9118049 Mon Sep 17 00:00:00 2001 From: RaidMax Date: Sun, 16 Jun 2019 12:19:23 -0500 Subject: [PATCH] don't count bots on master list don't save every ac snapshot oops.. --- Plugins/Stats/Cheat/Detection.cs | 23 +++++++++++++---------- Plugins/Stats/Helpers/StatManager.cs | 9 ++++++--- SharedLibraryCore/Server.cs | 2 +- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/Plugins/Stats/Cheat/Detection.cs b/Plugins/Stats/Cheat/Detection.cs index 0b3984832..4d5817666 100644 --- a/Plugins/Stats/Cheat/Detection.cs +++ b/Plugins/Stats/Cheat/Detection.cs @@ -371,7 +371,7 @@ namespace IW4MAdmin.Plugins.Stats.Cheat if (currentChestAbdomenRatio > chestAbdomenRatioLerpValueForFlag) { - if (currentChestAbdomenRatio > chestAbdomenLerpValueForBan && chestHits >= Thresholds.MediumSampleMinKills + 30) + if (currentChestAbdomenRatio > chestAbdomenLerpValueForBan && chestHits >= Thresholds.MediumSampleMinKills * 2) { //Log.WriteDebug("**Maximum Chest/Abdomen Ratio Reached For Ban**"); //Log.WriteDebug($"ClientId: {hit.AttackerId}"); @@ -459,8 +459,9 @@ namespace IW4MAdmin.Plugins.Stats.Cheat public DetectionPenaltyResult ProcessTotalRatio(EFClientStatistics stats) { int totalChestHits = stats.HitLocations.Single(c => c.Location == IW4Info.HitLocation.torso_upper).HitCount; + var results = new List(); - if (totalChestHits >= 60) + if (totalChestHits >= Thresholds.MediumSampleMinKills * 2) { double marginOfError = Thresholds.GetMarginOfError(totalChestHits); double lerpAmount = Math.Min(1.0, (totalChestHits - 60) / 250.0); @@ -486,14 +487,14 @@ namespace IW4MAdmin.Plugins.Stats.Cheat // sb.Append($"HitLocation: {location.Location} -> {location.HitCount}\r\n"); //Log.WriteDebug(sb.ToString()); - return new DetectionPenaltyResult() + results.Add(new DetectionPenaltyResult() { ClientPenalty = EFPenalty.PenaltyType.Ban, Value = currentChestAbdomenRatio, Location = IW4Info.HitLocation.torso_upper, HitCount = totalChestHits, Type = DetectionType.Chest - }; + }); } else { @@ -507,22 +508,24 @@ namespace IW4MAdmin.Plugins.Stats.Cheat // sb.Append($"HitLocation: {location.Location} -> {location.HitCount}\r\n"); //Log.WriteDebug(sb.ToString()); - return new DetectionPenaltyResult() + results.Add(new DetectionPenaltyResult() { ClientPenalty = EFPenalty.PenaltyType.Flag, Value = currentChestAbdomenRatio, Location = IW4Info.HitLocation.torso_upper, HitCount = totalChestHits, Type = DetectionType.Chest - }; + }); } } } - return new DetectionPenaltyResult() - { - ClientPenalty = EFPenalty.PenaltyType.Any - }; + return results.FirstOrDefault(_result => _result.ClientPenalty == EFPenalty.PenaltyType.Ban) ?? + results.FirstOrDefault(_result => _result.ClientPenalty == EFPenalty.PenaltyType.Flag) ?? + new DetectionPenaltyResult() + { + ClientPenalty = EFPenalty.PenaltyType.Any, + }; } } } diff --git a/Plugins/Stats/Helpers/StatManager.cs b/Plugins/Stats/Helpers/StatManager.cs index 21f0aa90d..c7ac7f450 100644 --- a/Plugins/Stats/Helpers/StatManager.cs +++ b/Plugins/Stats/Helpers/StatManager.cs @@ -569,6 +569,7 @@ namespace IW4MAdmin.Plugins.Stats.Helpers if (Plugin.Config.Configuration().EnableAntiCheat && !attacker.IsBot && attacker.ClientId != victim.ClientId) { + DetectionPenaltyResult result = new DetectionPenaltyResult() { ClientPenalty = EFPenalty.PenaltyType.Any }; #if DEBUG if (clientDetection.QueuedHits.Count > 0) #else @@ -580,10 +581,12 @@ namespace IW4MAdmin.Plugins.Stats.Helpers clientDetection.QueuedHits = clientDetection.QueuedHits.OrderBy(_hits => _hits.TimeOffset).ToList(); var oldestHit = clientDetection.QueuedHits.First(); clientDetection.QueuedHits.RemoveAt(0); - await ApplyPenalty(clientDetection.ProcessHit(oldestHit, isDamage), attacker, ctx); + result = clientDetection.ProcessHit(oldestHit, isDamage); + await ApplyPenalty(result, attacker, ctx); } - await ApplyPenalty(clientDetection.ProcessTotalRatio(clientStats), attacker, ctx); + result = clientDetection.ProcessTotalRatio(clientStats); + await ApplyPenalty(result , attacker, ctx); } else @@ -591,7 +594,7 @@ namespace IW4MAdmin.Plugins.Stats.Helpers clientDetection.QueuedHits.Add(hit); } - if (clientDetection.Tracker.HasChanges) + if (clientDetection.Tracker.HasChanges && result.ClientPenalty != EFPenalty.PenaltyType.Any) { SaveTrackedSnapshots(clientDetection, ctx); } diff --git a/SharedLibraryCore/Server.cs b/SharedLibraryCore/Server.cs index 0c23ecb69..09b995194 100644 --- a/SharedLibraryCore/Server.cs +++ b/SharedLibraryCore/Server.cs @@ -295,7 +295,7 @@ namespace SharedLibraryCore { get { - return Clients.Where(p => p != null).Count(); + return Clients.Where(p => p != null && !p.IsBot).Count(); } } public int MaxClients { get; protected set; }