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/stringTable.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 '')
| -rw-r--r-- | pkg/classes/stringTables.go (renamed from pkg/classes/stringTable.go) | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/pkg/classes/stringTable.go b/pkg/classes/stringTables.go index 44d8a73..01939b2 100644 --- a/pkg/classes/stringTable.go +++ b/pkg/classes/stringTables.go | |||
| @@ -5,6 +5,11 @@ import ( | |||
| 5 | "github.com/pektezol/demoparser/pkg/writer" | 5 | "github.com/pektezol/demoparser/pkg/writer" |
| 6 | ) | 6 | ) |
| 7 | 7 | ||
| 8 | type StringTables struct { | ||
| 9 | Size int32 | ||
| 10 | Data []StringTable | ||
| 11 | } | ||
| 12 | |||
| 8 | type StringTable struct { | 13 | type StringTable struct { |
| 9 | Name string | 14 | Name string |
| 10 | TableEntries []StringTableEntry | 15 | TableEntries []StringTableEntry |
| @@ -25,15 +30,17 @@ type StringTableClass struct { | |||
| 25 | Data string | 30 | Data string |
| 26 | } | 31 | } |
| 27 | 32 | ||
| 28 | func ParseStringTables(reader *bitreader.Reader) []StringTable { | 33 | func (stringTables *StringTables) ParseStringTables(reader *bitreader.Reader) { |
| 29 | tableCount := reader.TryReadBits(8) | 34 | stringTables.Size = reader.TryReadSInt32() |
| 30 | stringTables := make([]StringTable, tableCount) | 35 | stringTableReader := bitreader.NewReaderFromBytes(reader.TryReadBytesToSlice(uint64(stringTables.Size)), true) |
| 36 | tableCount := stringTableReader.TryReadBits(8) | ||
| 37 | tables := make([]StringTable, tableCount) | ||
| 31 | for i := 0; i < int(tableCount); i++ { | 38 | for i := 0; i < int(tableCount); i++ { |
| 32 | var table StringTable | 39 | var table StringTable |
| 33 | table.ParseStream(reader) | 40 | table.ParseStream(stringTableReader) |
| 34 | stringTables[i] = table | 41 | tables[i] = table |
| 35 | } | 42 | } |
| 36 | return stringTables | 43 | stringTables.Data = tables |
| 37 | } | 44 | } |
| 38 | 45 | ||
| 39 | func (stringTable *StringTable) ParseStream(reader *bitreader.Reader) { | 46 | func (stringTable *StringTable) ParseStream(reader *bitreader.Reader) { |