aboutsummaryrefslogtreecommitdiff
path: root/pkg/types/types.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/types/types.go')
-rw-r--r--pkg/types/types.go71
1 files changed, 71 insertions, 0 deletions
diff --git a/pkg/types/types.go b/pkg/types/types.go
new file mode 100644
index 0000000..341e875
--- /dev/null
+++ b/pkg/types/types.go
@@ -0,0 +1,71 @@
1package types
2
3import (
4 "github.com/pektezol/sdp.go/pkg/writer"
5)
6
7type Demo struct {
8 Headers Headers `json:"headers"`
9 Messages []Message `json:"messages"`
10 Writer *writer.Writer `json:"-"`
11 GameEventList *SvcGameEventList `json:"-"`
12}
13
14type Headers struct {
15 DemoFileStamp string `json:"demo_file_stamp"`
16 DemoProtocol int32 `json:"demo_protocol"`
17 NetworkProtocol int32 `json:"network_protocol"`
18 ServerName string `json:"server_name"`
19 ClientName string `json:"client_name"`
20 MapName string `json:"map_name"`
21 GameDirectory string `json:"game_directory"`
22 PlaybackTime float32 `json:"playback_time"`
23 PlaybackTicks int32 `json:"playback_ticks"`
24 PlaybackFrames int32 `json:"playback_frames"`
25 SignOnLength int32 `json:"sign_on_length"`
26}
27
28type Message struct {
29 PacketType MessageType `json:"packet_type"`
30 TickNumber int32 `json:"tick_number"`
31 SlotNumber uint8 `json:"slot_number"`
32 Data any `json:"data"`
33}
34
35type MessageType uint8
36
37const (
38 SignOn MessageType = iota + 1
39 Packet
40 SyncTick
41 ConsoleCmd
42 UserCmd
43 DataTables
44 Stop
45 CustomData
46 StringTables
47)
48
49func (t MessageType) String() string {
50 switch t {
51 case SignOn:
52 return "SIGNON"
53 case Packet:
54 return "PACKET"
55 case SyncTick:
56 return "SYNCTICK"
57 case ConsoleCmd:
58 return "CONSOLECMD"
59 case UserCmd:
60 return "USERCMD"
61 case DataTables:
62 return "DATATABLES"
63 case Stop:
64 return "STOP"
65 case CustomData:
66 return "CUSTOMDATA"
67 case StringTables:
68 return "STRINGTABLES"
69 }
70 return "INVALID"
71}