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

Commit 634ea21

Browse files
committed
TimeFixed event added
1 parent d3bd3ac commit 634ea21

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

DemoInfo/DemoParser.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ public class DemoParser : IDisposable
3939
/// </summary>
4040
public event EventHandler<HeaderParsedEventArgs> HeaderCorrupted;
4141

42+
/// <summary>
43+
/// Raised when the time variables have been fixed for a demo with a corrupted header
44+
/// </summary>
45+
public event EventHandler<TimeFixedEventArgs> TimeFixed;
46+
4247
/// <summary>
4348
/// Occurs when the match started, so when the "begin_new_match"-GameEvent is dropped.
4449
/// This usually right before the freezetime of the 1st round. Be careful, since the players
@@ -533,12 +538,13 @@ public void ParseHeader()
533538

534539
if (IsHeaderCorrupted)
535540
{
536-
Console.WriteLine("WARNING: The header for this demo file is corrupted. TickRate, TickTime, CurrentTime will be 0 for ticks at the start of the demo. ParsingProgress, PlaybackFrames, PlaybackTicks, PlaybackTime will always be 0. HeaderCorrupted event triggered.");
541+
Console.WriteLine("WARNING: The header for this demo file is corrupted. TickRate, TickTime, CurrentTime will be 0 for ticks at the start of the demo. ParsingProgress, PlaybackFrames, PlaybackTicks, PlaybackTime will always be 0.");
542+
Console.WriteLine("HeaderCorrupted event raised, TimeFixed event will be raised when time variables are repaired.");
537543

538544
if (HeaderCorrupted != null)
539545
{
540546
HeaderCorrupted(this, new HeaderParsedEventArgs(Header));
541-
}
547+
}
542548
}
543549

544550
if (HeaderParsed != null)
@@ -582,6 +588,9 @@ private void FixTickTime()
582588

583589
if (isConsecutive) {
584590
_ticktime = gap * TickInterval;
591+
592+
if (TimeFixed != null)
593+
TimeFixed(this, new TimeFixedEventArgs());
585594
}
586595
}
587596

@@ -1449,6 +1458,7 @@ public void Dispose ()
14491458
this.FlashNadeExploded = null;
14501459
this.HeaderParsed = null;
14511460
this.HeaderCorrupted = null;
1461+
this.TimeFixed = null;
14521462
this.MatchStarted = null;
14531463
this.NadeReachedTarget = null;
14541464
this.PlayerKilled = null;

0 commit comments

Comments
 (0)