diff --git a/pkg/demoinfocs/datatables.go b/pkg/demoinfocs/datatables.go index 82cff6fa..112303ab 100644 --- a/pkg/demoinfocs/datatables.go +++ b/pkg/demoinfocs/datatables.go @@ -1121,10 +1121,21 @@ func (p *parser) bindGameRules() { entity.Property(grPrefix("m_bFreezePeriod")).OnUpdate(func(val st.PropertyValue) { newIsFreezetime := val.BoolVal() - p.eventDispatcher.Dispatch(events.RoundFreezetimeChanged{ + freezetimeEvent := events.RoundFreezetimeChanged{ OldIsFreezetime: p.gameState.isFreezetime, NewIsFreezetime: newIsFreezetime, - }) + } + + if p.isSource2() { + if p.disableMimicSource1GameEvents { + p.eventDispatcher.Dispatch(freezetimeEvent) + } else { + p.gameState.lastFreezeTimeChangedEvent = &freezetimeEvent + } + } else { + p.eventDispatcher.Dispatch(freezetimeEvent) + } + p.gameState.isFreezetime = newIsFreezetime }) diff --git a/pkg/demoinfocs/game_events.go b/pkg/demoinfocs/game_events.go index ae73382d..671430c6 100644 --- a/pkg/demoinfocs/game_events.go +++ b/pkg/demoinfocs/game_events.go @@ -1023,8 +1023,10 @@ func (p *parser) dispatchMatchStartedEventIfNecessary() { // Dispatch round progress events in the following order: // 1. MatchStartedChanged // 2. RoundStart -// 3. RoundEnd -// 4. MatchStartedChanged +// 3. FreezeTimeStart +// 4. FreezetimeEnd +// 5. RoundEnd +// 6. MatchStartedChanged func (p *parser) processRoundProgressEvents() { if p.gameState.lastRoundStartEvent != nil { p.dispatchMatchStartedEventIfNecessary() @@ -1032,6 +1034,11 @@ func (p *parser) processRoundProgressEvents() { p.gameState.lastRoundStartEvent = nil } + if p.gameState.lastFreezeTimeChangedEvent != nil { + p.gameEventHandler.dispatch(*p.gameState.lastFreezeTimeChangedEvent) + p.gameState.lastFreezeTimeChangedEvent = nil + } + if p.gameState.lastRoundEndEvent != nil { p.gameEventHandler.dispatch(*p.gameState.lastRoundEndEvent) p.gameState.lastRoundEndEvent = nil diff --git a/pkg/demoinfocs/game_state.go b/pkg/demoinfocs/game_state.go index cd28fbe6..3273b99b 100644 --- a/pkg/demoinfocs/game_state.go +++ b/pkg/demoinfocs/game_state.go @@ -43,9 +43,10 @@ type gameState struct { thrownGrenades map[*common.Player][]*common.Equipment // Information about every player's thrown grenades (from the moment they are thrown to the moment their effect is ended) rules gameRules demoInfo demoInfoProvider - lastRoundStartEvent *events.RoundStart // Used to dispatch this event after a possible MatchStartedChanged event - lastRoundEndEvent *events.RoundEnd // Used to dispatch this event before a possible MatchStartedChanged event - lastMatchStartedChangedEvent *events.MatchStartedChanged // Used to dispatch this event before a possible RoundStart event and after a possible RoundEnd event + lastRoundStartEvent *events.RoundStart // Used to dispatch this event after a possible MatchStartedChanged event + lastFreezeTimeChangedEvent *events.RoundFreezetimeChanged // Used to dispatch this event after a possible RoundStart event + lastRoundEndEvent *events.RoundEnd // Used to dispatch this event before a possible RoundFreezetimeChanged event + lastMatchStartedChangedEvent *events.MatchStartedChanged // Used to dispatch this event before a possible RoundStart event and after a possible RoundEnd event // Used to mimic missing player_blind events for CS2 demos. // // When a player throws a flashbang the following happens: