aboutsummaryrefslogtreecommitdiff
path: root/pkg/packets/headers.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/packets/headers.go')
-rw-r--r--pkg/packets/headers.go45
1 files changed, 0 insertions, 45 deletions
diff --git a/pkg/packets/headers.go b/pkg/packets/headers.go
deleted file mode 100644
index ba5482b..0000000
--- a/pkg/packets/headers.go
+++ /dev/null
@@ -1,45 +0,0 @@
1package packets
2
3import (
4 "github.com/pektezol/bitreader"
5)
6
7type Headers struct {
8 DemoFileStamp string
9 DemoProtocol int32
10 NetworkProtocol int32
11 ServerName string
12 ClientName string
13 MapName string
14 GameDirectory string
15 PlaybackTime float32
16 PlaybackTicks int32
17 PlaybackFrames int32
18 SignOnLength int32
19}
20
21func ParseHeaders(reader *bitreader.Reader) Headers {
22 headers := Headers{
23 DemoFileStamp: reader.TryReadString(),
24 DemoProtocol: int32(reader.TryReadSInt32()),
25 NetworkProtocol: int32(reader.TryReadSInt32()),
26 ServerName: reader.TryReadStringLength(260),
27 ClientName: reader.TryReadStringLength(260),
28 MapName: reader.TryReadStringLength(260),
29 GameDirectory: reader.TryReadStringLength(260),
30 PlaybackTime: reader.TryReadFloat32(),
31 PlaybackTicks: int32(reader.TryReadSInt32()),
32 PlaybackFrames: int32(reader.TryReadSInt32()),
33 SignOnLength: int32(reader.TryReadSInt32()),
34 }
35 if headers.DemoFileStamp != "HL2DEMO" {
36 panic("invalid demo file stamp")
37 }
38 if headers.DemoProtocol != 4 {
39 panic("this parser only supports demos from new engine")
40 }
41 if headers.NetworkProtocol != 2001 {
42 panic("this parser only supports demos from portal 2")
43 }
44 return headers
45}