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/customData.go | |
| parent | add strings builder, customize ALL outputs (#6) (diff) | |
| download | sdp.go-1.1.1.tar.gz sdp.go-1.1.1.tar.bz2 sdp.go-1.1.1.zip | |
organize packets and classes (#9)v1.1.1
Diffstat (limited to 'pkg/classes/customData.go')
| -rw-r--r-- | pkg/classes/customData.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/pkg/classes/customData.go b/pkg/classes/customData.go new file mode 100644 index 0000000..2dadde4 --- /dev/null +++ b/pkg/classes/customData.go | |||
| @@ -0,0 +1,30 @@ | |||
| 1 | package classes | ||
| 2 | |||
| 3 | import ( | ||
| 4 | "github.com/pektezol/bitreader" | ||
| 5 | "github.com/pektezol/demoparser/pkg/writer" | ||
| 6 | ) | ||
| 7 | |||
| 8 | type CustomData struct { | ||
| 9 | Type int32 | ||
| 10 | Size int32 | ||
| 11 | Data string | ||
| 12 | } | ||
| 13 | |||
| 14 | func (customData *CustomData) ParseCustomData(reader *bitreader.Reader, tickNumber int32, packetType uint8) { | ||
| 15 | customData.Type = reader.TryReadSInt32() | ||
| 16 | customData.Size = reader.TryReadSInt32() | ||
| 17 | if customData.Type != 0 || customData.Size == 8 { | ||
| 18 | // Not SAR data | ||
| 19 | writer.AppendLine("[%d] %s (%d):", tickNumber, "CUSTOMDATA", packetType) | ||
| 20 | customData.Data = string(reader.TryReadBytesToSlice(uint64(customData.Size))) | ||
| 21 | writer.AppendLine("\t%s", customData.Data) | ||
| 22 | return | ||
| 23 | } | ||
| 24 | // SAR data | ||
| 25 | writer.AppendLine("[%d] %s (%d):", tickNumber, "SARDATA", packetType) | ||
| 26 | sarData := SarData{} | ||
| 27 | data := reader.TryReadBytesToSlice(uint64(customData.Size)) | ||
| 28 | sarReader := bitreader.NewReaderFromBytes(data, true) | ||
| 29 | sarData.ParseSarData(sarReader) | ||
| 30 | } | ||