diff options
| author | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2023-09-21 19:26:40 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-21 19:26:40 +0300 |
| commit | 44eefefe67a4a5f514faa4594370346fd1b54996 (patch) | |
| tree | a8853a8ecd49ddbb87c6cc19904ec6bb5419ee83 /pkg/classes/userCmdInfo.go | |
| parent | add strings builder, customize ALL outputs (#6) (diff) | |
| download | sdp.go-44eefefe67a4a5f514faa4594370346fd1b54996.tar.gz sdp.go-44eefefe67a4a5f514faa4594370346fd1b54996.tar.bz2 sdp.go-44eefefe67a4a5f514faa4594370346fd1b54996.zip | |
organize packets and classes (#9)v1.1.1
Diffstat (limited to 'pkg/classes/userCmdInfo.go')
| -rw-r--r-- | pkg/classes/userCmdInfo.go | 87 |
1 files changed, 0 insertions, 87 deletions
diff --git a/pkg/classes/userCmdInfo.go b/pkg/classes/userCmdInfo.go deleted file mode 100644 index f1bb613..0000000 --- a/pkg/classes/userCmdInfo.go +++ /dev/null | |||
| @@ -1,87 +0,0 @@ | |||
| 1 | package classes | ||
| 2 | |||
| 3 | import ( | ||
| 4 | "bytes" | ||
| 5 | |||
| 6 | "github.com/pektezol/bitreader" | ||
| 7 | "github.com/pektezol/demoparser/pkg/writer" | ||
| 8 | ) | ||
| 9 | |||
| 10 | type UserCmdInfo struct { | ||
| 11 | CommandNumber int32 | ||
| 12 | TickCount int32 | ||
| 13 | ViewAnglesX float32 | ||
| 14 | ViewAnglesY float32 | ||
| 15 | ViewAnglesZ float32 | ||
| 16 | ForwardMove float32 | ||
| 17 | SideMove float32 | ||
| 18 | UpMove float32 | ||
| 19 | Buttons int32 | ||
| 20 | Impulse int8 | ||
| 21 | WeaponSelect int16 | ||
| 22 | WeaponSubType int8 | ||
| 23 | MouseDx int16 | ||
| 24 | MouseDy int16 | ||
| 25 | } | ||
| 26 | |||
| 27 | func ParseUserCmdInfo(data []byte) UserCmdInfo { | ||
| 28 | reader := bitreader.NewReader(bytes.NewReader(data), true) | ||
| 29 | userCmdInfo := UserCmdInfo{} | ||
| 30 | if reader.TryReadBool() { | ||
| 31 | userCmdInfo.CommandNumber = int32(reader.TryReadBits(32)) | ||
| 32 | } | ||
| 33 | if reader.TryReadBool() { | ||
| 34 | userCmdInfo.TickCount = int32(reader.TryReadBits(32)) | ||
| 35 | } | ||
| 36 | if reader.TryReadBool() { | ||
| 37 | userCmdInfo.ViewAnglesX = reader.TryReadFloat32() | ||
| 38 | } | ||
| 39 | if reader.TryReadBool() { | ||
| 40 | userCmdInfo.ViewAnglesY = reader.TryReadFloat32() | ||
| 41 | } | ||
| 42 | if reader.TryReadBool() { | ||
| 43 | userCmdInfo.ViewAnglesZ = reader.TryReadFloat32() | ||
| 44 | } | ||
| 45 | if reader.TryReadBool() { | ||
| 46 | userCmdInfo.ForwardMove = reader.TryReadFloat32() | ||
| 47 | } | ||
| 48 | if reader.TryReadBool() { | ||
| 49 | userCmdInfo.SideMove = reader.TryReadFloat32() | ||
| 50 | } | ||
| 51 | if reader.TryReadBool() { | ||
| 52 | userCmdInfo.UpMove = reader.TryReadFloat32() | ||
| 53 | } | ||
| 54 | if reader.TryReadBool() { | ||
| 55 | userCmdInfo.Buttons = int32(reader.TryReadBits(32)) | ||
| 56 | } | ||
| 57 | if reader.TryReadBool() { | ||
| 58 | userCmdInfo.Impulse = int8(reader.TryReadBits(8)) | ||
| 59 | } | ||
| 60 | if reader.TryReadBool() { | ||
| 61 | userCmdInfo.WeaponSelect = int16(reader.TryReadBits(11)) | ||
| 62 | if reader.TryReadBool() { | ||
| 63 | userCmdInfo.WeaponSubType = int8(reader.TryReadBits(6)) | ||
| 64 | } | ||
| 65 | } | ||
| 66 | if reader.TryReadBool() { | ||
| 67 | userCmdInfo.MouseDx = int16(reader.TryReadBits(16)) | ||
| 68 | } | ||
| 69 | if reader.TryReadBool() { | ||
| 70 | userCmdInfo.MouseDy = int16(reader.TryReadBits(16)) | ||
| 71 | } | ||
| 72 | writer.AppendLine("\tCommand Number: %v", userCmdInfo.CommandNumber) | ||
| 73 | writer.AppendLine("\tTick Count: %v", userCmdInfo.TickCount) | ||
| 74 | writer.AppendLine("\tView Angles X: %v", userCmdInfo.ViewAnglesX) | ||
| 75 | writer.AppendLine("\tView Angles Y: %v", userCmdInfo.ViewAnglesY) | ||
| 76 | writer.AppendLine("\tView Angles Z: %v", userCmdInfo.ViewAnglesZ) | ||
| 77 | writer.AppendLine("\tForward Move: %v", userCmdInfo.ForwardMove) | ||
| 78 | writer.AppendLine("\tSide Move: %v", userCmdInfo.SideMove) | ||
| 79 | writer.AppendLine("\tUp Move: %v", userCmdInfo.UpMove) | ||
| 80 | writer.AppendLine("\tButtons: %v", userCmdInfo.Buttons) | ||
| 81 | writer.AppendLine("\tImpulse: %v", userCmdInfo.Impulse) | ||
| 82 | writer.AppendLine("\tWeapon Select: %v", userCmdInfo.WeaponSelect) | ||
| 83 | writer.AppendLine("\tWeapon Sub Type: %v", userCmdInfo.WeaponSubType) | ||
| 84 | writer.AppendLine("\tMouse Dx: %v", userCmdInfo.MouseDx) | ||
| 85 | writer.AppendLine("\tMouse Dy: %v", userCmdInfo.MouseDy) | ||
| 86 | return userCmdInfo | ||
| 87 | } | ||