aboutsummaryrefslogtreecommitdiff
path: root/packets/messages/types/SvcPacketEntities.go
blob: 9d8a8b0bbe10f50e69414605ade7ffcda280fbcf (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
37
38
39
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())
	} else {
		deltafrom = -1
	}
	baseline := reader.TryReadBool()
	updatedentries := reader.TryReadBits(11)
	length := reader.TryReadBits(20)
	updatebaseline := reader.TryReadBool()
	return SvcPacketEntities{
		MaxEntries:     uint16(maxentries),
		IsDelta:        isdelta,
		DeltaFrom:      deltafrom,
		BaseLine:       baseline,
		UpdatedEntries: uint16(updatedentries),
		UpdateBaseline: updatebaseline,
		Data:           reader.TryReadBitsToSlice(int(length)),
	}
}