aboutsummaryrefslogtreecommitdiff
path: root/pkg/messages/types/svcBspDecal.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/messages/types/svcBspDecal.go')
-rw-r--r--pkg/messages/types/svcBspDecal.go62
1 files changed, 0 insertions, 62 deletions
diff --git a/pkg/messages/types/svcBspDecal.go b/pkg/messages/types/svcBspDecal.go
deleted file mode 100644
index 6bf96a3..0000000
--- a/pkg/messages/types/svcBspDecal.go
+++ /dev/null
@@ -1,62 +0,0 @@
1package messages
2
3import (
4 "github.com/pektezol/bitreader"
5)
6
7type SvcBspDecal struct {
8 Pos []vectorCoord
9 DecalTextureIndex int16
10 EntityIndex uint16
11 ModelIndex uint16
12 LowPriority bool
13}
14
15type vectorCoord struct {
16 Value float32
17 Valid bool
18}
19
20func ParseSvcBspDecal(reader *bitreader.Reader) SvcBspDecal {
21 svcBspDecal := SvcBspDecal{
22 Pos: readVectorCoords(reader),
23 DecalTextureIndex: int16(reader.TryReadBits(9)),
24 }
25 if reader.TryReadBool() {
26 svcBspDecal.EntityIndex = uint16(reader.TryReadBits(11))
27 svcBspDecal.ModelIndex = uint16(reader.TryReadBits(11))
28 }
29 svcBspDecal.LowPriority = reader.TryReadBool()
30
31 return svcBspDecal
32}
33
34func readVectorCoords(reader *bitreader.Reader) []vectorCoord {
35 const COORD_INTEGER_BITS uint8 = 14
36 const COORD_FRACTIONAL_BITS uint8 = 5
37 const COORD_DENOMINATOR uint8 = 1 << COORD_FRACTIONAL_BITS
38 const COORD_RESOLUTION float32 = 1.0 / float32(COORD_DENOMINATOR)
39 readVectorCoord := func() float32 {
40 value := float32(0)
41 integer := reader.TryReadBits(1)
42 fraction := reader.TryReadBits(1)
43 if integer != 0 || fraction != 0 {
44 sign := reader.TryReadBits(1)
45 if integer != 0 {
46 integer = reader.TryReadBits(uint64(COORD_INTEGER_BITS)) + 1
47 }
48 if fraction != 0 {
49 fraction = reader.TryReadBits(uint64(COORD_FRACTIONAL_BITS))
50 }
51 value = float32(integer) + float32(fraction)*COORD_RESOLUTION
52 if sign != 0 {
53 value = -value
54 }
55 }
56 return value
57 }
58 x := reader.TryReadBits(1)
59 y := reader.TryReadBits(1)
60 z := reader.TryReadBits(1)
61 return []vectorCoord{{Value: readVectorCoord(), Valid: x != 0}, {Value: readVectorCoord(), Valid: y != 0}, {Value: readVectorCoord(), Valid: z != 0}}
62}