aboutsummaryrefslogtreecommitdiff
path: root/packets/classes/usercmd.go
diff options
context:
space:
mode:
authorArda Serdar Pektezol <1669855+pektezol@users.noreply.github.com>2022-11-07 18:42:28 +0300
committerArda Serdar Pektezol <1669855+pektezol@users.noreply.github.com>2023-09-16 21:39:38 +0300
commit8352bfc1d8deedd4d6a0a5b0698fe1f8b9a06e88 (patch)
tree69fd0825f69ff70fe0c8ae597cfe20a91af2d961 /packets/classes/usercmd.go
parentstarting stringtable (diff)
downloadsdp.go-8352bfc1d8deedd4d6a0a5b0698fe1f8b9a06e88.tar.gz
sdp.go-8352bfc1d8deedd4d6a0a5b0698fe1f8b9a06e88.tar.bz2
sdp.go-8352bfc1d8deedd4d6a0a5b0698fe1f8b9a06e88.zip
stringtable done, can't see data properly
Diffstat (limited to 'packets/classes/usercmd.go')
-rw-r--r--packets/classes/usercmd.go45
1 files changed, 7 insertions, 38 deletions
diff --git a/packets/classes/usercmd.go b/packets/classes/usercmd.go
index a3183b6..78e9c58 100644
--- a/packets/classes/usercmd.go
+++ b/packets/classes/usercmd.go
@@ -1,94 +1,63 @@
1package classes 1package classes
2 2
3import ( 3import (
4 "bytes"
5
4 "github.com/pektezol/bitreader" 6 "github.com/pektezol/bitreader"
5) 7)
6 8
7func ParseUserCmdInfo(reader *bitreader.ReaderType, size int) UserCmdInfo { 9func ParseUserCmdInfo(data []byte) UserCmdInfo {
8 var bitCount int 10 reader := bitreader.Reader(bytes.NewReader(data), true)
9 var userCmdInfo UserCmdInfo 11 var userCmdInfo UserCmdInfo
10 if reader.TryReadBool() { 12 if reader.TryReadBool() {
11 userCmdInfo.CommandNumber = int(reader.TryReadInt32()) 13 userCmdInfo.CommandNumber = int32(reader.TryReadInt32())
12 bitCount += 32
13 } 14 }
14 bitCount++
15 if reader.TryReadBool() { 15 if reader.TryReadBool() {
16 userCmdInfo.TickCount = int(reader.TryReadInt32()) 16 userCmdInfo.TickCount = int32(reader.TryReadInt32())
17 bitCount += 32
18 } 17 }
19 bitCount++
20 if reader.TryReadBool() { 18 if reader.TryReadBool() {
21 userCmdInfo.ViewAnglesX = reader.TryReadFloat32() 19 userCmdInfo.ViewAnglesX = reader.TryReadFloat32()
22 bitCount += 32
23 } 20 }
24 bitCount++
25 if reader.TryReadBool() { 21 if reader.TryReadBool() {
26 userCmdInfo.ViewAnglesY = reader.TryReadFloat32() 22 userCmdInfo.ViewAnglesY = reader.TryReadFloat32()
27 bitCount += 32
28 } 23 }
29 bitCount++
30 if reader.TryReadBool() { 24 if reader.TryReadBool() {
31 userCmdInfo.ViewAnglesZ = reader.TryReadFloat32() 25 userCmdInfo.ViewAnglesZ = reader.TryReadFloat32()
32 bitCount += 32
33 } 26 }
34 bitCount++
35 if reader.TryReadBool() { 27 if reader.TryReadBool() {
36 userCmdInfo.ForwardMove = reader.TryReadFloat32() 28 userCmdInfo.ForwardMove = reader.TryReadFloat32()
37 bitCount += 32
38 } 29 }
39 bitCount++
40 if reader.TryReadBool() { 30 if reader.TryReadBool() {
41 userCmdInfo.SideMove = reader.TryReadFloat32() 31 userCmdInfo.SideMove = reader.TryReadFloat32()
42 bitCount += 32
43 } 32 }
44 bitCount++
45 if reader.TryReadBool() { 33 if reader.TryReadBool() {
46 userCmdInfo.UpMove = reader.TryReadFloat32() 34 userCmdInfo.UpMove = reader.TryReadFloat32()
47 bitCount += 32
48 } 35 }
49 bitCount++
50 if reader.TryReadBool() { 36 if reader.TryReadBool() {
51 userCmdInfo.Buttons = int(reader.TryReadInt32()) 37 userCmdInfo.Buttons = int32(reader.TryReadInt32())
52 bitCount += 32
53 } 38 }
54 bitCount++
55 if reader.TryReadBool() { 39 if reader.TryReadBool() {
56 userCmdInfo.Impulse = reader.TryReadInt8() 40 userCmdInfo.Impulse = reader.TryReadInt8()
57 bitCount += 8
58 } 41 }
59 bitCount++
60 if reader.TryReadBool() { 42 if reader.TryReadBool() {
61 value, err := reader.ReadBits(11) 43 value, err := reader.ReadBits(11)
62 if err != nil { 44 if err != nil {
63 panic(err) 45 panic(err)
64 } 46 }
65 userCmdInfo.WeaponSelect = int(value) 47 userCmdInfo.WeaponSelect = int(value)
66 bitCount += 11
67 if reader.TryReadBool() { 48 if reader.TryReadBool() {
68 value, err := reader.ReadBits(6) 49 value, err := reader.ReadBits(6)
69 if err != nil { 50 if err != nil {
70 panic(err) 51 panic(err)
71 } 52 }
72 userCmdInfo.WeaponSubtype = int(value) 53 userCmdInfo.WeaponSubtype = int(value)
73 bitCount += 6
74 } 54 }
75 bitCount++
76 } 55 }
77 bitCount++
78 if reader.TryReadBool() { 56 if reader.TryReadBool() {
79 userCmdInfo.MouseDx = int16(reader.TryReadInt16()) 57 userCmdInfo.MouseDx = int16(reader.TryReadInt16())
80 bitCount += 16
81 } 58 }
82 bitCount++
83 if reader.TryReadBool() { 59 if reader.TryReadBool() {
84 userCmdInfo.MouseDy = int16(reader.TryReadInt16()) 60 userCmdInfo.MouseDy = int16(reader.TryReadInt16())
85 bitCount += 16
86 } 61 }
87 bitCount++
88 /*if bitCount > size*8 {
89 //reader.SkipBits(size * 8)
90 return userCmdInfo
91 }*/
92 reader.SkipBits(size*8 - bitCount)
93 return userCmdInfo 62 return userCmdInfo
94} 63}