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

import "github.com/pektezol/bitreader"

type SvcSounds struct {
	ReliableSound bool
	Size          int8
	Length        int16
	Data          []byte
}

func ParseSvcSounds(reader *bitreader.Reader) SvcSounds {
	svcSounds := SvcSounds{
		ReliableSound: reader.TryReadBool(),
	}
	if svcSounds.ReliableSound {
		svcSounds.Size = 1
		svcSounds.Length = int16(reader.TryReadBits(8))
	} else {
		svcSounds.Size = int8(reader.TryReadBits(8))
		svcSounds.Length = int16(reader.TryReadBits(16))
	}
	svcSounds.Data = reader.TryReadBitsToSlice(uint64(svcSounds.Length))
	return svcSounds
}