diff options
| author | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2023-09-21 01:53:59 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-21 01:53:59 +0300 |
| commit | 171e350e348afadb55967b9c13d5eadc7f7d2cf4 (patch) | |
| tree | 14ec93df8ccc1aca0cf453f826d46a402b09dc8f /pkg/classes/stringTable.go | |
| parent | define todos on packets (diff) | |
| download | sdp.go-171e350e348afadb55967b9c13d5eadc7f7d2cf4.tar.gz sdp.go-171e350e348afadb55967b9c13d5eadc7f7d2cf4.tar.bz2 sdp.go-171e350e348afadb55967b9c13d5eadc7f7d2cf4.zip | |
add strings builder, customize ALL outputs (#6)
Diffstat (limited to 'pkg/classes/stringTable.go')
| -rw-r--r-- | pkg/classes/stringTable.go | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/pkg/classes/stringTable.go b/pkg/classes/stringTable.go index 3983c1f..44d8a73 100644 --- a/pkg/classes/stringTable.go +++ b/pkg/classes/stringTable.go | |||
| @@ -2,6 +2,7 @@ package classes | |||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "github.com/pektezol/bitreader" | 4 | "github.com/pektezol/bitreader" |
| 5 | "github.com/pektezol/demoparser/pkg/writer" | ||
| 5 | ) | 6 | ) |
| 6 | 7 | ||
| 7 | type StringTable struct { | 8 | type StringTable struct { |
| @@ -38,6 +39,7 @@ func ParseStringTables(reader *bitreader.Reader) []StringTable { | |||
| 38 | func (stringTable *StringTable) ParseStream(reader *bitreader.Reader) { | 39 | func (stringTable *StringTable) ParseStream(reader *bitreader.Reader) { |
| 39 | stringTable.Name = reader.TryReadString() | 40 | stringTable.Name = reader.TryReadString() |
| 40 | entryCount := reader.TryReadBits(16) | 41 | entryCount := reader.TryReadBits(16) |
| 42 | writer.AppendLine("\tTable Name: %s", stringTable.Name) | ||
| 41 | stringTable.TableEntries = make([]StringTableEntry, entryCount) | 43 | stringTable.TableEntries = make([]StringTableEntry, entryCount) |
| 42 | 44 | ||
| 43 | for i := 0; i < int(entryCount); i++ { | 45 | for i := 0; i < int(entryCount); i++ { |
| @@ -45,7 +47,12 @@ func (stringTable *StringTable) ParseStream(reader *bitreader.Reader) { | |||
| 45 | entry.Parse(reader) | 47 | entry.Parse(reader) |
| 46 | stringTable.TableEntries[i] = entry | 48 | stringTable.TableEntries[i] = entry |
| 47 | } | 49 | } |
| 48 | 50 | if entryCount != 0 { | |
| 51 | writer.AppendLine("\t\t%d Table Entries:", entryCount) | ||
| 52 | writer.AppendOutputFromTemp() | ||
| 53 | } else { | ||
| 54 | writer.AppendLine("\t\tNo Table Entries") | ||
| 55 | } | ||
| 49 | if reader.TryReadBool() { | 56 | if reader.TryReadBool() { |
| 50 | classCount := reader.TryReadBits(16) | 57 | classCount := reader.TryReadBits(16) |
| 51 | stringTable.Classes = make([]StringTableClass, classCount) | 58 | stringTable.Classes = make([]StringTableClass, classCount) |
| @@ -55,6 +62,10 @@ func (stringTable *StringTable) ParseStream(reader *bitreader.Reader) { | |||
| 55 | class.Parse(reader) | 62 | class.Parse(reader) |
| 56 | stringTable.Classes[i] = class | 63 | stringTable.Classes[i] = class |
| 57 | } | 64 | } |
| 65 | writer.AppendLine("\t\t%d Classes:", classCount) | ||
| 66 | writer.AppendOutputFromTemp() | ||
| 67 | } else { | ||
| 68 | writer.AppendLine("\t\tNo Class Entries") | ||
| 58 | } | 69 | } |
| 59 | } | 70 | } |
| 60 | 71 | ||
| @@ -73,8 +84,10 @@ func (stringTableEntry *StringTableEntry) Parse(reader *bitreader.Reader) { | |||
| 73 | 84 | ||
| 74 | func (stringTableClass *StringTableClass) Parse(reader *bitreader.Reader) { | 85 | func (stringTableClass *StringTableClass) Parse(reader *bitreader.Reader) { |
| 75 | stringTableClass.Name = reader.TryReadString() | 86 | stringTableClass.Name = reader.TryReadString() |
| 87 | writer.TempAppendLine("\t\t\tName: %s", stringTableClass.Name) | ||
| 76 | if reader.TryReadBool() { | 88 | if reader.TryReadBool() { |
| 77 | dataLen := reader.TryReadBits(16) | 89 | dataLen := reader.TryReadBits(16) |
| 78 | stringTableClass.Data = reader.TryReadStringLength(dataLen) | 90 | stringTableClass.Data = reader.TryReadStringLength(dataLen) |
| 91 | writer.TempAppendLine("\t\t\tData: %s", stringTableClass.Data) | ||
| 79 | } | 92 | } |
| 80 | } | 93 | } |