]> git.lizzy.rs Git - mt_net.git/blob - src/to_srv.rs
Use improved attributes
[mt_net.git] / src / to_srv.rs
1 use super::*;
2
3 #[mt_derive(to = "srv", repr = "u32", enumset)]
4 pub enum Key {
5     Forward,
6     Backward,
7     Left,
8     Right,
9     Jump,
10     Special,
11     Sneak,
12     Dig,
13     Place,
14     Zoom,
15 }
16
17 #[mt_derive(to = "srv")]
18 pub struct PlayerPos {
19     pub pos_100: [i32; 3],
20     pub vel_100: [i32; 3],
21     pub pitch_100: i32,
22     pub yaw_100: i32,
23     pub keys: EnumSet<Key>,
24     pub fov_80: u8,
25     pub wanted_range: u8,
26 }
27
28 #[mt_derive(to = "srv", repr = "u8")]
29 pub enum Interaction {
30     Dig = 0,
31     StopDigging,
32     Dug,
33     Place,
34     Use,
35     Activate,
36 }
37
38 #[mt_derive(to = "srv", repr = "u8", tag = "type")]
39 #[mt(const_before = "0u8")] // version
40 pub enum PointedThing {
41     None = 0,
42     Node { under: [i16; 3], above: [i16; 3] },
43     Obj { obj: u16 },
44 }
45
46 #[mt_derive(to = "srv", repr = "u16", tag = "type", content = "data")]
47 pub enum ToSrvPkt {
48     Nil = 0,
49     Init {
50         serialize_version: u8,
51         #[mt(const_before = "1u16")] // supported compression
52         min_proto_version: u16,
53         max_proto_version: u16,
54         player_name: String,
55         #[mt(default)]
56         send_full_item_meta: bool,
57     } = 2,
58     Init2 {
59         lang: String,
60     } = 17,
61     JoinModChan {
62         channel: String,
63     } = 23,
64     LeaveModChan {
65         channel: String,
66     } = 24,
67     MsgModChan {
68         channel: String,
69         msg: String,
70     } = 25,
71     PlayerPos(PlayerPos) = 35,
72     GotBlocks {
73         #[mt(len = "u8")]
74         blocks: Vec<[i16; 3]>,
75     } = 36,
76     DeletedBlocks {
77         #[mt(len = "u8")]
78         blocks: Vec<[i16; 3]>,
79     } = 37,
80     InvAction {
81         #[mt(len = "()")]
82         action: String,
83     } = 49,
84     ChatMsg {
85         #[mt(len = "Utf16")]
86         msg: String,
87     } = 50,
88     FallDmg {
89         amount: u16,
90     } = 53,
91     SelectItem {
92         select_item: u16,
93     } = 55,
94     Respawn = 56,
95     Interact {
96         action: Interaction,
97         item_slot: u16,
98         #[mt(size = "u32")]
99         pointed: PointedThing,
100         pos: PlayerPos,
101     } = 57,
102     RemovedSounds {
103         ids: Vec<i32>,
104     } = 58,
105     NodeMetaFields {
106         pos: [i16; 3],
107         formname: String,
108         #[mt(len = "(DefCfg, (DefCfg, u32))")]
109         fields: HashMap<String, String>,
110     } = 59,
111     InvFields {
112         formname: String,
113         #[mt(len = "(DefCfg, (DefCfg, u32))")]
114         fields: HashMap<String, String>,
115     } = 60,
116     ReqMedia {
117         filenames: Vec<String>,
118     } = 64,
119     CltReady {
120         major: u8,
121         minor: u8,
122         patch: u8,
123         reserved: u8,
124         version: String,
125         formspec: u16,
126     } = 67,
127     FirstSrp {
128         salt: Vec<u8>,
129         verifier: Vec<u8>,
130         empty_passwd: bool,
131     } = 80,
132     SrpBytesA {
133         a: Vec<u8>,
134         no_sha1: bool,
135     } = 81,
136     SrpBytesM {
137         m: Vec<u8>,
138     } = 82,
139     Disco = 0xffff,
140 }