aboutsummaryrefslogtreecommitdiff
path: root/packets/header.go
diff options
context:
space:
mode:
authorArda Serdar Pektezol <1669855+pektezol@users.noreply.github.com>2022-11-07 16:09:44 +0300
committerArda Serdar Pektezol <1669855+pektezol@users.noreply.github.com>2023-09-16 21:39:37 +0300
commita77cf8169b42a4394e62f7a381ca546b27d0f723 (patch)
tree2dd8d4f51c5841b806e9b5ed6fe9054bce06e2e0 /packets/header.go
parentchanged github username + other stuff that i don't remember (diff)
downloadsdp.go-a77cf8169b42a4394e62f7a381ca546b27d0f723.tar.gz
sdp.go-a77cf8169b42a4394e62f7a381ca546b27d0f723.tar.bz2
sdp.go-a77cf8169b42a4394e62f7a381ca546b27d0f723.zip
starting fresh for the third time
Diffstat (limited to 'packets/header.go')
-rw-r--r--packets/header.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/packets/header.go b/packets/header.go
new file mode 100644
index 0000000..60cd146
--- /dev/null
+++ b/packets/header.go
@@ -0,0 +1,33 @@
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: uint(reader.TryReadInt32()),
13 NetworkProtocol: uint(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: int(reader.TryReadInt32()),
20 PlaybackFrames: int(reader.TryReadInt32()),
21 SignOnLength: uint(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}