Skip to content

Commit 7c11f6a

Browse files
authored
events: add TickRateInfoAvailable for CSVCMsg_ServerInfo (#296)
1 parent fcd7113 commit 7c11f6a

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

pkg/demoinfocs/events/events.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,13 @@ type SayText2 struct {
447447
IsChatAll bool // Seems to always be false, team chat might not be recorded
448448
}
449449

450+
// TickRateInfoAvailable signals that the tick-rate information has been received via CSVCMsg_ServerInfo.
451+
// This can be useful for corrupt demo headers where the tick-rate is missing in the beginning of the demo.
452+
type TickRateInfoAvailable struct {
453+
TickRate float64 // See Parser.TickRate()
454+
TickTime time.Duration // See Parser.TickTime()
455+
}
456+
450457
// ChatMessage signals a player generated chat message.
451458
// Since team chat is generally not recorded IsChatAll will probably always be false.
452459
// See SayText for admin / console messages and SayText2 for raw network package data.

pkg/demoinfocs/net_messages.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,9 @@ func (p *parser) handleSetConVar(setConVar *msg.CNETMsg_SetConVar) {
6565
func (p *parser) handleServerInfo(srvInfo *msg.CSVCMsg_ServerInfo) {
6666
// srvInfo.MapCrc might be interesting as well
6767
p.tickInterval = srvInfo.TickInterval
68+
69+
p.eventDispatcher.Dispatch(events.TickRateInfoAvailable{
70+
TickRate: p.TickRate(),
71+
TickTime: p.TickTime(),
72+
})
6873
}

test/default.golden

41 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)