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

import "github.com/pektezol/bitreader"

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

func ParseSvcPacketEntities(reader *bitreader.ReaderType) SvcPacketEntities {
	svcPacketEntities := SvcPacketEntities{
		MaxEntries: int16(reader.TryReadBits(11)),
		IsDelta:    reader.TryReadBool(),
	}
	if svcPacketEntities.IsDelta {
		svcPacketEntities.DeltaFrom = int32(reader.TryReadBits(32))
	}
	svcPacketEntities.BaseLine = reader.TryReadBool()
	svcPacketEntities.UpdatedEntries = int16(reader.TryReadBits(11))
	svcPacketEntities.Length = int32(reader.TryReadBits(20))
	svcPacketEntities.UpdatedBaseline = reader.TryReadBool()
	svcPacketEntities.Data = reader.TryReadBitsToSlice(int(svcPacketEntities.Length))
	return svcPacketEntities
}