aboutsummaryrefslogtreecommitdiff
path: root/pkg/classes/userCmdInfo.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/classes/userCmdInfo.go')
-rw-r--r--pkg/classes/userCmdInfo.go72
1 files changed, 72 insertions, 0 deletions
diff --git a/pkg/classes/userCmdInfo.go b/pkg/classes/userCmdInfo.go
new file mode 100644
index 0000000..a6d9091
--- /dev/null
+++ b/pkg/classes/userCmdInfo.go
@@ -0,0 +1,72 @@
1package classes
2
3import (
4 "bytes"
5
6 "github.com/pektezol/bitreader"
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 int8
20 WeaponSelect int16
21 WeaponSubType int8
22 MouseDx int16
23 MouseDy int16
24}
25
26func ParseUserCmdInfo(data []byte) UserCmdInfo {
27 reader := bitreader.Reader(bytes.NewReader(data), true)
28 userCmdInfo := UserCmdInfo{}
29 if reader.TryReadBool() {
30 userCmdInfo.CommandNumber = int32(reader.TryReadBits(32))
31 }
32 if reader.TryReadBool() {
33 userCmdInfo.TickCount = int32(reader.TryReadBits(32))
34 }
35 if reader.TryReadBool() {
36 userCmdInfo.ViewAnglesX = reader.TryReadFloat32()
37 }
38 if reader.TryReadBool() {
39 userCmdInfo.ViewAnglesY = reader.TryReadFloat32()
40 }
41 if reader.TryReadBool() {
42 userCmdInfo.ViewAnglesZ = reader.TryReadFloat32()
43 }
44 if reader.TryReadBool() {
45 userCmdInfo.ForwardMove = reader.TryReadFloat32()
46 }
47 if reader.TryReadBool() {
48 userCmdInfo.SideMove = reader.TryReadFloat32()
49 }
50 if reader.TryReadBool() {
51 userCmdInfo.UpMove = reader.TryReadFloat32()
52 }
53 if reader.TryReadBool() {
54 userCmdInfo.Buttons = int32(reader.TryReadBits(32))
55 }
56 if reader.TryReadBool() {
57 userCmdInfo.Impulse = int8(reader.TryReadBits(8))
58 }
59 if reader.TryReadBool() {
60 userCmdInfo.WeaponSelect = int16(reader.TryReadBits(11))
61 if reader.TryReadBool() {
62 userCmdInfo.WeaponSubType = int8(reader.TryReadBits(6))
63 }
64 }
65 if reader.TryReadBool() {
66 userCmdInfo.MouseDx = int16(reader.TryReadBits(16))
67 }
68 if reader.TryReadBool() {
69 userCmdInfo.MouseDy = int16(reader.TryReadBits(16))
70 }
71 return userCmdInfo
72}