diff options
| author | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2023-11-06 18:37:11 +0300 |
|---|---|---|
| committer | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2023-11-06 18:37:11 +0300 |
| commit | 2f8c92f261586f68a976efce0cfcdd0401f402e0 (patch) | |
| tree | 33189cc48987789dff4e7fba0a74d2b2326f0a04 /pkg/classes/stringTables.go | |
| parent | convert cm ticks correctly (diff) | |
| download | sdp.go-lp-parser.tar.gz sdp.go-lp-parser.tar.bz2 sdp.go-lp-parser.zip | |
dont try to understand it, feel itlp-parser
Diffstat (limited to '')
| -rw-r--r-- | pkg/classes/stringTables.go | 86 |
1 files changed, 0 insertions, 86 deletions
diff --git a/pkg/classes/stringTables.go b/pkg/classes/stringTables.go deleted file mode 100644 index 45954be..0000000 --- a/pkg/classes/stringTables.go +++ /dev/null | |||
| @@ -1,86 +0,0 @@ | |||
| 1 | package classes | ||
| 2 | |||
| 3 | import ( | ||
| 4 | "github.com/pektezol/bitreader" | ||
| 5 | ) | ||
| 6 | |||
| 7 | type StringTables struct { | ||
| 8 | Size int32 | ||
| 9 | Data []StringTable | ||
| 10 | } | ||
| 11 | |||
| 12 | type StringTable struct { | ||
| 13 | Name string | ||
| 14 | TableEntries []StringTableEntry | ||
| 15 | Classes []StringTableClass | ||
| 16 | } | ||
| 17 | |||
| 18 | type StringTableEntry struct { | ||
| 19 | Name string | ||
| 20 | EntryData StringTableEntryData | ||
| 21 | } | ||
| 22 | |||
| 23 | type StringTableEntryData struct { | ||
| 24 | // TODO: Parse StringTableEntry | ||
| 25 | } | ||
| 26 | |||
| 27 | type StringTableClass struct { | ||
| 28 | Name string | ||
| 29 | Data string | ||
| 30 | } | ||
| 31 | |||
| 32 | func (stringTables *StringTables) ParseStringTables(reader *bitreader.Reader) { | ||
| 33 | stringTables.Size = reader.TryReadSInt32() | ||
| 34 | stringTableReader := bitreader.NewReaderFromBytes(reader.TryReadBytesToSlice(uint64(stringTables.Size)), true) | ||
| 35 | tableCount := stringTableReader.TryReadBits(8) | ||
| 36 | tables := make([]StringTable, tableCount) | ||
| 37 | for i := 0; i < int(tableCount); i++ { | ||
| 38 | var table StringTable | ||
| 39 | table.ParseStream(stringTableReader) | ||
| 40 | tables[i] = table | ||
| 41 | } | ||
| 42 | stringTables.Data = tables | ||
| 43 | } | ||
| 44 | |||
| 45 | func (stringTable *StringTable) ParseStream(reader *bitreader.Reader) { | ||
| 46 | stringTable.Name = reader.TryReadString() | ||
| 47 | entryCount := reader.TryReadBits(16) | ||
| 48 | stringTable.TableEntries = make([]StringTableEntry, entryCount) | ||
| 49 | |||
| 50 | for i := 0; i < int(entryCount); i++ { | ||
| 51 | var entry StringTableEntry | ||
| 52 | entry.Parse(reader) | ||
| 53 | stringTable.TableEntries[i] = entry | ||
| 54 | } | ||
| 55 | if reader.TryReadBool() { | ||
| 56 | classCount := reader.TryReadBits(16) | ||
| 57 | stringTable.Classes = make([]StringTableClass, classCount) | ||
| 58 | |||
| 59 | for i := 0; i < int(classCount); i++ { | ||
| 60 | var class StringTableClass | ||
| 61 | class.Parse(reader) | ||
| 62 | stringTable.Classes[i] = class | ||
| 63 | } | ||
| 64 | } | ||
| 65 | } | ||
| 66 | |||
| 67 | func (stringTableEntry *StringTableEntry) Parse(reader *bitreader.Reader) { | ||
| 68 | stringTableEntry.Name = reader.TryReadString() | ||
| 69 | if reader.TryReadBool() { | ||
| 70 | byteLen, err := reader.ReadBits(16) | ||
| 71 | if err != nil { | ||
| 72 | return | ||
| 73 | } | ||
| 74 | dataBsr := reader.TryReadBytesToSlice(byteLen) | ||
| 75 | _ = bitreader.NewReaderFromBytes(dataBsr, true) // TODO: Parse StringTableEntry | ||
| 76 | // stringTableEntry.EntryData.ParseStream(entryReader) | ||
| 77 | } | ||
| 78 | } | ||
| 79 | |||
| 80 | func (stringTableClass *StringTableClass) Parse(reader *bitreader.Reader) { | ||
| 81 | stringTableClass.Name = reader.TryReadString() | ||
| 82 | if reader.TryReadBool() { | ||
| 83 | dataLen := reader.TryReadBits(16) | ||
| 84 | stringTableClass.Data = reader.TryReadStringLength(dataLen) | ||
| 85 | } | ||
| 86 | } | ||