Skip to content

Commit be3e78a

Browse files
authored
Use [ReloadOrRestart] to detect game reloads, instead of frame number. #2982 from Mankarse/InfologParse2
2 parents 690f506 + b5d02d5 commit be3e78a

1 file changed

Lines changed: 11 additions & 23 deletions

File tree

ChobbyLauncher/CrashReportHelper.cs

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -209,32 +209,20 @@ private static async Task<Issue> ReportCrash(string infolog, CrashType type, str
209209

210210
private static int[] ReadGameReloads(string logStr)
211211
{
212-
//Game reload detected by [f=-000001] that follows either the start of the file, or [f={non-negative value}]
213-
214-
var list = new List<int>();
215-
216-
var negativeFrameRegex = new Regex(@"f=-(?<=(?<s>^)\[t=\d+:\d+:\d+\.\d+\]\[f=-)\d+\]", RegexOptions.CultureInvariant | RegexOptions.Compiled | RegexOptions.ExplicitCapture | RegexOptions.Multiline, TimeSpan.FromSeconds(30));
217-
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));
218-
219-
var idx = 0;
212+
//[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
213+
//This happens whenever a new game is started, or when a game is exited and returns to lobby.
220214

221215
try
222216
{
223-
while (true)
224-
{
225-
{
226-
var m = negativeFrameRegex.Match(logStr, idx);
227-
if (!m.Success) break;
228-
idx = m.Index;
229-
list.Add(m.Groups["s"].Index);
230-
}
231-
{
232-
var m = nonNegativeFrameRegex.Match(logStr, idx);
233-
if (!m.Success) break;
234-
idx = m.Index;
235-
}
236-
}
237-
return list.ToArray();
217+
return
218+
Regex
219+
.Matches(
220+
logStr,
221+
@"\[ReloadOrRestart\](?<=(?<s>^)\[t=\d+:\d+:\d+\.\d+\]\[f=-?\d+\] \[ReloadOrRestart\])",
222+
RegexOptions.CultureInvariant | RegexOptions.Compiled | RegexOptions.ExplicitCapture | RegexOptions.Multiline,
223+
TimeSpan.FromSeconds(30))
224+
.Cast<Match>().Select(m => m.Groups["s"].Index)
225+
.ToArray();
238226
}
239227
catch (RegexMatchTimeoutException)
240228
{

0 commit comments

Comments
 (0)