Skip to content

Commit e9cf7cd

Browse files
committed
events: deprecate TickDone in favour of FrameDone (#120)
1 parent f12b32a commit e9cf7cd

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

demoinfocs_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ import (
1313
"testing"
1414
"time"
1515

16-
proto "github.com/gogo/protobuf/proto"
16+
"github.com/gogo/protobuf/proto"
1717
dispatch "github.com/markus-wa/godispatch"
1818

1919
dem "github.com/markus-wa/demoinfocs-golang"
20-
common "github.com/markus-wa/demoinfocs-golang/common"
21-
events "github.com/markus-wa/demoinfocs-golang/events"
22-
msg "github.com/markus-wa/demoinfocs-golang/msg"
20+
"github.com/markus-wa/demoinfocs-golang/common"
21+
"github.com/markus-wa/demoinfocs-golang/events"
22+
"github.com/markus-wa/demoinfocs-golang/msg"
2323
)
2424

2525
const csDemosPath = "cs-demos"
@@ -202,7 +202,7 @@ func TestCancelParseToEnd(t *testing.T) {
202202
var tix int
203203

204204
var handlerID dispatch.HandlerIdentifier
205-
handlerID = p.RegisterEventHandler(func(events.TickDone) {
205+
handlerID = p.RegisterEventHandler(func(events.FrameDone) {
206206
tix++
207207
if tix == maxTicks {
208208
p.Cancel()
@@ -215,7 +215,7 @@ func TestCancelParseToEnd(t *testing.T) {
215215
t.Error("Parsing cancelled but error was not ErrCancelled:", err)
216216
}
217217
if tix > maxTicks {
218-
t.Error("TickDoneEvent handler was triggered after being unregistered")
218+
t.Error("FrameDone handler was triggered after being unregistered")
219219
}
220220
}
221221

events/events.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,20 @@ package events
88
import (
99
"time"
1010

11-
r3 "github.com/golang/geo/r3"
11+
"github.com/golang/geo/r3"
1212

13-
common "github.com/markus-wa/demoinfocs-golang/common"
14-
msg "github.com/markus-wa/demoinfocs-golang/msg"
13+
"github.com/markus-wa/demoinfocs-golang/common"
14+
"github.com/markus-wa/demoinfocs-golang/msg"
1515
)
1616

17-
// TickDone signals that a tick is done.
17+
// TickDone is deprecated, use the identical FrameDone event instead.
18+
// It does NOT signal the end of a tick, it signals the end of a demo-frame instead.
1819
type TickDone struct{}
1920

21+
// FrameDone signals that a demo-frame has been processed.
22+
// A frame can contain multiple ticks (usually 2 or 4) if the tv_snapshotrate differs from the tick-rate the game was played at.
23+
type FrameDone struct{}
24+
2025
// MatchStart signals that the match has started.
2126
type MatchStart struct{}
2227

@@ -425,7 +430,7 @@ type DataTablesParsed struct{}
425430

426431
// StringTableCreated signals that a string table was created via net message.
427432
// Can be useful for figuring out when player-info is available via Parser.GameState().[Playing]Participants().
428-
// E.g. after the table 'userinfo' has been created the player-data should be available after the next TickDone.
433+
// E.g. after the table 'userinfo' has been created the player-data should be available after the next FrameDone.
429434
// The reason it's not immediately available is because we need to do some post-processing to prep that data after a tick has finished.
430435
type StringTableCreated struct {
431436
TableName string

parsing.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ func (p *Parser) handleFrameParsed(*frameParsedTokenType) {
349349

350350
p.currentFrame++
351351
p.eventDispatcher.Dispatch(events.TickDone{})
352+
p.eventDispatcher.Dispatch(events.FrameDone{})
352353
}
353354

354355
/*

0 commit comments

Comments
 (0)