]> git.lizzy.rs Git - mt_net.git/blob - src/to_srv.rs
ce5282cde569c3c7956a9c9dce060f4d77e9bc3b
[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", repr = "u16", tag = "type", content = "data")]
47 pub enum ToSrvPkt {
48     Nil = 0,
49     Init {
50         serialize_version: u8,
51         #[mt(const16 = 1)] // 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(len8)]
74         blocks: Vec<[i16; 3]>,
75     } = 36,
76     DeletedBlocks {
77         #[mt(len8)]
78         blocks: Vec<[i16; 3]>,
79     } = 37,
80     InvAction {
81         #[mt(len0)]
82         action: String,
83     } = 49,
84     ChatMsg {
85         #[mt(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(size32)]
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         fields: HashMap<String, String>,
109     } = 59,
110     InvFields {
111         formname: String,
112         fields: HashMap<String, String>,
113     } = 60,
114     ReqMedia {
115         filenames: Vec<String>,
116     } = 64,
117     CltReady {
118         major: u8,
119         minor: u8,
120         patch: u8,
121         reserved: u8,
122         version: String,
123         formspec: u16,
124     } = 67,
125     FirstSrp {
126         salt: Vec<u8>,
127         verifier: Vec<u8>,
128         empty_passwd: bool,
129     } = 80,
130     SrpBytesA {
131         a: Vec<u8>,
132         no_sha1: bool,
133     } = 81,
134     SrpBytesM {
135         m: Vec<u8>,
136     } = 82,
137     Disco = 0xffff,
138 }