diff options
Diffstat (limited to 'pkg/messages/types/svcSounds.go')
| -rw-r--r-- | pkg/messages/types/svcSounds.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/pkg/messages/types/svcSounds.go b/pkg/messages/types/svcSounds.go new file mode 100644 index 0000000..e87d584 --- /dev/null +++ b/pkg/messages/types/svcSounds.go | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | package messages | ||
| 2 | |||
| 3 | import "github.com/pektezol/bitreader" | ||
| 4 | |||
| 5 | type SvcSounds struct { | ||
| 6 | ReliableSound bool | ||
| 7 | Size int8 | ||
| 8 | Length int16 | ||
| 9 | Data []byte | ||
| 10 | } | ||
| 11 | |||
| 12 | func ParseSvcSounds(reader *bitreader.ReaderType) SvcSounds { | ||
| 13 | svcSounds := SvcSounds{ | ||
| 14 | ReliableSound: reader.TryReadBool(), | ||
| 15 | } | ||
| 16 | if svcSounds.ReliableSound { | ||
| 17 | svcSounds.Size = 1 | ||
| 18 | svcSounds.Length = int16(reader.TryReadBits(8)) | ||
| 19 | } else { | ||
| 20 | svcSounds.Size = int8(reader.TryReadBits(8)) | ||
| 21 | svcSounds.Length = int16(reader.TryReadBits(16)) | ||
| 22 | } | ||
| 23 | svcSounds.Data = reader.TryReadBitsToSlice(int(svcSounds.Length)) | ||
| 24 | return svcSounds | ||
| 25 | } | ||