aboutsummaryrefslogtreecommitdiff
path: root/pkg/messages/types/svcPacketEntities.go
blob: 2d86bf244017f0ae7ee9630dec0db671514d85d5 (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
package messages

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

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

func ParseSvcPacketEntities(reader *bitreader.Reader) SvcPacketEntities {
	svcPacketEntities := SvcPacketEntities{
		MaxEntries: uint16(reader.TryReadBits(11)),
		IsDelta:    reader.TryReadBool(),
	}
	if svcPacketEntities.IsDelta {
		svcPacketEntities.DeltaFrom = reader.TryReadSInt32()
	} else {
		svcPacketEntities.DeltaFrom = -1
	}
	svcPacketEntities.BaseLine = reader.TryReadBool()
	svcPacketEntities.UpdatedEntries = uint16(reader.TryReadBits(11))
	svcPacketEntities.Length = uint32(reader.TryReadBits(20))
	svcPacketEntities.UpdatedBaseline = reader.TryReadBool()
	svcPacketEntities.Data = reader.TryReadBitsToSlice(uint64(svcPacketEntities.Length))
	return svcPacketEntities
}