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

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

type SvcSounds struct {
	ReliableSound bool
	SoundCount    uint8
	Length        uint16
	Data          []byte
}

func ParseSvcSounds(reader *bitreader.Reader) SvcSounds {
	svcSounds := SvcSounds{
		ReliableSound: reader.TryReadBool(),
	}
	if svcSounds.ReliableSound {
		svcSounds.SoundCount = 1
		svcSounds.Length = uint16(reader.TryReadUInt8())
	} else {
		svcSounds.SoundCount = reader.TryReadUInt8()
		svcSounds.Length = reader.TryReadUInt16()
	}
	svcSounds.Data = reader.TryReadBitsToSlice(uint64(svcSounds.Length))

	return svcSounds
}