diff options
Diffstat (limited to 'pkg/classes/customData.go')
| -rw-r--r-- | pkg/classes/customData.go | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/pkg/classes/customData.go b/pkg/classes/customData.go index 1d6f30a..4c1a79e 100644 --- a/pkg/classes/customData.go +++ b/pkg/classes/customData.go | |||
| @@ -2,29 +2,30 @@ package classes | |||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "github.com/pektezol/bitreader" | 4 | "github.com/pektezol/bitreader" |
| 5 | "github.com/pektezol/sdp.go/pkg/writer" | 5 | "github.com/pektezol/sdp.go/pkg/types" |
| 6 | ) | 6 | ) |
| 7 | 7 | ||
| 8 | type CustomData struct { | 8 | type CustomData struct { |
| 9 | Type int32 | 9 | Type int32 `json:"type"` |
| 10 | Size int32 | 10 | Size int32 `json:"size"` |
| 11 | Data string | 11 | Data any `json:"data"` |
| 12 | } | 12 | } |
| 13 | 13 | ||
| 14 | func (customData *CustomData) ParseCustomData(reader *bitreader.Reader, tickNumber int32, packetType uint8) { | 14 | func (customData *CustomData) ParseCustomData(reader *bitreader.Reader, tickNumber int32, packetType uint8, demo *types.Demo) { |
| 15 | customData.Type = reader.TryReadSInt32() | 15 | customData.Type = reader.TryReadSInt32() |
| 16 | customData.Size = reader.TryReadSInt32() | 16 | customData.Size = reader.TryReadSInt32() |
| 17 | if customData.Type != 0 || customData.Size == 8 { | 17 | if customData.Type != 0 || customData.Size == 8 { |
| 18 | // Not SAR data | 18 | // Not SAR data |
| 19 | writer.AppendLine("[%d] %s (%d):", tickNumber, "CUSTOMDATA", packetType) | 19 | demo.Writer.AppendLine("[%d] %s (%d):", tickNumber, "CUSTOMDATA", packetType) |
| 20 | customData.Data = string(reader.TryReadBytesToSlice(uint64(customData.Size))) | 20 | customData.Data = string(reader.TryReadBytesToSlice(uint64(customData.Size))) |
| 21 | writer.AppendLine("\t%s", customData.Data) | 21 | demo.Writer.AppendLine("\t%s", customData.Data) |
| 22 | return | 22 | return |
| 23 | } | 23 | } |
| 24 | // SAR data | 24 | // SAR data |
| 25 | writer.AppendLine("[%d] %s (%d):", tickNumber, "SARDATA", packetType) | 25 | demo.Writer.AppendLine("[%d] %s (%d):", tickNumber, "SARDATA", packetType) |
| 26 | sarData := SarData{} | 26 | sarData := SarData{} |
| 27 | data := reader.TryReadBytesToSlice(uint64(customData.Size)) | 27 | data := reader.TryReadBytesToSlice(uint64(customData.Size)) |
| 28 | sarReader := bitreader.NewReaderFromBytes(data, true) | 28 | sarReader := bitreader.NewReaderFromBytes(data, true) |
| 29 | sarData.ParseSarData(sarReader) | 29 | sarData.ParseSarData(sarReader, demo) |
| 30 | customData.Data = sarData | ||
| 30 | } | 31 | } |