From a82092958245be0bf9c6e04182bd0d3fd5682731 Mon Sep 17 00:00:00 2001 From: RaidMax Date: Sat, 24 Aug 2019 14:06:23 -0500 Subject: [PATCH 1/2] another fix because I'm retarded bump version up --- Application/Application.csproj | 6 +++--- Application/IO/GameLogEventDetection.cs | 2 ++ Plugins/Stats/Helpers/StatManager.cs | 10 ++++++++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Application/Application.csproj b/Application/Application.csproj index d2d3f06e1..e172bbf80 100644 --- a/Application/Application.csproj +++ b/Application/Application.csproj @@ -6,7 +6,7 @@ 2.2.2 false RaidMax.IW4MAdmin.Application - 2.2.8.1 + 2.2.8.2 RaidMax Forever None IW4MAdmin @@ -33,8 +33,8 @@ false true true - 2.2.8.1 - 2.2.8.1 + 2.2.8.2 + 2.2.8.2 7.1 diff --git a/Application/IO/GameLogEventDetection.cs b/Application/IO/GameLogEventDetection.cs index 70c14df8e..3b89ccfb6 100644 --- a/Application/IO/GameLogEventDetection.cs +++ b/Application/IO/GameLogEventDetection.cs @@ -48,6 +48,8 @@ namespace IW4MAdmin.Application.IO await Task.Delay(_reader.UpdateInterval, _server.Manager.CancellationToken); } + + _server.Logger.WriteDebug("Stopped polling for changes"); } private async Task UpdateLogEvents() diff --git a/Plugins/Stats/Helpers/StatManager.cs b/Plugins/Stats/Helpers/StatManager.cs index bba171c1b..f27269a9e 100644 --- a/Plugins/Stats/Helpers/StatManager.cs +++ b/Plugins/Stats/Helpers/StatManager.cs @@ -564,11 +564,12 @@ namespace IW4MAdmin.Plugins.Stats.Helpers { if (Plugin.Config.Configuration().StoreClientKills) { + OnProcessingPenalty.Wait(); _hitCache.Add(hit); if (_hitCache.Count > Detection.MAX_TRACKED_HIT_COUNT) { - OnProcessingPenalty.Wait(); + using (var ctx = new DatabaseContext()) { ctx.AddRange(_hitCache); @@ -576,8 +577,8 @@ namespace IW4MAdmin.Plugins.Stats.Helpers } _hitCache.Clear(); - OnProcessingPenalty.Release(); } + OnProcessingPenalty.Release(1); } @@ -630,6 +631,11 @@ namespace IW4MAdmin.Plugins.Stats.Helpers { _log.WriteError("Could not save hit or AC info"); _log.WriteDebug(ex.GetExceptionInfo()); + + if (OnProcessingPenalty.CurrentCount == 0) + { + OnProcessingPenalty.Release(); + } } } From 11d2df1fe8bed8463e7472a4eeda1902f577b7ab Mon Sep 17 00:00:00 2001 From: RaidMax Date: Sat, 24 Aug 2019 20:15:50 -0500 Subject: [PATCH 2/2] small stat changes --- Plugins/Stats/Helpers/StatManager.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Plugins/Stats/Helpers/StatManager.cs b/Plugins/Stats/Helpers/StatManager.cs index f27269a9e..d39cc0dfc 100644 --- a/Plugins/Stats/Helpers/StatManager.cs +++ b/Plugins/Stats/Helpers/StatManager.cs @@ -430,21 +430,21 @@ namespace IW4MAdmin.Plugins.Stats.Helpers // get individual client's stats var clientStats = playerStats[pl.ClientId]; - // remove the client from the stats dictionary as they're leaving - playerStats.TryRemove(pl.ClientId, out _); - detectionStats.TryRemove(pl.ClientId, out _); - // sync their stats before they leave clientStats = UpdateStats(clientStats); await SaveClientStats(clientStats); + // remove the client from the stats dictionary as they're leaving + playerStats.TryRemove(pl.ClientId, out _); + detectionStats.TryRemove(pl.ClientId, out _); + // increment the total play time serverStats.TotalPlayTime += pl.ConnectionLength; } private static async Task SaveClientStats(EFClientStatistics clientStats) { - using (var ctx = new DatabaseContext(disableTracking: true)) + using (var ctx = new DatabaseContext()) { ctx.Update(clientStats); await ctx.SaveChangesAsync(); @@ -533,11 +533,6 @@ namespace IW4MAdmin.Plugins.Stats.Helpers await AddStandardKill(attacker, victim); } - if (hit.IsKillstreakKill) - { - return; - } - // incase the add player event get delayed if (!_servers[serverId].PlayerStats.ContainsKey(attacker.ClientId)) { @@ -560,6 +555,11 @@ namespace IW4MAdmin.Plugins.Stats.Helpers await SaveClientStats(clientStats); } + if (hit.IsKillstreakKill) + { + return; + } + try { if (Plugin.Config.Configuration().StoreClientKills)