Skip to content

Commit ee7d4d2

Browse files
authored
Refactor eventLines handling in LogParser
Reset eventLines to defaults to prevent accumulation across gaming sessions and updated handling of custom filters.
1 parent 9fde848 commit ee7d4d2

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

Classes/LogParser.cs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,22 @@ public string ParseLog(Stream inputStream, Settings _run_settings)
3636
}
3737
else if (_run_settings.EventText && _run_settings.FilterLines != "")
3838
{
39-
List<String> eventLinesTemp = new List<String>();
39+
// Reset to defaults to prevent accumulation across gaming sessions
40+
eventLines = new List<string>(defaultEventLines);
4041
foreach (string theEvent in filterLinesArray)
4142
{
42-
eventLinesTemp.Add(theEvent);
43+
string trimmedEvent = theEvent.Trim();
44+
// Add custom filter if not already in the list
45+
if (!eventLines.Contains(trimmedEvent))
46+
{
47+
eventLines.Add(trimmedEvent);
48+
}
4349
}
44-
eventLines.AddRange(eventLinesTemp);
50+
}
51+
else if (_run_settings.EventText)
52+
{
53+
// No custom filters, just use defaults
54+
eventLines = new List<string>(defaultEventLines);
4555
}
4656

4757
string text;
@@ -359,7 +369,8 @@ private List<Tuple<Regex, string>> formatReplacesWithUserOverride(Settings _run_
359369
"[CHAT WINDOW TEXT] ",
360370
};
361371

362-
private List<string> eventLines = new List<string>
372+
// Default event lines to filter out - stored as readonly to prevent accumulation
373+
private static readonly List<string> defaultEventLines = new List<string>
363374
{
364375
"[Event]",
365376
"[Server]",
@@ -403,6 +414,9 @@ private List<Tuple<Regex, string>> formatReplacesWithUserOverride(Settings _run_
403414
"Your public CDKEY is ",
404415
};
405416

417+
// Working copy of event lines - reset each time ParseLog is called
418+
private List<string> eventLines = new List<string>();
419+
406420
private static string lineStartMatch = @"(?<=\n|^)";
407421
private static string lineChatStartMatch = @"\[CHAT\sWINDOW\sTEXT\]\s";
408422
private static string timestampMatch = @"^.+?(?=.*)";

0 commit comments

Comments
 (0)