2
0
mirror of https://github.com/9ParsonsB/Pulsar.git synced 2025-04-05 17:39:39 -04:00

[ObservatoryCore] Add Statistics and OnFoot CarrierJumps to preread data (#129)

CarrierJump w/ OnFoot is needed for many location tracking things -- ATTN MattG as this is causing problems with BioInsights.

I'm requesting Statistics for use by StatsScanner.
This commit is contained in:
F K 2024-01-23 19:36:57 -05:00 committed by Xjph
parent 100d5e290a
commit 64d7b0e072

View File

@ -131,7 +131,7 @@ namespace Observatory.Utils
// journal is mostly empty) but keeping only the lines since the last FSDJump. // journal is mostly empty) but keeping only the lines since the last FSDJump.
List<string> lastSystemLines = new(); List<string> lastSystemLines = new();
List<string> lastFileLines = new(); List<string> lastFileLines = new();
string lastLoadGame = string.Empty; List<String> fileHeaderLines = new();
bool sawFSDJump = false; bool sawFSDJump = false;
foreach (var file in files.Skip(Math.Max(files.Count() - 2, 0))) foreach (var file in files.Skip(Math.Max(files.Count() - 2, 0)))
{ {
@ -139,7 +139,7 @@ namespace Observatory.Utils
foreach (var line in lines) foreach (var line in lines)
{ {
var eventType = JournalUtilities.GetEventType(line); var eventType = JournalUtilities.GetEventType(line);
if (eventType.Equals("FSDJump") || eventType.Equals("CarrierJump") && line.Contains("\"Docked\":true")) if (eventType.Equals("FSDJump") || (eventType.Equals("CarrierJump") && (line.Contains("\"Docked\":true") || line.Contains("\"OnFoot\":true"))))
{ {
// Reset, start collecting again. // Reset, start collecting again.
lastSystemLines.Clear(); lastSystemLines.Clear();
@ -148,10 +148,13 @@ namespace Observatory.Utils
else if (eventType.Equals("Fileheader")) else if (eventType.Equals("Fileheader"))
{ {
lastFileLines.Clear(); lastFileLines.Clear();
fileHeaderLines.Clear();
fileHeaderLines.Add(line);
} }
else if (eventType.Equals("LoadGame")) else if (eventType.Equals("LoadGame") || eventType.Equals("Statistics"))
{ {
lastLoadGame = line; // A few header lines to collect.
fileHeaderLines.Add(line);
} }
lastSystemLines.Add(line); lastSystemLines.Add(line);
lastFileLines.Add(line); lastFileLines.Add(line);
@ -166,11 +169,11 @@ namespace Observatory.Utils
List<string> linesToRead = lastFileLines; List<string> linesToRead = lastFileLines;
if (sawFSDJump) if (sawFSDJump)
{ {
// If we saw a LoadGame, insert it as well. This ensures odyssey biologicials are properly // If we saw any relevant header lines, insert them as well. This ensures odyssey biologicials are properly
// counted/presented. // counted/presented, current Commander name is present, etc.
if (!string.IsNullOrEmpty(lastLoadGame)) if (fileHeaderLines.Count > 0)
{ {
lastSystemLines.Insert(0, lastLoadGame); lastSystemLines.InsertRange(0, fileHeaderLines);
} }
linesToRead = lastSystemLines; linesToRead = lastSystemLines;
} }