diff --git a/Application/Application.csproj b/Application/Application.csproj index 8226d692e..d21014ece 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 @@ -34,8 +34,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 0822905e3..9dc9547fb 100644 --- a/Plugins/Stats/Helpers/StatManager.cs +++ b/Plugins/Stats/Helpers/StatManager.cs @@ -431,21 +431,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,15 +555,21 @@ namespace IW4MAdmin.Plugins.Stats.Helpers await SaveClientStats(clientStats); } + if (hit.IsKillstreakKill) + { + return; + } + try { 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(); + } } }