diff options
Diffstat (limited to 'classes')
| -rw-r--r-- | classes/classes.go | 199 | ||||
| -rw-r--r-- | classes/netsvc/netsvc.go | 32 | ||||
| -rw-r--r-- | classes/netsvc/types.go | 106 | ||||
| -rw-r--r-- | classes/types.go | 60 |
4 files changed, 0 insertions, 397 deletions
diff --git a/classes/classes.go b/classes/classes.go deleted file mode 100644 index 4d6acb0..0000000 --- a/classes/classes.go +++ /dev/null | |||
| @@ -1,199 +0,0 @@ | |||
| 1 | package classes | ||
| 2 | |||
| 3 | import ( | ||
| 4 | "encoding/binary" | ||
| 5 | "os" | ||
| 6 | |||
| 7 | "github.com/pektezol/bitreader" | ||
| 8 | "github.com/pektezol/demoparser/utils" | ||
| 9 | ) | ||
| 10 | |||
| 11 | func ParseCmdInfo(file *os.File, MSSC int) []CmdInfo { | ||
| 12 | array := utils.ReadByteFromFile(file, 76*int32(MSSC)) | ||
| 13 | var cmdinfoarray []CmdInfo | ||
| 14 | for count := 0; count < MSSC; count++ { | ||
| 15 | var cmdinfo CmdInfo | ||
| 16 | cmdinfo.Flags = int32(binary.LittleEndian.Uint32(array[0+76*count : 4+76*count])) | ||
| 17 | cmdinfo.ViewOrigin = utils.FloatArrFromBytes(array[4+76*count : 16+76*count]) | ||
| 18 | cmdinfo.ViewAngles = utils.FloatArrFromBytes(array[16+76*count : 28+76*count]) | ||
| 19 | cmdinfo.LocalViewAngles = utils.FloatArrFromBytes(array[28+76*count : 40+76*count]) | ||
| 20 | cmdinfo.ViewOrigin2 = utils.FloatArrFromBytes(array[40+76*count : 52+76*count]) | ||
| 21 | cmdinfo.ViewAngles2 = utils.FloatArrFromBytes(array[52+76*count : 64+76*count]) | ||
| 22 | cmdinfo.LocalViewAngles2 = utils.FloatArrFromBytes(array[64+76*count : 76+76*count]) | ||
| 23 | cmdinfoarray = append(cmdinfoarray, cmdinfo) | ||
| 24 | } | ||
| 25 | return cmdinfoarray | ||
| 26 | } | ||
| 27 | |||
| 28 | func ParseUserCmdInfo(file *os.File, size int) UserCmdInfo { | ||
| 29 | reader := bitreader.Reader(file, true) | ||
| 30 | var usercmd UserCmdInfo | ||
| 31 | count := 0 | ||
| 32 | flag, err := reader.ReadBool() | ||
| 33 | utils.CheckError(err) | ||
| 34 | if flag { | ||
| 35 | usercmd.CommandNumber = int32(reader.TryReadInt32()) | ||
| 36 | count += 32 | ||
| 37 | } | ||
| 38 | count++ | ||
| 39 | flag, err = reader.ReadBool() | ||
| 40 | utils.CheckError(err) | ||
| 41 | if flag { | ||
| 42 | usercmd.TickCount = int32(reader.TryReadInt32()) | ||
| 43 | count += 32 | ||
| 44 | } | ||
| 45 | count++ | ||
| 46 | flag, err = reader.ReadBool() | ||
| 47 | utils.CheckError(err) | ||
| 48 | if flag { | ||
| 49 | usercmd.ViewAnglesX = reader.TryReadFloat32() | ||
| 50 | count += 32 | ||
| 51 | } | ||
| 52 | count++ | ||
| 53 | flag, err = reader.ReadBool() | ||
| 54 | utils.CheckError(err) | ||
| 55 | if flag { | ||
| 56 | usercmd.ViewAnglesY = reader.TryReadFloat32() | ||
| 57 | count += 32 | ||
| 58 | } | ||
| 59 | count++ | ||
| 60 | flag, err = reader.ReadBool() | ||
| 61 | utils.CheckError(err) | ||
| 62 | if flag { | ||
| 63 | usercmd.ViewAnglesZ = reader.TryReadFloat32() | ||
| 64 | count += 32 | ||
| 65 | } | ||
| 66 | count++ | ||
| 67 | flag, err = reader.ReadBool() | ||
| 68 | utils.CheckError(err) | ||
| 69 | if flag { | ||
| 70 | usercmd.ForwardMove = reader.TryReadFloat32() | ||
| 71 | count += 32 | ||
| 72 | } | ||
| 73 | count++ | ||
| 74 | flag, err = reader.ReadBool() | ||
| 75 | utils.CheckError(err) | ||
| 76 | if flag { | ||
| 77 | usercmd.SideMove = reader.TryReadFloat32() | ||
| 78 | count += 32 | ||
| 79 | } | ||
| 80 | count++ | ||
| 81 | flag, err = reader.ReadBool() | ||
| 82 | utils.CheckError(err) | ||
| 83 | if flag { | ||
| 84 | usercmd.UpMove = reader.TryReadFloat32() | ||
| 85 | count += 32 | ||
| 86 | } | ||
| 87 | count++ | ||
| 88 | flag, err = reader.ReadBool() | ||
| 89 | utils.CheckError(err) | ||
| 90 | if flag { | ||
| 91 | usercmd.Buttons = int32(reader.TryReadInt32()) | ||
| 92 | count += 32 | ||
| 93 | } | ||
| 94 | count++ | ||
| 95 | flag, err = reader.ReadBool() | ||
| 96 | utils.CheckError(err) | ||
| 97 | if flag { | ||
| 98 | //reader.SkipBits(8) | ||
| 99 | usercmd.Impulse = int8(reader.TryReadInt8()) | ||
| 100 | count += 8 | ||
| 101 | } | ||
| 102 | count++ | ||
| 103 | flag, err = reader.ReadBool() | ||
| 104 | utils.CheckError(err) | ||
| 105 | if flag { | ||
| 106 | value, err := reader.ReadBits(11) | ||
| 107 | utils.CheckError(err) | ||
| 108 | usercmd.WeaponSelect = int(value) | ||
| 109 | flag, err = reader.ReadBool() | ||
| 110 | utils.CheckError(err) | ||
| 111 | count += 11 | ||
| 112 | if flag { | ||
| 113 | value, err := reader.ReadBits(6) | ||
| 114 | utils.CheckError(err) | ||
| 115 | usercmd.WeaponSubtype = int(value) | ||
| 116 | count += 6 | ||
| 117 | } | ||
| 118 | count++ | ||
| 119 | } | ||
| 120 | count++ | ||
| 121 | flag, err = reader.ReadBool() | ||
| 122 | utils.CheckError(err) | ||
| 123 | if flag { | ||
| 124 | usercmd.MouseDx = int16(reader.TryReadInt16()) | ||
| 125 | count += 16 | ||
| 126 | } | ||
| 127 | count++ | ||
| 128 | flag, err = reader.ReadBool() | ||
| 129 | utils.CheckError(err) | ||
| 130 | if flag { | ||
| 131 | usercmd.MouseDy = int16(reader.TryReadInt16()) | ||
| 132 | count += 16 | ||
| 133 | } | ||
| 134 | count++ | ||
| 135 | reader.SkipBits(size*8 - count) // Skip remaining bits from specified size | ||
| 136 | return usercmd | ||
| 137 | } | ||
| 138 | |||
| 139 | /*func ParseStringTable(file *os.File, size int) []StringTable { | ||
| 140 | reader := bitreader.Reader(file, true) | ||
| 141 | var stringtable StringTable | ||
| 142 | var stringtablearray []StringTable | ||
| 143 | //count := 0 | ||
| 144 | stringtable.NumOfTables = int8(reader.TryReadInt8()) | ||
| 145 | for i := 0; i < int(stringtable.NumOfTables); i++ { | ||
| 146 | stringtable.TableName = utils.ReadStringFromFile(file) | ||
| 147 | stringtable.NumOfEntries = int16(reader.TryReadInt16()) | ||
| 148 | stringtable.EntryName = utils.ReadStringFromFile(file) | ||
| 149 | flag, err := reader.ReadBool() | ||
| 150 | utils.CheckError(err) | ||
| 151 | if flag { | ||
| 152 | stringtable.EntrySize = int16(reader.TryReadInt16()) | ||
| 153 | } | ||
| 154 | flag, err = reader.ReadBool() | ||
| 155 | utils.CheckError(err) | ||
| 156 | if flag { | ||
| 157 | fmt.Println(int(stringtable.EntrySize)) | ||
| 158 | reader.SkipBytes(int(stringtable.EntrySize)) | ||
| 159 | var bytearray []byte | ||
| 160 | for i := 0; i < int(stringtable.EntrySize); i++ { | ||
| 161 | value, err := reader.ReadBytes(1) | ||
| 162 | utils.CheckError(err) | ||
| 163 | bytearray = append(bytearray, byte(value)) | ||
| 164 | } | ||
| 165 | stringtable.EntryData = bytearrray | ||
| 166 | } | ||
| 167 | flag, err = reader.ReadBool() | ||
| 168 | utils.CheckError(err) | ||
| 169 | if flag { | ||
| 170 | stringtable.NumOfClientEntries = int16(reader.TryReadInt16()) | ||
| 171 | } | ||
| 172 | flag, err = reader.ReadBool() | ||
| 173 | utils.CheckError(err) | ||
| 174 | if flag { | ||
| 175 | stringtable.ClientEntryName = utils.ReadStringFromFile(file) | ||
| 176 | } | ||
| 177 | flag, err = reader.ReadBool() | ||
| 178 | utils.CheckError(err) | ||
| 179 | if flag { | ||
| 180 | stringtable.ClientEntrySize = int16(reader.TryReadInt16()) | ||
| 181 | } | ||
| 182 | flag, err = reader.ReadBool() | ||
| 183 | utils.CheckError(err) | ||
| 184 | if flag { | ||
| 185 | reader.SkipBytes(int(stringtable.ClientEntrySize)) | ||
| 186 | /*var bytearray []byte | ||
| 187 | for i := 0; i < int(stringtable.ClientEntrySize); i++ { | ||
| 188 | value, err := reader.ReadBytes(1) | ||
| 189 | utils.CheckError(err) | ||
| 190 | bytearray = append(bytearray, byte(value)) | ||
| 191 | } | ||
| 192 | stringtable.ClientEntryData = bytearrray | ||
| 193 | } | ||
| 194 | stringtablearray = append(stringtablearray, stringtable) | ||
| 195 | } | ||
| 196 | |||
| 197 | //reader.SkipBits(size*8 - 8) | ||
| 198 | return stringtablearray | ||
| 199 | }*/ | ||
diff --git a/classes/netsvc/netsvc.go b/classes/netsvc/netsvc.go deleted file mode 100644 index a454310..0000000 --- a/classes/netsvc/netsvc.go +++ /dev/null | |||
| @@ -1,32 +0,0 @@ | |||
| 1 | package netsvc | ||
| 2 | |||
| 3 | import ( | ||
| 4 | "bytes" | ||
| 5 | "fmt" | ||
| 6 | |||
| 7 | "github.com/pektezol/bitreader" | ||
| 8 | "github.com/pektezol/demoparser/utils" | ||
| 9 | ) | ||
| 10 | |||
| 11 | const NET_TICK_SCALEUP = 10000 | ||
| 12 | |||
| 13 | func ParseNetSvcMessage(file []byte) { | ||
| 14 | reader := bitreader.Reader(bytes.NewReader(file), true) | ||
| 15 | bitsRead := 0 | ||
| 16 | for { | ||
| 17 | messageType, err := reader.ReadBits(6) | ||
| 18 | if err != nil { // No remaining bits left | ||
| 19 | break | ||
| 20 | } | ||
| 21 | switch messageType { | ||
| 22 | case 16: | ||
| 23 | var svcprint SvcPrint | ||
| 24 | svcprint.Message = utils.ReadStringFromSlice(file) | ||
| 25 | fmt.Println(svcprint) | ||
| 26 | bitsRead += len(svcprint.Message) * 8 | ||
| 27 | default: | ||
| 28 | //fmt.Println("default") | ||
| 29 | break | ||
| 30 | } | ||
| 31 | } | ||
| 32 | } | ||
diff --git a/classes/netsvc/types.go b/classes/netsvc/types.go deleted file mode 100644 index 2a52f96..0000000 --- a/classes/netsvc/types.go +++ /dev/null | |||
| @@ -1,106 +0,0 @@ | |||
| 1 | package netsvc | ||
| 2 | |||
| 3 | type NetDisconnect struct { | ||
| 4 | Text string | ||
| 5 | } | ||
| 6 | |||
| 7 | type NetFile struct { | ||
| 8 | TransferId int32 | ||
| 9 | FileName string | ||
| 10 | FileRequested bool | ||
| 11 | } | ||
| 12 | |||
| 13 | type NetSplitScreenUser struct { | ||
| 14 | Unknown bool | ||
| 15 | } | ||
| 16 | |||
| 17 | type NetTick struct { | ||
| 18 | Tick int32 | ||
| 19 | HostFrameTime int16 | ||
| 20 | HostFrameTimeStdDeviation int16 | ||
| 21 | } | ||
| 22 | |||
| 23 | type NetStringCmd struct { | ||
| 24 | Command string | ||
| 25 | } | ||
| 26 | |||
| 27 | type ConVar struct { | ||
| 28 | Name string | ||
| 29 | Value string | ||
| 30 | } | ||
| 31 | |||
| 32 | type NetSetConVar struct { | ||
| 33 | Length int8 | ||
| 34 | ConVars []ConVar | ||
| 35 | } | ||
| 36 | |||
| 37 | type NetSignonStateOE struct { | ||
| 38 | SignonState int8 | ||
| 39 | SpawnCount int32 | ||
| 40 | } | ||
| 41 | |||
| 42 | type NetSignonStateNE struct { | ||
| 43 | NetSignonStateOE | ||
| 44 | NumServerPlayers int32 | ||
| 45 | IdsLength int32 | ||
| 46 | PlayerNetworkIds []byte | ||
| 47 | MapNameLength int32 | ||
| 48 | MapName string | ||
| 49 | } | ||
| 50 | |||
| 51 | type SvcServerInfo struct { | ||
| 52 | Protocol int8 | ||
| 53 | ServerCount int32 | ||
| 54 | IsHltv bool | ||
| 55 | IsDedicated bool | ||
| 56 | ClientCrc int32 | ||
| 57 | MaxClasses int16 | ||
| 58 | MapCrc int32 | ||
| 59 | PlayerSlot int8 | ||
| 60 | MaxClients int8 | ||
| 61 | Unk int32 // NE | ||
| 62 | TickInterval float32 | ||
| 63 | COs byte | ||
| 64 | GameDir string | ||
| 65 | MapName string | ||
| 66 | SkyName string | ||
| 67 | HostName string | ||
| 68 | } | ||
| 69 | |||
| 70 | type SvcSendTable struct { | ||
| 71 | NeedsDecoder bool | ||
| 72 | Length int8 | ||
| 73 | Props int // ? | ||
| 74 | } | ||
| 75 | |||
| 76 | type ServerClass struct { | ||
| 77 | ClassId int8 | ||
| 78 | ClassName string | ||
| 79 | DataTableName string | ||
| 80 | } | ||
| 81 | |||
| 82 | type SvcClassInfo struct { | ||
| 83 | Length int16 | ||
| 84 | CreateOnClient bool | ||
| 85 | ServerClasses []ServerClass | ||
| 86 | } | ||
| 87 | |||
| 88 | type SvcSetPause struct { | ||
| 89 | Paused bool | ||
| 90 | } | ||
| 91 | |||
| 92 | type SvcCreateStringTable struct { | ||
| 93 | Name string | ||
| 94 | MaxEntries int16 | ||
| 95 | NumEntries int8 | ||
| 96 | Length int32 | ||
| 97 | UserDataFixedSize bool | ||
| 98 | UserDataSize int32 | ||
| 99 | UserDataSizeBits int8 | ||
| 100 | Flags int8 | ||
| 101 | StringData int // ? | ||
| 102 | } | ||
| 103 | |||
| 104 | type SvcPrint struct { | ||
| 105 | Message string | ||
| 106 | } | ||
diff --git a/classes/types.go b/classes/types.go deleted file mode 100644 index 20c793a..0000000 --- a/classes/types.go +++ /dev/null | |||
| @@ -1,60 +0,0 @@ | |||
| 1 | package classes | ||
| 2 | |||
| 3 | type CmdInfo struct { | ||
| 4 | Flags int32 | ||
| 5 | ViewOrigin []float32 | ||
| 6 | ViewAngles []float32 | ||
| 7 | LocalViewAngles []float32 | ||
| 8 | ViewOrigin2 []float32 | ||
| 9 | ViewAngles2 []float32 | ||
| 10 | LocalViewAngles2 []float32 | ||
| 11 | } | ||
| 12 | |||
| 13 | type UserCmdInfo struct { | ||
| 14 | CommandNumber int32 | ||
| 15 | TickCount int32 | ||
| 16 | ViewAnglesX float32 | ||
| 17 | ViewAnglesY float32 | ||
| 18 | ViewAnglesZ float32 | ||
| 19 | ForwardMove float32 | ||
| 20 | SideMove float32 | ||
| 21 | UpMove float32 | ||
| 22 | Buttons int32 | ||
| 23 | Impulse int8 | ||
| 24 | WeaponSelect int | ||
| 25 | WeaponSubtype int | ||
| 26 | MouseDx int16 | ||
| 27 | MouseDy int16 | ||
| 28 | } | ||
| 29 | |||
| 30 | type DataTables struct { | ||
| 31 | SendTable []SendTable | ||
| 32 | ServerClassInfo []ServerClassInfo | ||
| 33 | } | ||
| 34 | |||
| 35 | type SendTable struct { | ||
| 36 | NetTableName string | ||
| 37 | NumOfProps int | ||
| 38 | SendPropType int | ||
| 39 | SendPropName string | ||
| 40 | SendPropFlags int | ||
| 41 | } | ||
| 42 | |||
| 43 | type ServerClassInfo struct { | ||
| 44 | } | ||
| 45 | |||
| 46 | type StringTable struct { | ||
| 47 | NumOfTables int8 | ||
| 48 | TableName string | ||
| 49 | NumOfEntries int16 | ||
| 50 | EntryName string | ||
| 51 | EntrySize int16 | ||
| 52 | EntryData []byte | ||
| 53 | NumOfClientEntries int16 | ||
| 54 | ClientEntryName string | ||
| 55 | ClientEntrySize int16 | ||
| 56 | ClientEntryData []byte | ||
| 57 | } | ||
| 58 | |||
| 59 | type GameEvent struct { | ||
| 60 | } | ||