diff options
| author | BiSaXa <1669855+BiSaXa@users.noreply.github.com> | 2022-08-27 21:17:06 +0300 |
|---|---|---|
| committer | BiSaXa <1669855+BiSaXa@users.noreply.github.com> | 2022-08-27 21:17:06 +0300 |
| commit | 2e51abad509a6663f1cc15da91a263ff7b8e1513 (patch) | |
| tree | 2a3238661ead91740df80ec63b93c632120b073f /classes | |
| parent | some stuff before i realized i need my own bitreader library (diff) | |
| download | sdp.go-2e51abad509a6663f1cc15da91a263ff7b8e1513.tar.gz sdp.go-2e51abad509a6663f1cc15da91a263ff7b8e1513.tar.bz2 sdp.go-2e51abad509a6663f1cc15da91a263ff7b8e1513.zip | |
it's a mess
Diffstat (limited to 'classes')
| -rw-r--r-- | classes/userCmdInfo.go | 105 |
1 files changed, 75 insertions, 30 deletions
diff --git a/classes/userCmdInfo.go b/classes/userCmdInfo.go index 3705c8d..86b186c 100644 --- a/classes/userCmdInfo.go +++ b/classes/userCmdInfo.go | |||
| @@ -1,7 +1,6 @@ | |||
| 1 | package classes | 1 | package classes |
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "fmt" | ||
| 5 | "parser/utils" | 4 | "parser/utils" |
| 6 | 5 | ||
| 7 | "github.com/potterxu/bitreader" | 6 | "github.com/potterxu/bitreader" |
| @@ -16,53 +15,99 @@ type UserCmdInfo struct { | |||
| 16 | ForwardMove float32 | 15 | ForwardMove float32 |
| 17 | SideMove float32 | 16 | SideMove float32 |
| 18 | UpMove float32 | 17 | UpMove float32 |
| 19 | Buttons int32 | ||
| 20 | Impulse byte | ||
| 21 | /*WeaponSelect int | ||
| 22 | WeaponSubtype int | ||
| 23 | MouseDx int16 | ||
| 24 | MouseDy int16*/ | ||
| 25 | } | 18 | } |
| 26 | 19 | ||
| 27 | func UserCmdInfoInit(byteArr []byte, size int) (output UserCmdInfo) { | 20 | func UserCmdInfoInit(byteArr []byte, size int) (output UserCmdInfo) { |
| 28 | var class UserCmdInfo | 21 | var class UserCmdInfo |
| 29 | fmt.Println("Size: ", size) | 22 | reversedByteArr := utils.ReverseByteArrayValues(byteArr, size) |
| 30 | reader := bitreader.BitReader(byteArr) | 23 | reader := bitreader.BitReader(reversedByteArr) |
| 31 | flag, err := reader.ReadBit() | 24 | if size-1 >= 4 { |
| 32 | utils.CheckError(err) | 25 | bit, err := reader.ReadBit() |
| 33 | fmt.Println(flag) | 26 | utils.CheckError(err) |
| 34 | flag2, err := reader.ReadBit() | 27 | if bit { |
| 35 | utils.CheckError(err) | 28 | value, err := reader.ReadBits(32) |
| 36 | fmt.Println(flag2) | 29 | utils.CheckError(err) |
| 37 | /*if size-1 >= 4 { | 30 | class.CommandNumber = int32(value) |
| 38 | class.CommandNumber = int32(utils.IntFromBytes(byteArr[:4])) | 31 | } else { |
| 32 | return class | ||
| 33 | } | ||
| 39 | } | 34 | } |
| 40 | if size-1 >= 8 { | 35 | if size-1 >= 8 { |
| 41 | class.TickCount = int32(utils.IntFromBytes(byteArr[4:8])) | 36 | bit, err := reader.ReadBit() |
| 37 | utils.CheckError(err) | ||
| 38 | if bit { | ||
| 39 | value, err := reader.ReadBits(32) | ||
| 40 | utils.CheckError(err) | ||
| 41 | class.TickCount = int32(value) | ||
| 42 | } else { | ||
| 43 | return class | ||
| 44 | } | ||
| 42 | } | 45 | } |
| 43 | if size-1 >= 12 { | 46 | if size-1 >= 12 { |
| 44 | class.ViewAnglesX = utils.FloatFromBytes(byteArr[8:12]) | 47 | bit, err := reader.ReadBit() |
| 48 | utils.CheckError(err) | ||
| 49 | if bit { | ||
| 50 | value, err := reader.ReadBits(32) | ||
| 51 | utils.CheckError(err) | ||
| 52 | class.ViewAnglesX = float32(value) | ||
| 53 | } else { | ||
| 54 | return class | ||
| 55 | } | ||
| 45 | } | 56 | } |
| 46 | if size-1 >= 16 { | 57 | if size-1 >= 16 { |
| 47 | class.ViewAnglesY = utils.FloatFromBytes(byteArr[12:16]) | 58 | bit, err := reader.ReadBit() |
| 59 | utils.CheckError(err) | ||
| 60 | if bit { | ||
| 61 | value, err := reader.ReadBits(32) | ||
| 62 | utils.CheckError(err) | ||
| 63 | class.ViewAnglesY = float32(value) | ||
| 64 | } else { | ||
| 65 | return class | ||
| 66 | } | ||
| 48 | } | 67 | } |
| 49 | if size-1 >= 20 { | 68 | if size-1 >= 20 { |
| 50 | class.ViewAnglesZ = utils.FloatFromBytes(byteArr[16:20]) | 69 | bit, err := reader.ReadBit() |
| 70 | utils.CheckError(err) | ||
| 71 | if bit { | ||
| 72 | value, err := reader.ReadBits(32) | ||
| 73 | utils.CheckError(err) | ||
| 74 | class.ViewAnglesZ = float32(value) | ||
| 75 | } else { | ||
| 76 | return class | ||
| 77 | } | ||
| 51 | } | 78 | } |
| 52 | if size-1 >= 24 { | 79 | if size-1 >= 24 { |
| 53 | class.ForwardMove = utils.FloatFromBytes(byteArr[20:24]) | 80 | bit, err := reader.ReadBit() |
| 81 | utils.CheckError(err) | ||
| 82 | if bit { | ||
| 83 | value, err := reader.ReadBits(32) | ||
| 84 | utils.CheckError(err) | ||
| 85 | class.ForwardMove = float32(value) | ||
| 86 | } else { | ||
| 87 | return class | ||
| 88 | } | ||
| 54 | } | 89 | } |
| 55 | if size-1 >= 28 { | 90 | if size-1 >= 28 { |
| 56 | class.SideMove = utils.FloatFromBytes(byteArr[24:28]) | 91 | bit, err := reader.ReadBit() |
| 92 | utils.CheckError(err) | ||
| 93 | if bit { | ||
| 94 | value, err := reader.ReadBits(32) | ||
| 95 | utils.CheckError(err) | ||
| 96 | class.SideMove = float32(value) | ||
| 97 | } else { | ||
| 98 | return class | ||
| 99 | } | ||
| 57 | } | 100 | } |
| 58 | if size-1 >= 32 { | 101 | if size-1 >= 32 { |
| 59 | class.UpMove = utils.FloatFromBytes(byteArr[28:32]) | 102 | bit, err := reader.ReadBit() |
| 103 | utils.CheckError(err) | ||
| 104 | if bit { | ||
| 105 | value, err := reader.ReadBits(32) | ||
| 106 | utils.CheckError(err) | ||
| 107 | class.UpMove = float32(value) | ||
| 108 | } else { | ||
| 109 | return class | ||
| 110 | } | ||
| 60 | } | 111 | } |
| 61 | if size-1 >= 36 { | ||
| 62 | class.Buttons = int32(utils.IntFromBytes(byteArr[32:36])) | ||
| 63 | } | ||
| 64 | if size-1 >= 40 { | ||
| 65 | class.Impulse = byteArr[36] | ||
| 66 | }*/ | ||
| 67 | return class | 112 | return class |
| 68 | } | 113 | } |