aboutsummaryrefslogtreecommitdiff
path: root/classes/userCmdInfo.go
diff options
context:
space:
mode:
authorBiSaXa <1669855+BiSaXa@users.noreply.github.com>2022-09-07 19:40:16 +0300
committerArda Serdar Pektezol <1669855+pektezol@users.noreply.github.com>2023-09-16 21:39:36 +0300
commit4e71a481884c0c43aea3d0ee695ae68cdec56478 (patch)
treed75c96612526a7c686d9f4d85af6b89c7cd864e6 /classes/userCmdInfo.go
parentfinal commit before rewrite (diff)
downloadsdp.go-4e71a481884c0c43aea3d0ee695ae68cdec56478.tar.gz
sdp.go-4e71a481884c0c43aea3d0ee695ae68cdec56478.tar.bz2
sdp.go-4e71a481884c0c43aea3d0ee695ae68cdec56478.zip
first rewrite commit using bisaxa/bitreader
Diffstat (limited to 'classes/userCmdInfo.go')
-rw-r--r--classes/userCmdInfo.go72
1 files changed, 0 insertions, 72 deletions
diff --git a/classes/userCmdInfo.go b/classes/userCmdInfo.go
deleted file mode 100644
index d2de229..0000000
--- a/classes/userCmdInfo.go
+++ /dev/null
@@ -1,72 +0,0 @@
1package classes
2
3import (
4 "fmt"
5
6 "github.com/bisaxa/demoparser/utils"
7)
8
9type UserCmdInfo struct {
10 CommandNumber int32
11 TickCount int32
12 ViewAnglesX float32
13 ViewAnglesY float32
14 ViewAnglesZ float32
15 ForwardMove float32
16 SideMove float32
17 UpMove float32
18 Buttons int32
19 // Impulse byte }
20 // WeaponSelect int32 }
21 // WeaponSubtype int32 Not worth the effort, no one cares about these
22 // MouseDx int16 }
23 // MouseDy int }
24}
25
26// It is so janky it hurts, but hey it is at least working (hopefully)
27// Reading the data is really weird, who even implemented this smh
28func UserCmdInfoInit(byteArr []byte, size int32) (output UserCmdInfo) {
29 var class UserCmdInfo
30 successCount := 0
31 failedCount := 0
32 looped := 0
33 classIndex := 0
34 //fmt.Println(byteArr)
35 fmt.Printf("%08b\n", byteArr)
36 for i := 0; i < 9; i++ {
37 if successCount+failedCount > 7 {
38 failedCount = -successCount
39 looped++
40 }
41 firstBit, err := utils.ReadBitStateLSB(byteArr[successCount*4+looped], successCount+failedCount)
42 utils.CheckError(err)
43 if firstBit {
44 successCount++
45 switch classIndex {
46 case 0:
47 class.CommandNumber = utils.Read32BitsAfterFirstBitInt32(byteArr, successCount+failedCount, successCount*4+looped)
48 case 1:
49 class.TickCount = utils.Read32BitsAfterFirstBitInt32(byteArr, successCount+failedCount, successCount*4+looped)
50 case 2:
51 class.ViewAnglesX = utils.Read32BitsAfterFirstBitFloat32(byteArr, successCount+failedCount, successCount*4+looped)
52 case 3:
53 class.ViewAnglesY = utils.Read32BitsAfterFirstBitFloat32(byteArr, successCount+failedCount, successCount*4+looped)
54 case 4:
55 class.ViewAnglesZ = utils.Read32BitsAfterFirstBitFloat32(byteArr, successCount+failedCount, successCount*4+looped)
56 case 5:
57 class.ForwardMove = utils.Read32BitsAfterFirstBitFloat32(byteArr, successCount+failedCount, successCount*4+looped)
58 case 6:
59 class.SideMove = utils.Read32BitsAfterFirstBitFloat32(byteArr, successCount+failedCount, successCount*4+looped)
60 case 7:
61 class.UpMove = utils.Read32BitsAfterFirstBitFloat32(byteArr, successCount+failedCount, successCount*4+looped)
62 case 8:
63 class.Buttons = utils.Read32BitsAfterFirstBitInt32(byteArr, successCount+failedCount, successCount*4+looped)
64 }
65 classIndex++
66 } else {
67 failedCount++
68 classIndex++
69 }
70 }
71 return class
72}