diff options
| author | BiSaXa <1669855+BiSaXa@users.noreply.github.com> | 2022-08-27 13:02:35 +0300 |
|---|---|---|
| committer | BiSaXa <1669855+BiSaXa@users.noreply.github.com> | 2022-08-27 13:02:35 +0300 |
| commit | f108a577658c9aab8496da4ebd0fb4f0216093e8 (patch) | |
| tree | e484a8a8b54c92ca4a393f267ebc755ec6434c8d /classes/userCmdInfo.go | |
| download | sdp.go-f108a577658c9aab8496da4ebd0fb4f0216093e8.tar.gz sdp.go-f108a577658c9aab8496da4ebd0fb4f0216093e8.tar.bz2 sdp.go-f108a577658c9aab8496da4ebd0fb4f0216093e8.zip | |
init
Diffstat (limited to 'classes/userCmdInfo.go')
| -rw-r--r-- | classes/userCmdInfo.go | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/classes/userCmdInfo.go b/classes/userCmdInfo.go new file mode 100644 index 0000000..ae27e9a --- /dev/null +++ b/classes/userCmdInfo.go | |||
| @@ -0,0 +1,57 @@ | |||
| 1 | package classes | ||
| 2 | |||
| 3 | import ( | ||
| 4 | "parser/utils" | ||
| 5 | ) | ||
| 6 | |||
| 7 | type UserCmdInfo struct { | ||
| 8 | CommandNumber int32 | ||
| 9 | TickCount int32 | ||
| 10 | ViewAnglesX float32 | ||
| 11 | ViewAnglesY float32 | ||
| 12 | ViewAnglesZ float32 | ||
| 13 | ForwardMove float32 | ||
| 14 | SideMove float32 | ||
| 15 | UpMove float32 | ||
| 16 | Buttons int32 | ||
| 17 | Impulse byte | ||
| 18 | /*WeaponSelect int | ||
| 19 | WeaponSubtype int | ||
| 20 | MouseDx int16 | ||
| 21 | MouseDy int16*/ | ||
| 22 | } | ||
| 23 | |||
| 24 | func UserCmdInfoInit(byteArr []byte, size int) (output UserCmdInfo) { | ||
| 25 | var class UserCmdInfo | ||
| 26 | if size-1 >= 4 { | ||
| 27 | class.CommandNumber = int32(utils.IntFromBytes(byteArr[:4])) | ||
| 28 | } | ||
| 29 | if size-1 >= 8 { | ||
| 30 | class.TickCount = int32(utils.IntFromBytes(byteArr[4:8])) | ||
| 31 | } | ||
| 32 | if size-1 >= 12 { | ||
| 33 | class.ViewAnglesX = utils.FloatFromBytes(byteArr[8:12]) | ||
| 34 | } | ||
| 35 | if size-1 >= 16 { | ||
| 36 | class.ViewAnglesY = utils.FloatFromBytes(byteArr[12:16]) | ||
| 37 | } | ||
| 38 | if size-1 >= 20 { | ||
| 39 | class.ViewAnglesZ = utils.FloatFromBytes(byteArr[16:20]) | ||
| 40 | } | ||
| 41 | if size-1 >= 24 { | ||
| 42 | class.ForwardMove = utils.FloatFromBytes(byteArr[20:24]) | ||
| 43 | } | ||
| 44 | if size-1 >= 28 { | ||
| 45 | class.SideMove = utils.FloatFromBytes(byteArr[24:28]) | ||
| 46 | } | ||
| 47 | if size-1 >= 32 { | ||
| 48 | class.UpMove = utils.FloatFromBytes(byteArr[28:32]) | ||
| 49 | } | ||
| 50 | if size-1 >= 36 { | ||
| 51 | class.Buttons = int32(utils.IntFromBytes(byteArr[32:36])) | ||
| 52 | } | ||
| 53 | if size-1 >= 40 { | ||
| 54 | class.Impulse = byteArr[36] | ||
| 55 | } | ||
| 56 | return class | ||
| 57 | } | ||