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