diff options
| author | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2023-11-06 18:37:11 +0300 |
|---|---|---|
| committer | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2023-11-06 18:37:11 +0300 |
| commit | 2f8c92f261586f68a976efce0cfcdd0401f402e0 (patch) | |
| tree | 33189cc48987789dff4e7fba0a74d2b2326f0a04 /pkg/messages/types/svcBspDecal.go | |
| parent | convert cm ticks correctly (diff) | |
| download | sdp.go-2f8c92f261586f68a976efce0cfcdd0401f402e0.tar.gz sdp.go-2f8c92f261586f68a976efce0cfcdd0401f402e0.tar.bz2 sdp.go-2f8c92f261586f68a976efce0cfcdd0401f402e0.zip | |
dont try to understand it, feel itlp-parser
Diffstat (limited to 'pkg/messages/types/svcBspDecal.go')
| -rw-r--r-- | pkg/messages/types/svcBspDecal.go | 62 |
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 @@ | |||
| 1 | package messages | ||
| 2 | |||
| 3 | import ( | ||
| 4 | "github.com/pektezol/bitreader" | ||
| 5 | ) | ||
| 6 | |||
| 7 | type SvcBspDecal struct { | ||
| 8 | Pos []vectorCoord | ||
| 9 | DecalTextureIndex int16 | ||
| 10 | EntityIndex uint16 | ||
| 11 | ModelIndex uint16 | ||
| 12 | LowPriority bool | ||
| 13 | } | ||
| 14 | |||
| 15 | type vectorCoord struct { | ||
| 16 | Value float32 | ||
| 17 | Valid bool | ||
| 18 | } | ||
| 19 | |||
| 20 | func 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 | |||
| 34 | func 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 | } | ||