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