blob: 78e9c5853ab83f07def60f05193b58035c366eee (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
package classes
import (
"bytes"
"github.com/pektezol/bitreader"
)
func ParseUserCmdInfo(data []byte) UserCmdInfo {
reader := bitreader.Reader(bytes.NewReader(data), true)
var userCmdInfo UserCmdInfo
if reader.TryReadBool() {
userCmdInfo.CommandNumber = int32(reader.TryReadInt32())
}
if reader.TryReadBool() {
userCmdInfo.TickCount = int32(reader.TryReadInt32())
}
if reader.TryReadBool() {
userCmdInfo.ViewAnglesX = reader.TryReadFloat32()
}
if reader.TryReadBool() {
userCmdInfo.ViewAnglesY = reader.TryReadFloat32()
}
if reader.TryReadBool() {
userCmdInfo.ViewAnglesZ = reader.TryReadFloat32()
}
if reader.TryReadBool() {
userCmdInfo.ForwardMove = reader.TryReadFloat32()
}
if reader.TryReadBool() {
userCmdInfo.SideMove = reader.TryReadFloat32()
}
if reader.TryReadBool() {
userCmdInfo.UpMove = reader.TryReadFloat32()
}
if reader.TryReadBool() {
userCmdInfo.Buttons = int32(reader.TryReadInt32())
}
if reader.TryReadBool() {
userCmdInfo.Impulse = reader.TryReadInt8()
}
if reader.TryReadBool() {
value, err := reader.ReadBits(11)
if err != nil {
panic(err)
}
userCmdInfo.WeaponSelect = int(value)
if reader.TryReadBool() {
value, err := reader.ReadBits(6)
if err != nil {
panic(err)
}
userCmdInfo.WeaponSubtype = int(value)
}
}
if reader.TryReadBool() {
userCmdInfo.MouseDx = int16(reader.TryReadInt16())
}
if reader.TryReadBool() {
userCmdInfo.MouseDy = int16(reader.TryReadInt16())
}
return userCmdInfo
}
|