aboutsummaryrefslogtreecommitdiff
path: root/pkg/packets/headers.go
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--pkg/packets/headers.go42
1 files changed, 14 insertions, 28 deletions
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
2 2
3import ( 3import (
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
8type Headers struct { 8func ParseHeaders(reader *bitreader.Reader, demo *types.Demo) types.Headers {
9 DemoFileStamp string 9 headers := types.Headers{
10 DemoProtocol int32
11 NetworkProtocol int32
12 ServerName string
13 ClientName string
14 MapName string
15 GameDirectory string
16 PlaybackTime float32
17 PlaybackTicks int32
18 PlaybackFrames int32
19 SignOnLength int32
20}
21
22func ParseHeaders(reader *bitreader.Reader) Headers {
23 headers := Headers{
24 DemoFileStamp: reader.TryReadString(), 10 DemoFileStamp: reader.TryReadString(),
25 DemoProtocol: int32(reader.TryReadSInt32()), 11 DemoProtocol: int32(reader.TryReadSInt32()),
26 NetworkProtocol: int32(reader.TryReadSInt32()), 12 NetworkProtocol: int32(reader.TryReadSInt32()),
@@ -42,16 +28,16 @@ func ParseHeaders(reader *bitreader.Reader) Headers {
42 if headers.NetworkProtocol != 2001 { 28 if headers.NetworkProtocol != 2001 {
43 panic("this parser only supports demos from portal 2") 29 panic("this parser only supports demos from portal 2")
44 } 30 }
45 writer.AppendLine("\nDemo File Stamp: %s", headers.DemoFileStamp) 31 demo.Writer.AppendLine("\nDemo File Stamp: %s", headers.DemoFileStamp)
46 writer.AppendLine("Demo Protocol: %d", headers.DemoProtocol) 32 demo.Writer.AppendLine("Demo Protocol: %d", headers.DemoProtocol)
47 writer.AppendLine("Network Protocol: %d", headers.NetworkProtocol) 33 demo.Writer.AppendLine("Network Protocol: %d", headers.NetworkProtocol)
48 writer.AppendLine("Server Name: %s", headers.ServerName) 34 demo.Writer.AppendLine("Server Name: %s", headers.ServerName)
49 writer.AppendLine("Client Name: %s", headers.ClientName) 35 demo.Writer.AppendLine("Client Name: %s", headers.ClientName)
50 writer.AppendLine("Map Name: %s", headers.MapName) 36 demo.Writer.AppendLine("Map Name: %s", headers.MapName)
51 writer.AppendLine("Game Directory: %s", headers.GameDirectory) 37 demo.Writer.AppendLine("Game Directory: %s", headers.GameDirectory)
52 writer.AppendLine("Playback Time: %f", headers.PlaybackTime) 38 demo.Writer.AppendLine("Playback Time: %f", headers.PlaybackTime)
53 writer.AppendLine("Playback Ticks: %d", headers.PlaybackTicks) 39 demo.Writer.AppendLine("Playback Ticks: %d", headers.PlaybackTicks)
54 writer.AppendLine("Playback Frames: %d", headers.PlaybackFrames) 40 demo.Writer.AppendLine("Playback Frames: %d", headers.PlaybackFrames)
55 writer.AppendLine("Sign On Length: %d\n", headers.SignOnLength) 41 demo.Writer.AppendLine("Sign On Length: %d\n", headers.SignOnLength)
56 return headers 42 return headers
57} 43}