]> git.lizzy.rs Git - mt_net.git/blob - src/to_srv.rs
Fix Field sending
[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(const8 = 0)] // 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")]
47 pub struct String32(#[mt(len32)] pub String);
48
49 impl std::ops::Deref for String32 {
50     type Target = String;
51
52     fn deref(&self) -> &Self::Target {
53         &self.0
54     }
55 }
56
57 impl std::ops::DerefMut for String32 {
58     fn deref_mut(&mut self) -> &mut Self::Target {
59         &mut self.0
60     }
61 }
62
63 #[mt_derive(to = "srv", repr = "u16", tag = "type", content = "data")]
64 pub enum ToSrvPkt {
65     Nil = 0,
66     Init {
67         serialize_version: u8,
68         #[mt(const16 = 1)] // supported compression
69         min_proto_version: u16,
70         max_proto_version: u16,
71         player_name: String,
72         #[mt(default)]
73         send_full_item_meta: bool,
74     } = 2,
75     Init2 {
76         lang: String,
77     } = 17,
78     JoinModChan {
79         channel: String,
80     } = 23,
81     LeaveModChan {
82         channel: String,
83     } = 24,
84     MsgModChan {
85         channel: String,
86         msg: String,
87     } = 25,
88     PlayerPos(PlayerPos) = 35,
89     GotBlocks {
90         #[mt(len8)]
91         blocks: Vec<[i16; 3]>,
92     } = 36,
93     DeletedBlocks {
94         #[mt(len8)]
95         blocks: Vec<[i16; 3]>,
96     } = 37,
97     InvAction {
98         #[mt(len0)]
99         action: String,
100     } = 49,
101     ChatMsg {
102         #[mt(utf16)]
103         msg: String,
104     } = 50,
105     FallDmg {
106         amount: u16,
107     } = 53,
108     SelectItem {
109         select_item: u16,
110     } = 55,
111     Respawn = 56,
112     Interact {
113         action: Interaction,
114         item_slot: u16,
115         #[mt(size32)]
116         pointed: PointedThing,
117         pos: PlayerPos,
118     } = 57,
119     RemovedSounds {
120         ids: Vec<i32>,
121     } = 58,
122     NodeMetaFields {
123         pos: [i16; 3],
124         formname: String,
125         fields: HashMap<String, String32>,
126     } = 59,
127     InvFields {
128         formname: String,
129         fields: HashMap<String, String32>,
130     } = 60,
131     ReqMedia {
132         filenames: Vec<String>,
133     } = 64,
134     CltReady {
135         major: u8,
136         minor: u8,
137         patch: u8,
138         reserved: u8,
139         version: String,
140         formspec: u16,
141     } = 67,
142     FirstSrp {
143         salt: Vec<u8>,
144         verifier: Vec<u8>,
145         empty_passwd: bool,
146     } = 80,
147     SrpBytesA {
148         a: Vec<u8>,
149         no_sha1: bool,
150     } = 81,
151     SrpBytesM {
152         m: Vec<u8>,
153     } = 82,
154     Disco = 0xffff,
155 }