aboutsummaryrefslogtreecommitdiff
path: root/pkg/messages/types/svcSounds.go
blob: 15534506317a613ef771fba2be8bf5c734e3b02e (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
	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
}