Skip to content

Commit 58e4196

Browse files
committed
feat: dispatch RecordingPlayerDetecte eventd
1 parent f3a1c63 commit 58e4196

File tree

5 files changed

+8
-17
lines changed

5 files changed

+8
-17
lines changed

pkg/demoinfocs/events/events.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ import (
1818
// A frame can contain multiple ticks (usually 2 or 4) if the tv_snapshotrate differs from the tick-rate the game was played at.
1919
type FrameDone struct{}
2020

21+
// RecordingPlayerDetected signals that a player started recording the demo locally.
22+
// If this event is dispatched, it means it's a client-side (POV) demo.
23+
type RecordingPlayerDetected struct {
24+
PlayerSlot int
25+
PlayerInfo common.PlayerInfo
26+
}
27+
2128
// MatchStart signals that the match has started.
2229
type MatchStart struct{}
2330

pkg/demoinfocs/parser.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,6 @@ func (p *parser) Progress() float32 {
195195
return float32(p.currentFrame) / float32(p.header.PlaybackFrames)
196196
}
197197

198-
// IsPOV indicates if the demo being parsed is a POV demo.
199-
func (p *parser) IsPOV() bool {
200-
return p.recordingPlayerSlot != -1
201-
}
202-
203198
/*
204199
RegisterEventHandler registers a handler for game events.
205200

pkg/demoinfocs/parser_interface.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ type Parser interface {
6464
// Might not be 100% correct since it's just based on the reported tick count of the header.
6565
// May always return 0 if the demo header is corrupt.
6666
Progress() float32
67-
// IsPOV indicates if the demo being parsed is a POV demo.
68-
IsPOV() bool
6967
/*
7068
RegisterEventHandler registers a handler for game events.
7169

pkg/demoinfocs/parser_test.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,6 @@ func TestParser_GameState(t *testing.T) {
2323
assert.Equal(t, gs, (&parser{gameState: gs}).GameState())
2424
}
2525

26-
func TestParser_IsPOV(t *testing.T) {
27-
p := &parser{recordingPlayerSlot: -1}
28-
29-
assert.Equal(t, false, p.IsPOV())
30-
31-
p.recordingPlayerSlot = 3
32-
33-
assert.Equal(t, true, p.IsPOV())
34-
}
35-
3626
func TestParser_CurrentTime(t *testing.T) {
3727
p := &parser{
3828
tickInterval: 2,

pkg/demoinfocs/stringtables.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ func (p *parser) processStringTable(tab *msg.CSVCMsg_CreateStringTable) {
241241

242242
if p.header.ClientName == player.Name {
243243
p.recordingPlayerSlot = entryIndex
244+
p.eventDispatcher.Dispatch(events.RecordingPlayerDetected{PlayerSlot: entryIndex, PlayerInfo: player})
244245
}
245246

246247
p.setRawPlayer(entryIndex, player)

0 commit comments

Comments
 (0)