From 77e4b066cb8d506b4bc944ab4eb2d6e4679e2202 Mon Sep 17 00:00:00 2001 From: Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> Date: Sat, 15 Jun 2024 13:58:30 +0300 Subject: enable multithreading with goroutines (#20) --- pkg/packets/headers.go | 42 ++++++++++++++---------------------------- 1 file changed, 14 insertions(+), 28 deletions(-) (limited to 'pkg/packets/headers.go') diff --git a/pkg/packets/headers.go b/pkg/packets/headers.go index 6c5ab10..bee8ddf 100644 --- a/pkg/packets/headers.go +++ b/pkg/packets/headers.go @@ -2,25 +2,11 @@ package packets import ( "github.com/pektezol/bitreader" - "github.com/pektezol/sdp.go/pkg/writer" + "github.com/pektezol/sdp.go/pkg/types" ) -type Headers struct { - DemoFileStamp string - DemoProtocol int32 - NetworkProtocol int32 - ServerName string - ClientName string - MapName string - GameDirectory string - PlaybackTime float32 - PlaybackTicks int32 - PlaybackFrames int32 - SignOnLength int32 -} - -func ParseHeaders(reader *bitreader.Reader) Headers { - headers := Headers{ +func ParseHeaders(reader *bitreader.Reader, demo *types.Demo) types.Headers { + headers := types.Headers{ DemoFileStamp: reader.TryReadString(), DemoProtocol: int32(reader.TryReadSInt32()), NetworkProtocol: int32(reader.TryReadSInt32()), @@ -42,16 +28,16 @@ func ParseHeaders(reader *bitreader.Reader) Headers { if headers.NetworkProtocol != 2001 { panic("this parser only supports demos from portal 2") } - writer.AppendLine("\nDemo File Stamp: %s", headers.DemoFileStamp) - writer.AppendLine("Demo Protocol: %d", headers.DemoProtocol) - writer.AppendLine("Network Protocol: %d", headers.NetworkProtocol) - writer.AppendLine("Server Name: %s", headers.ServerName) - writer.AppendLine("Client Name: %s", headers.ClientName) - writer.AppendLine("Map Name: %s", headers.MapName) - writer.AppendLine("Game Directory: %s", headers.GameDirectory) - writer.AppendLine("Playback Time: %f", headers.PlaybackTime) - writer.AppendLine("Playback Ticks: %d", headers.PlaybackTicks) - writer.AppendLine("Playback Frames: %d", headers.PlaybackFrames) - writer.AppendLine("Sign On Length: %d\n", headers.SignOnLength) + demo.Writer.AppendLine("\nDemo File Stamp: %s", headers.DemoFileStamp) + demo.Writer.AppendLine("Demo Protocol: %d", headers.DemoProtocol) + demo.Writer.AppendLine("Network Protocol: %d", headers.NetworkProtocol) + demo.Writer.AppendLine("Server Name: %s", headers.ServerName) + demo.Writer.AppendLine("Client Name: %s", headers.ClientName) + demo.Writer.AppendLine("Map Name: %s", headers.MapName) + demo.Writer.AppendLine("Game Directory: %s", headers.GameDirectory) + demo.Writer.AppendLine("Playback Time: %f", headers.PlaybackTime) + demo.Writer.AppendLine("Playback Ticks: %d", headers.PlaybackTicks) + demo.Writer.AppendLine("Playback Frames: %d", headers.PlaybackFrames) + demo.Writer.AppendLine("Sign On Length: %d\n", headers.SignOnLength) return headers } -- cgit v1.2.3