aboutsummaryrefslogtreecommitdiff
path: root/pkg/messages/types/netTick.go
blob: 9ef1ce2b13b6318280daeac872d3f3065a2e5a6d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package messages

import (
	"github.com/pektezol/bitreader"
	"github.com/pektezol/sdp.go/pkg/writer"
)

type NetTick struct {
	Tick                      uint32
	HostFrameTime             float32
	HostFrameTimeStdDeviation float32
}

func ParseNetTick(reader *bitreader.Reader) NetTick {
	netTick := NetTick{
		Tick:                      reader.TryReadUInt32(),
		HostFrameTime:             float32(reader.TryReadUInt16()) / 1e5,
		HostFrameTimeStdDeviation: float32(reader.TryReadUInt16()) / 1e5,
	}
	writer.TempAppendLine("\t\tTick: %d", netTick.Tick)
	writer.TempAppendLine("\t\tHost Frame Time: %f", netTick.HostFrameTime)
	writer.TempAppendLine("\t\tHost Frame Time Std Deviation: %f", netTick.HostFrameTimeStdDeviation)
	return netTick
}