]> git.lizzy.rs Git - mt.git/blob - tosrvcmds.go
Add high-level protocol (de)serialization
[mt.git] / tosrvcmds.go
1 //go:generate ./cmdno.sh tosrvcmds ToSrv toSrv uint16 Cmd newToSrvCmd
2
3 package mt
4
5 type ToSrvCmd interface {
6         Cmd
7         toSrvCmdNo() uint16
8 }
9
10 // ToSrvNil is the first packet sent in a connection.
11 type ToSrvNil struct{}
12
13 // ToSrvInit is sent as unreliable after ToSrvNil and is re-sent repeatedly
14 // until either the server replies with ToCltHello or 10 seconds pass and
15 // the connection times out.
16 type ToSrvInit struct {
17         SerializeVer             uint8
18         SupportedCompression     CompressionModes
19         MinProtoVer, MaxProtoVer uint16
20         PlayerName               string
21
22         //mt:opt
23         SendFullItemMeta bool
24 }
25
26 // ToSrvInit2 is sent after ToCltAcceptAuth is received.
27 // The server responds to ToSrvInit2 by sending ToCltItemDefs, ToCltNodeDefs,
28 // ToCltAnnounceMedia, ToCltMovement and ToCltCSMRestrictionFlags.
29 type ToSrvInit2 struct {
30         Lang string
31 }
32
33 // ToSrvModChanJoin attempts to join a mod channel.
34 type ToSrvModChanJoin struct {
35         Channel string
36 }
37
38 // ToSrvModChanJoin attempts to leave a mod channel.
39 type ToSrvModChanLeave struct {
40         Channel string
41 }
42
43 // ToSrvModChanJoin sends a message on a mod channel.
44 type ToSrvModChanMsg struct {
45         Channel string
46         Msg     string
47 }
48
49 // ToSrvPlayerPos tells the server that the client's PlayerPos has changed.
50 type ToSrvPlayerPos struct {
51         Pos PlayerPos
52 }
53
54 // ToSrvGotBlks tells the server that the client has received Blks.
55 type ToSrvGotBlks struct {
56         //mt:len8
57         Blks [][3]int16
58 }
59
60 // ToSrvDeletedBlks tells the server that the client has deleted Blks.
61 type ToSrvDeletedBlks struct {
62         //mt:len8
63         Blks [][3]int16
64 }
65
66 // ToSrvInvAction tells the server that the client has performed an inventory action.
67 type ToSrvInvAction struct {
68         //mt:raw
69         Action string
70 }
71
72 // ToSrvChatMsg tells the server that the client has sent a chat message.
73 type ToSrvChatMsg struct {
74         //mt:utf16
75         Msg string
76 }
77
78 // ToSrvFallDmg tells the server that the client has taken fall damage.
79 type ToSrvFallDmg struct {
80         Amount uint16
81 }
82
83 // ToSrvSelectItem tells the server the selected item in the client's hotbar.
84 type ToSrvSelectItem struct {
85         Slot uint16
86 }
87
88 // ToSrvRespawn tells the server that the player has respawned.
89 type ToSrvRespawn struct{}
90
91 // ToSrvInteract tells the server that a node or AO has been interacted with.
92 type ToSrvInteract struct {
93         Action   Interaction
94         ItemSlot uint16
95         //mt:lenhdr 32
96         Pointed PointedThing
97         //mt:end
98         Pos PlayerPos
99 }
100
101 type Interaction uint8
102
103 const (
104         Dig Interaction = iota
105         StopDigging
106         Dug
107         Place
108         Use      // Left click snowball-like.
109         Activate // Right click air.
110 )
111
112 // ToSrvRemovedSounds tells the server that the client has finished playing
113 // the sounds with the given IDs.
114 type ToSrvRemovedSounds struct {
115         IDs []SoundID
116 }
117
118 type ToSrvNodeMetaFields struct {
119         Pos      [3]int16
120         Formname string
121         Fields   []Field
122 }
123
124 type ToSrvInvFields struct {
125         Formname string
126         Fields   []Field
127 }
128
129 // ToSrvReqMedia requests media files from the server.
130 type ToSrvReqMedia struct {
131         Filenames []string
132 }
133
134 type ToSrvCltReady struct {
135         // Version information.
136         Major, Minor, Patch uint8
137         Reserved            uint8
138         Version             string
139         Formspec            uint16
140 }
141
142 type ToSrvFirstSRP struct {
143         Salt        []byte
144         Verifier    []byte
145         EmptyPasswd bool
146 }
147
148 type ToSrvSRPBytesA struct {
149         A      []byte
150         NoSHA1 bool
151 }
152
153 type ToSrvSRPBytesM struct {
154         M []byte
155 }