]> git.lizzy.rs Git - mt.git/blob - tosrvcmds.go
Add WaitGroup to SerializePkt
[mt.git] / tosrvcmds.go
1 package mt
2
3 import "github.com/dragonfireclient/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 // ToSrvHaveMedia tells the server that the client has received the media.
63 type ToSrvHaveMedia struct {
64         //mt:len8
65         Tokens []uint32
66 }
67
68 // ToSrvDeletedBlks tells the server that the client has deleted Blks.
69 type ToSrvDeletedBlks struct {
70         //mt:len8
71         Blks [][3]int16
72 }
73
74 // ToSrvInvAction tells the server that the client has performed an inventory action.
75 type ToSrvInvAction struct {
76         //mt:raw
77         Action string
78 }
79
80 // ToSrvChatMsg tells the server that the client has sent a chat message.
81 type ToSrvChatMsg struct {
82         //mt:utf16
83         Msg string
84 }
85
86 // ToSrvFallDmg tells the server that the client has taken fall damage.
87 type ToSrvFallDmg struct {
88         Amount uint16
89 }
90
91 // ToSrvSelectItem tells the server the selected item in the client's hotbar.
92 type ToSrvSelectItem struct {
93         Slot uint16
94 }
95
96 // ToSrvRespawn tells the server that the player has respawned.
97 type ToSrvRespawn struct{}
98
99 // ToSrvInteract tells the server that a node or AO has been interacted with.
100 type ToSrvInteract struct {
101         Action   Interaction
102         ItemSlot uint16
103         //mt:lenhdr 32
104         Pointed PointedThing
105         //mt:end
106         Pos PlayerPos
107 }
108
109 type Interaction uint8
110
111 const (
112         Dig Interaction = iota
113         StopDigging
114         Dug
115         Place
116         Use      // Left click snowball-like.
117         Activate // Right click air.
118 )
119
120 //go:generate stringer -type Interaction
121
122 // ToSrvRemovedSounds tells the server that the client has finished playing
123 // the sounds with the given IDs.
124 type ToSrvRemovedSounds struct {
125         IDs []SoundID
126 }
127
128 type ToSrvNodeMetaFields struct {
129         Pos      [3]int16
130         Formname string
131         Fields   []Field
132 }
133
134 type ToSrvInvFields struct {
135         Formname string
136         Fields   []Field
137 }
138
139 // ToSrvReqMedia requests media files from the server.
140 type ToSrvReqMedia struct {
141         Filenames []string
142 }
143
144 type ToSrvCltReady struct {
145         // Version information.
146         Major, Minor, Patch uint8
147         Reserved            uint8
148         Version             string
149         Formspec            uint16
150 }
151
152 type ToSrvFirstSRP struct {
153         Salt        []byte
154         Verifier    []byte
155         EmptyPasswd bool
156 }
157
158 type ToSrvSRPBytesA struct {
159         A      []byte
160         NoSHA1 bool
161 }
162
163 type ToSrvSRPBytesM struct {
164         M []byte
165 }
166
167 type ToSrvDisco struct{}
168
169 func (*ToSrvDisco) cmd()                         {}
170 func (*ToSrvDisco) toSrvCmdNo() uint16           { return 0xffff }
171 func (*ToSrvDisco) DefaultPktInfo() rudp.PktInfo { return rudp.PktInfo{} }