aboutsummaryrefslogtreecommitdiff
path: root/packets/header.go
diff options
context:
space:
mode:
authorArda Serdar Pektezol <1669855+pektezol@users.noreply.github.com>2023-09-12 20:53:09 +0300
committerArda Serdar Pektezol <1669855+pektezol@users.noreply.github.com>2023-09-16 21:39:42 +0300
commit82871ba1bac1d62f69e1933b66659e62d2e5e063 (patch)
treea906310fba89b670bcfda9625a6d776553d482f6 /packets/header.go
parentnet/svc messages finally getting parsed correctly (diff)
downloadsdp.go-82871ba1bac1d62f69e1933b66659e62d2e5e063.tar.gz
sdp.go-82871ba1bac1d62f69e1933b66659e62d2e5e063.tar.bz2
sdp.go-82871ba1bac1d62f69e1933b66659e62d2e5e063.zip
another rewrite, v1.0.0
Diffstat (limited to 'packets/header.go')
-rw-r--r--packets/header.go33
1 files changed, 0 insertions, 33 deletions
diff --git a/packets/header.go b/packets/header.go
deleted file mode 100644
index c4172d9..0000000
--- a/packets/header.go
+++ /dev/null
@@ -1,33 +0,0 @@
1package packets
2
3import (
4 "fmt"
5
6 "github.com/pektezol/bitreader"
7)
8
9func ParseHeader(reader *bitreader.ReaderType) {
10 header := Header{
11 DemoFileStamp: reader.TryReadStringLen(8),
12 DemoProtocol: uint32(reader.TryReadInt32()),
13 NetworkProtocol: uint32(reader.TryReadInt32()),
14 ServerName: reader.TryReadStringLen(260),
15 ClientName: reader.TryReadStringLen(260),
16 MapName: reader.TryReadStringLen(260),
17 GameDirectory: reader.TryReadStringLen(260),
18 PlaybackTime: reader.TryReadFloat32(),
19 PlaybackTicks: int32(reader.TryReadInt32()),
20 PlaybackFrames: int32(reader.TryReadInt32()),
21 SignOnLength: uint32(reader.TryReadInt32()),
22 }
23 if header.DemoFileStamp != "HL2DEMO" {
24 panic("Invalid demo file stamp. Make sure a valid demo file is given.")
25 }
26 if header.DemoProtocol != 4 {
27 panic("Given demo is from old engine. This parser is only supported for new engine.")
28 }
29 if header.NetworkProtocol != 2001 {
30 panic("Given demo is not from Portal2. This parser currently only supports Portal 2.")
31 }
32 fmt.Println(header)
33}