]> git.lizzy.rs Git - mt_net.git/blob - src/to_clt.rs
Fix ToCltPkt repr
[mt_net.git] / src / to_clt.rs
1 use super::*;
2
3 #[mt_derive(to = "clt")]
4 pub struct ArgbColor {
5     pub a: u8,
6     pub r: u8,
7     pub g: u8,
8     pub b: u8,
9 }
10
11 #[mt_derive(to = "clt", repr = "u8")]
12 pub enum ModChanSig {
13     JoinOk = 0,
14     JoinFail,
15     LeaveOk,
16     LeaveFail,
17     NotRegistered,
18     SetState,
19 }
20
21 mod chat;
22 mod env;
23 mod hud;
24 mod media;
25 mod status;
26
27 pub use chat::*;
28 pub use env::*;
29 pub use hud::*;
30 pub use media::*;
31 pub use status::*;
32
33 #[mt_derive(to = "clt", repr = "u16", tag = "type", content = "data")]
34 pub enum ToCltPkt {
35     Hello {
36         serialize_version: u8,
37         #[mt(const16 = 1)] // compression
38         proto_version: u16,
39         auth_methods: EnumSet<AuthMethod>,
40         username: String,
41     } = 2,
42     AcceptAuth {
43         player_pos: [f32; 3],
44         map_seed: u64,
45         send_interval: f32,
46         sudo_auth_methods: EnumSet<AuthMethod>,
47     } = 3,
48     AcceptSudoMode {
49         sudo_auth_methods: EnumSet<AuthMethod>,
50     } = 4,
51     DenySudoMode = 5,
52     Kick(KickReason) = 10,
53     BlockData {
54         pos: [i16; 3],
55         #[mt(zstd)]
56         block: Box<MapBlock>,
57     } = 32,
58     AddNode {
59         pos: [i16; 3],
60         param0: u16,
61         param1: u8,
62         param2: u8,
63         keep_meta: bool,
64     } = 33,
65     RemoveNode {
66         pos: [i16; 3],
67     } = 34,
68     Inv {
69         inv: String,
70     } = 39,
71     TimeOfDay {
72         time: u16,
73         speed: f32,
74     } = 41,
75     CsmRestrictionFlags {
76         flags: EnumSet<CsmRestrictionFlag>,
77         map_range: u32,
78     } = 42,
79     AddPlayerVelocity {
80         vel: [f32; 3],
81     } = 43,
82     MediaPush {
83         no_len_hash: String,
84         filename: String,
85         callback_token: u32,
86         should_cache: bool,
87     } = 44,
88     ChatMsg {
89         #[mt(const8 = 1)]
90         msg_type: ChatMsgType,
91         #[mt(utf16)]
92         sender: String,
93         #[mt(utf16)]
94         text: String,
95         timestamp: i64, // unix time
96     } = 47,
97     ObjRemoveAdd {
98         remove: Vec<u16>,
99         add: Vec<ObjAdd>,
100     } = 49,
101     ObjMsgs {
102         msgs: Vec<ObjMsg>,
103     } = 50,
104     Hp {
105         hp: u16,
106         #[mt(default)]
107         damage_effect: bool,
108     } = 51,
109     MovePlayer {
110         pos: [f32; 3],
111         pitch: f32,
112         yaw: f32,
113     } = 52,
114     LegacyKick {
115         #[mt(utf16)]
116         reason: String,
117     } = 53,
118     Fov {
119         fov: f32,
120         multiplier: bool,
121         transition_time: f32,
122     } = 54,
123     DeathScreen {
124         point_cam: bool,
125         point_at: [f32; 3],
126     } = 55,
127     Media {
128         n: u16,
129         i: u16,
130         files: Vec<MediaPayload>, // FIXME: can we use a HashMap for this?
131     } = 56,
132     NodeDefs {
133         defs: Vec<NodeDef>,
134     } = 58,
135     AnnounceMedia {
136         files: Vec<MediaAnnounce>, // FIXME: can we use a HashMap for this?
137         url: String,
138     } = 60,
139     #[mt(size32, zlib)]
140     ItemDefs {
141         #[mt(const8 = 0)] // version
142         defs: Vec<ItemDef>,
143         aliases: HashMap<String, String>,
144     } = 61,
145     PlaySound {
146         id: u32,
147         name: String,
148         gain: f32,
149         src_type: SoundSrcType,
150         pos: [f32; 3],
151         src_obj_id: u16,
152         #[serde(rename = "loop")]
153         sound_loop: bool,
154         fade: f32,
155         pitch: f32,
156         ephermeral: bool,
157     } = 63,
158     StopSound {
159         id: u32,
160     } = 64,
161     Privs {
162         privs: HashSet<String>,
163     } = 65,
164     InvFormspec {
165         #[mt(size32)]
166         formspec: String,
167     } = 66,
168     DetachedInv {
169         name: String,
170         keep: bool,
171         len: u16,
172         #[mt(len0)]
173         inv: String,
174     } = 67,
175     ShowFormspec {
176         #[mt(len32)]
177         formspec: String,
178         formname: String,
179     } = 68,
180     Movement {
181         default_accel: f32,
182         air_accel: f32,
183         fast_accel: f32,
184         walk_speed: f32,
185         crouch_speed: f32,
186         fast_speed: f32,
187         climb_speed: f32,
188         jump_speed: f32,
189         gravity: f32,
190     } = 69,
191     SpawnParticle {
192         pos: [f32; 3],
193         vel: [f32; 3],
194         acc: [f32; 3],
195         expiration_time: f32,
196         size: f32,
197         collide: bool,
198         #[mt(len32)]
199         texture: String,
200         vertical: bool,
201         collision_rm: bool,
202         anim_params: TileAnim,
203         glow: u8,
204         obj_collision: bool,
205         node_param0: u16,
206         node_param2: u8,
207         node_tile: u8,
208     } = 70,
209     AddParticleSpawner {
210         amount: u16,
211         duration: f32,
212         pos: [[f32; 3]; 2],
213         vel: [[f32; 3]; 2],
214         acc: [[f32; 3]; 2],
215         expiration_time: [f32; 2],
216         size: [f32; 2],
217         collide: bool,
218         #[mt(len32)]
219         texture: String,
220         id: u32,
221         vertical: bool,
222         collision_rm: bool,
223         attached_obj_id: u16,
224         anim_params: TileAnim,
225         glow: u8,
226         obj_collision: bool,
227         node_param0: u16,
228         node_param2: u8,
229         node_tile: u8,
230     } = 71,
231     AddHud {
232         id: u32,
233         hud: HudElement,
234     } = 73,
235     RemoveHud {
236         id: u32,
237     } = 74,
238     ChangeHud {
239         id: u32,
240         change: HudChange,
241     } = 75,
242     HudFlags {
243         flags: EnumSet<HudFlag>,
244         mask: EnumSet<HudFlag>,
245     } = 76,
246     SetHotbarParam(HotbarParam) = 77,
247     Breath {
248         breath: u16,
249     } = 78,
250     // TODO
251     SkyParams = 79,
252     OverrideDayNightRatio {
253         #[serde(rename = "override")]
254         ratio_override: bool,
255         ratio: u16,
256     } = 80,
257     LocalPlayerAnim {
258         idle: [i32; 2],
259         walk: [i32; 2],
260         dig: [i32; 2],
261         walk_dig: [i32; 2],
262         speed: f32,
263     } = 81,
264     EyeOffset {
265         first: [f32; 3],
266         third: [f32; 3],
267     } = 82,
268     RemoveParticleSpawner {
269         id: u32,
270     } = 83,
271     CloudParams {
272         density: f32,
273         diffuse_color: ArgbColor,
274         ambient_color: ArgbColor,
275         height: f32,
276         thickness: f32,
277         speed: [f32; 2],
278     } = 84,
279     FadeSound {
280         id: u32,
281         step: f32,
282         gain: f32,
283     } = 85,
284     UpdatePlayerList {
285         update_type: PlayerListUpdateType,
286         players: HashSet<String>,
287     } = 86,
288     ModChanMsg {
289         channel: String,
290         sender: String,
291         msg: String,
292     } = 87,
293     ModChanSig {
294         signal: ModChanSig,
295         channel: String,
296     } = 88,
297     NodeMetasChanged(#[mt(size32)] HashMap<[i16; 3], NodeMeta>) = 89,
298     SunParams {
299         visible: bool,
300         texture: String,
301         tone_map: String,
302         rise: String,
303         rising: bool,
304         size: f32,
305     } = 90,
306     MoonParams {
307         visible: bool,
308         texture: String,
309         tone_map: String,
310         size: f32,
311     } = 91,
312     StarParams {
313         visible: bool,
314         texture: String,
315         tone_map: String,
316         size: f32,
317     } = 92,
318     SrpBytesSaltB {
319         salt: Vec<u8>,
320         b: Vec<u8>,
321     } = 96,
322     FormspecPrepend {
323         prepend: String,
324     } = 97,
325     MinimapModes(MinimapModePkt) = 98,
326 }