diff options
| author | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2023-11-06 18:37:11 +0300 |
|---|---|---|
| committer | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2023-11-06 18:37:11 +0300 |
| commit | 2f8c92f261586f68a976efce0cfcdd0401f402e0 (patch) | |
| tree | 33189cc48987789dff4e7fba0a74d2b2326f0a04 /pkg/packets/headers.go | |
| parent | convert cm ticks correctly (diff) | |
| download | sdp.go-2f8c92f261586f68a976efce0cfcdd0401f402e0.tar.gz sdp.go-2f8c92f261586f68a976efce0cfcdd0401f402e0.tar.bz2 sdp.go-2f8c92f261586f68a976efce0cfcdd0401f402e0.zip | |
dont try to understand it, feel itlp-parser
Diffstat (limited to '')
| -rw-r--r-- | pkg/packets/headers.go | 45 |
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 @@ | |||
| 1 | package packets | ||
| 2 | |||
| 3 | import ( | ||
| 4 | "github.com/pektezol/bitreader" | ||
| 5 | ) | ||
| 6 | |||
| 7 | type 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 | |||
| 21 | func 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 | } | ||