From 67c2406325bb4bd98d953ef95e6872cc10833937 Mon Sep 17 00:00:00 2001 From: RaidMax Date: Mon, 12 Jul 2021 14:57:44 -0500 Subject: [PATCH] fix issues with last release --- Application/ApplicationManager.cs | 6 +++++- Plugins/Stats/Client/HitCalculator.cs | 4 ++-- Plugins/Stats/Client/HitInfoBuilder.cs | 18 ++++++++++++++---- WebfrontCore/Startup.cs | 1 + 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/Application/ApplicationManager.cs b/Application/ApplicationManager.cs index d1e14029c..596f3ef00 100644 --- a/Application/ApplicationManager.cs +++ b/Application/ApplicationManager.cs @@ -259,7 +259,11 @@ namespace IW4MAdmin.Application { try { - await server.ProcessUpdatesAsync(_tokenSource.Token).WithWaitCancellation(runningUpdateTasks[server.EndPoint].tokenSource.Token); + if (runningUpdateTasks.ContainsKey(server.EndPoint)) + { + await server.ProcessUpdatesAsync(_tokenSource.Token) + .WithWaitCancellation(runningUpdateTasks[server.EndPoint].tokenSource.Token); + } } catch (Exception e) diff --git a/Plugins/Stats/Client/HitCalculator.cs b/Plugins/Stats/Client/HitCalculator.cs index ccce225ac..f70f50f74 100644 --- a/Plugins/Stats/Client/HitCalculator.cs +++ b/Plugins/Stats/Client/HitCalculator.cs @@ -170,9 +170,9 @@ namespace IW4MAdmin.Plugins.Stats.Client return; } - var attackerHitInfo = _hitInfoBuilder.Build(match.Values.Where(m => m.Length > 0).ToArray(), eventRegex, gameEvent.Origin.ClientId, + var attackerHitInfo = _hitInfoBuilder.Build(match.Values.ToArray(), eventRegex, gameEvent.Origin.ClientId, gameEvent.Origin.ClientId == gameEvent.Target.ClientId, false, gameEvent.Owner.GameName); - var victimHitInfo = _hitInfoBuilder.Build(match.Values.Where(m => m.Length > 0).ToArray(), eventRegex, gameEvent.Target.ClientId, + var victimHitInfo = _hitInfoBuilder.Build(match.Values.ToArray(), eventRegex, gameEvent.Target.ClientId, gameEvent.Origin.ClientId == gameEvent.Target.ClientId, true, gameEvent.Owner.GameName); foreach (var hitInfo in new[] {attackerHitInfo, victimHitInfo}) diff --git a/Plugins/Stats/Client/HitInfoBuilder.cs b/Plugins/Stats/Client/HitInfoBuilder.cs index 84d95f38f..147b1f419 100644 --- a/Plugins/Stats/Client/HitInfoBuilder.cs +++ b/Plugins/Stats/Client/HitInfoBuilder.cs @@ -47,15 +47,25 @@ namespace Stats.Client hitType = eventType == 'D' ? HitType.Damage : HitType.Kill; } + var damage = 0; + try + { + damage = Math.Min(MaximumDamage, + log.Length > parserRegex.GroupMapping[ParserRegex.GroupType.Damage] + ? int.Parse(log[parserRegex.GroupMapping[ParserRegex.GroupType.Damage]]) + : 0); + } + catch + { + // ignored + } + var hitInfo = new HitInfo() { EntityId = entityId, IsVictim = isVictim, HitType = hitType, - Damage = Math.Min(MaximumDamage, - log.Length > parserRegex.GroupMapping[ParserRegex.GroupType.Damage] - ? int.Parse(log[parserRegex.GroupMapping[ParserRegex.GroupType.Damage]]) - : 0), + Damage = damage, Location = log.Length > parserRegex.GroupMapping[ParserRegex.GroupType.HitLocation] ? log[parserRegex.GroupMapping[ParserRegex.GroupType.HitLocation]] : "Unknown", diff --git a/WebfrontCore/Startup.cs b/WebfrontCore/Startup.cs index f578bfbb9..d86649b27 100644 --- a/WebfrontCore/Startup.cs +++ b/WebfrontCore/Startup.cs @@ -113,6 +113,7 @@ namespace WebfrontCore services.AddSingleton, AdvancedClientStatsResourceQueryHelper>(); services.AddSingleton(typeof(IDataValueCache<,>), typeof(DataValueCache<,>)); // todo: this needs to be handled more gracefully + services.AddSingleton(Program.ApplicationServiceProvider.GetRequiredService()); services.AddSingleton(Program.ApplicationServiceProvider.GetRequiredService()); services.AddSingleton(Program.ApplicationServiceProvider.GetService()); services.AddSingleton(Program.ApplicationServiceProvider.GetService());