diff options
Diffstat (limited to 'packets/classes/usercmd.go')
| -rw-r--r-- | packets/classes/usercmd.go | 80 |
1 files changed, 0 insertions, 80 deletions
diff --git a/packets/classes/usercmd.go b/packets/classes/usercmd.go deleted file mode 100644 index d3328fd..0000000 --- a/packets/classes/usercmd.go +++ /dev/null | |||
| @@ -1,80 +0,0 @@ | |||
| 1 | package classes | ||
| 2 | |||
| 3 | import ( | ||
| 4 | "bytes" | ||
| 5 | |||
| 6 | "github.com/pektezol/bitreader" | ||
| 7 | ) | ||
| 8 | |||
| 9 | type 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 int | ||
| 21 | WeaponSubtype int | ||
| 22 | MouseDx int16 | ||
| 23 | MouseDy int16 | ||
| 24 | } | ||
| 25 | |||
| 26 | func ParseUserCmdInfo(data []byte) UserCmdInfo { | ||
| 27 | reader := bitreader.Reader(bytes.NewReader(data), true) | ||
| 28 | var userCmdInfo UserCmdInfo | ||
| 29 | if reader.TryReadBool() { | ||
| 30 | userCmdInfo.CommandNumber = int32(reader.TryReadInt32()) | ||
| 31 | } | ||
| 32 | if reader.TryReadBool() { | ||
| 33 | userCmdInfo.TickCount = int32(reader.TryReadInt32()) | ||
| 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.TryReadInt32()) | ||
| 55 | } | ||
| 56 | if reader.TryReadBool() { | ||
| 57 | userCmdInfo.Impulse = reader.TryReadInt8() | ||
| 58 | } | ||
| 59 | if reader.TryReadBool() { | ||
| 60 | value, err := reader.ReadBits(11) | ||
| 61 | if err != nil { | ||
| 62 | panic(err) | ||
| 63 | } | ||
| 64 | userCmdInfo.WeaponSelect = int(value) | ||
| 65 | if reader.TryReadBool() { | ||
| 66 | value, err := reader.ReadBits(6) | ||
| 67 | if err != nil { | ||
| 68 | panic(err) | ||
| 69 | } | ||
| 70 | userCmdInfo.WeaponSubtype = int(value) | ||
| 71 | } | ||
| 72 | } | ||
| 73 | if reader.TryReadBool() { | ||
| 74 | userCmdInfo.MouseDx = int16(reader.TryReadInt16()) | ||
| 75 | } | ||
| 76 | if reader.TryReadBool() { | ||
| 77 | userCmdInfo.MouseDy = int16(reader.TryReadInt16()) | ||
| 78 | } | ||
| 79 | return userCmdInfo | ||
| 80 | } | ||