Skip to content
This repository was archived by the owner on Sep 22, 2021. It is now read-only.

Commit c12451b

Browse files
committed
HeaderCorrupted event added
1 parent 2cca542 commit c12451b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

DemoInfo/DemoParser.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ public class DemoParser : IDisposable
3434
/// </summary>
3535
public event EventHandler<HeaderParsedEventArgs> HeaderParsed;
3636

37+
/// <summary>
38+
/// Raised when header data is corrupted and timings are zero and null.
39+
/// </summary>
40+
public event EventHandler<HeaderParsedEventArgs> HeaderCorrupted;
41+
3742
/// <summary>
3843
/// Occurs when the match started, so when the "begin_new_match"-GameEvent is dropped.
3944
/// This usually right before the freezetime of the 1st round. Be careful, since the players
@@ -531,6 +536,15 @@ public void ParseHeader()
531536

532537
Header = header;
533538

539+
if (header.PlaybackTime == 0)
540+
{
541+
Console.WriteLine("WARNING: The header for this demo file is corrupted. TickRate, TickTime, ParsingProgress, CurrentTime will be 0 for the first 50 ticks. PlaybackFrames, PlaybackTicks, PlaybackTime will always be 0. HeaderCorrupted event triggered.");
542+
543+
if (HeaderCorrupted != null)
544+
{
545+
HeaderCorrupted(this, new HeaderParsedEventArgs(Header));
546+
}
547+
}
534548

535549
if (HeaderParsed != null)
536550
HeaderParsed(this, new HeaderParsedEventArgs(Header));
@@ -1467,6 +1481,7 @@ public void Dispose ()
14671481
this.FireNadeWithOwnerStarted = null;
14681482
this.FlashNadeExploded = null;
14691483
this.HeaderParsed = null;
1484+
this.HeaderCorrupted = null;
14701485
this.MatchStarted = null;
14711486
this.NadeReachedTarget = null;
14721487
this.PlayerKilled = null;

0 commit comments

Comments
 (0)