aboutsummaryrefslogtreecommitdiff
path: root/packets/messages/types/SvcPacketEntities.go
blob: 5fc27dbb9db6e0f827a8ad48d8c649a4e7e48a06 (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
25
26
27
28
29
30
31
32
33
34
35
36
package types

import (
	"github.com/pektezol/bitreader"
)

type SvcPacketEntities struct {
	MaxEntries     uint16
	IsDelta        bool
	DeltaFrom      int32
	BaseLine       bool
	UpdatedEntries uint16
	UpdateBaseline bool
	Data           []byte
}

func ParseSvcPacketEntities(reader *bitreader.ReaderType) SvcPacketEntities {
	maxentries := reader.TryReadBits(11)
	isdelta := reader.TryReadBool()
	var deltafrom int32
	if isdelta {
		deltafrom = int32(reader.TryReadInt32())
	}
	baseline := reader.TryReadBool()
	updatedentries := reader.TryReadBits(11)
	length := reader.TryReadBits(20)
	return SvcPacketEntities{
		MaxEntries:     uint16(maxentries),
		IsDelta:        isdelta,
		DeltaFrom:      deltafrom,
		BaseLine:       baseline,
		UpdatedEntries: uint16(updatedentries),
		UpdateBaseline: reader.TryReadBool(),
		Data:           reader.TryReadBytesToSlice(int(length / 8)),
	}
}