Skip to content

Commit

Permalink
Use [ReloadOrRestart] to detect game reloads, instead of frame number.
Browse files Browse the repository at this point in the history
…#2982 from Mankarse/InfologParse2
  • Loading branch information
Licho1 authored Apr 19, 2024
2 parents 690f506 + b5d02d5 commit be3e78a
Showing 1 changed file with 11 additions and 23 deletions.
34 changes: 11 additions & 23 deletions ChobbyLauncher/CrashReportHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,32 +209,20 @@ private static async Task<Issue> ReportCrash(string infolog, CrashType type, str

private static int[] ReadGameReloads(string logStr)
{
//Game reload detected by [f=-000001] that follows either the start of the file, or [f={non-negative value}]

var list = new List<int>();

var negativeFrameRegex = new Regex(@"f=-(?<=(?<s>^)\[t=\d+:\d+:\d+\.\d+\]\[f=-)\d+\]", RegexOptions.CultureInvariant | RegexOptions.Compiled | RegexOptions.ExplicitCapture | RegexOptions.Multiline, TimeSpan.FromSeconds(30));
var nonNegativeFrameRegex = new Regex(@"f=\d(?<=^\[t=\d+:\d+:\d+\.\d+\]\[f=\d)\d*\]", RegexOptions.CultureInvariant | RegexOptions.Compiled | RegexOptions.ExplicitCapture | RegexOptions.Multiline, TimeSpan.FromSeconds(30));

var idx = 0;
//[t=00:00:30.569367][f=-000001] [ReloadOrRestart] Spring "E:\Games\SteamLibrary\steamapps\common\Zero-K\engine\win64\105.1.1-2457-g8095d30\spring.exe" should be reloading
//This happens whenever a new game is started, or when a game is exited and returns to lobby.

try
{
while (true)
{
{
var m = negativeFrameRegex.Match(logStr, idx);
if (!m.Success) break;
idx = m.Index;
list.Add(m.Groups["s"].Index);
}
{
var m = nonNegativeFrameRegex.Match(logStr, idx);
if (!m.Success) break;
idx = m.Index;
}
}
return list.ToArray();
return
Regex
.Matches(
logStr,
@"\[ReloadOrRestart\](?<=(?<s>^)\[t=\d+:\d+:\d+\.\d+\]\[f=-?\d+\] \[ReloadOrRestart\])",
RegexOptions.CultureInvariant | RegexOptions.Compiled | RegexOptions.ExplicitCapture | RegexOptions.Multiline,
TimeSpan.FromSeconds(30))
.Cast<Match>().Select(m => m.Groups["s"].Index)
.ToArray();
}
catch (RegexMatchTimeoutException)
{
Expand Down

0 comments on commit be3e78a

Please sign in to comment.