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