From 1c66ac9117bc17135fb57179b2931c97fe483a98 Mon Sep 17 00:00:00 2001 From: RaidMax Date: Thu, 1 Aug 2019 19:42:44 -0500 Subject: [PATCH] fix issue with log reader fix issue with searching names on webfront that could be parsed to hex --- Application/IO/GameLogEventDetection.cs | 6 +++--- Application/IO/GameLogReader.cs | 2 +- Plugins/Stats/Plugin.cs | 4 ++++ SharedLibraryCore/Services/ClientService.cs | 11 ++--------- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/Application/IO/GameLogEventDetection.cs b/Application/IO/GameLogEventDetection.cs index c869f57dc..e1e70884c 100644 --- a/Application/IO/GameLogEventDetection.cs +++ b/Application/IO/GameLogEventDetection.cs @@ -55,7 +55,9 @@ namespace IW4MAdmin.Application.IO long fileSize = _reader.Length; if (previousFileSize == 0) + { previousFileSize = fileSize; + } long fileDiff = fileSize - previousFileSize; @@ -63,9 +65,7 @@ namespace IW4MAdmin.Application.IO if (fileDiff < 1 && fileSize != -1) return; - previousFileSize = fileSize; - - var events = await _reader.ReadEventsFromLog(_server, fileDiff, fileSize - fileDiff); + var events = await _reader.ReadEventsFromLog(_server, fileDiff, previousFileSize); foreach (var ev in events) { diff --git a/Application/IO/GameLogReader.cs b/Application/IO/GameLogReader.cs index a26fd154f..247a6804e 100644 --- a/Application/IO/GameLogReader.cs +++ b/Application/IO/GameLogReader.cs @@ -39,7 +39,7 @@ namespace IW4MAdmin.Application.IO using (var rd = new StreamReader(new FileStream(LogFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite), Utilities.EncodingType)) { char[] buff = new char[fileSizeDiff]; - rd.BaseStream.Seek(-fileSizeDiff, SeekOrigin.End); + rd.BaseStream.Seek(startPosition, SeekOrigin.Begin); await rd.ReadAsync(buff, 0, (int)fileSizeDiff); var stringBuilder = new StringBuilder(); diff --git a/Plugins/Stats/Plugin.cs b/Plugins/Stats/Plugin.cs index c44652e08..897dd2d79 100644 --- a/Plugins/Stats/Plugin.cs +++ b/Plugins/Stats/Plugin.cs @@ -100,6 +100,10 @@ namespace IW4MAdmin.Plugins.Stats await Manager.AddStandardKill(E.Origin, E.Target); } + else + { + throw new Exception(); + } break; case GameEvent.EventType.Damage: if (!E.Owner.CustomCallback && !ShouldIgnoreEvent(E.Origin, E.Target)) diff --git a/SharedLibraryCore/Services/ClientService.cs b/SharedLibraryCore/Services/ClientService.cs index 2a739bba4..8bdaeaaf7 100644 --- a/SharedLibraryCore/Services/ClientService.cs +++ b/SharedLibraryCore/Services/ClientService.cs @@ -489,15 +489,8 @@ namespace SharedLibraryCore.Services var iqClients = context.Clients .Where(_client => _client.Active); - if (networkId.HasValue) - { - iqClients = iqClients.Where(_client => networkId.Value == _client.NetworkId); - } - - else - { - iqClients = iqClients.Where(_client => linkIds.Contains(_client.AliasLinkId)); - } + + iqClients = iqClients.Where(_client => networkId == _client.NetworkId || linkIds.Contains(_client.AliasLinkId)); // we want to project our results var iqClientProjection = iqClients.OrderByDescending(_client => _client.LastConnection)