summaryrefslogtreecommitdiff
path: root/src/to_srv.rs
diff options
context:
space:
mode:
authorLizzy Fleckenstein <eliasfleckenstein@web.de>2023-02-10 15:53:15 +0100
committerLizzy Fleckenstein <eliasfleckenstein@web.de>2023-02-10 15:53:15 +0100
commit6c875082474431a39596b1547b436a9bec1f5533 (patch)
treebafa770893e6a5a1daea8b57cc5a3f3574da3cb6 /src/to_srv.rs
downloadmt_net-6c875082474431a39596b1547b436a9bec1f5533.tar.xz
Initial commit
Diffstat (limited to 'src/to_srv.rs')
-rw-r--r--src/to_srv.rs133
1 files changed, 133 insertions, 0 deletions
diff --git a/src/to_srv.rs b/src/to_srv.rs
new file mode 100644
index 0000000..03cb5a4
--- /dev/null
+++ b/src/to_srv.rs
@@ -0,0 +1,133 @@
+use super::*;
+
+#[mt_derive(to = "srv", repr = "u32", enumset)]
+pub enum Key {
+ Forward,
+ Backward,
+ Left,
+ Right,
+ Jump,
+ Special,
+ Sneak,
+ Dig,
+ Place,
+ Zoom,
+}
+
+#[mt_derive(to = "srv")]
+pub struct PlayerPos {
+ pub pos_100: [i32; 3],
+ pub vel_100: [i32; 3],
+ pub pitch_100: i32,
+ pub yaw_100: i32,
+ pub keys: EnumSet<Key>,
+ pub fov_80: u8,
+ pub wanted_range: u8,
+}
+
+#[mt_derive(to = "srv", repr = "u8")]
+pub enum Interaction {
+ Dig = 0,
+ StopDigging,
+ Dug,
+ Place,
+ Use,
+ Activate,
+}
+
+#[mt_derive(to = "srv")]
+pub struct PointedThing; // TODO
+
+#[mt_derive(to = "srv", repr = "u16", tag = "type", content = "data")]
+pub enum ToSrvPkt {
+ Nil = 0,
+ Init {
+ serialize_version: u8,
+ #[mt(const16 = 1)] // supported compression
+ min_proto_version: u16,
+ max_proto_version: u16,
+ player_name: String,
+ #[mt(default)]
+ send_full_item_meta: bool,
+ } = 2,
+ Init2 {
+ lang: String,
+ } = 17,
+ JoinModChan {
+ channel: String,
+ } = 23,
+ LeaveModChan {
+ channel: String,
+ } = 24,
+ MsgModChan {
+ channel: String,
+ msg: String,
+ } = 25,
+ PlayerPos(PlayerPos) = 35,
+ GotBlocks {
+ #[mt(len8)]
+ blocks: Vec<[i16; 3]>,
+ } = 36,
+ DeletedBlocks {
+ #[mt(len8)]
+ blocks: Vec<[i16; 3]>,
+ } = 37,
+ InvAction {
+ #[mt(len0)]
+ action: String,
+ } = 49,
+ ChatMsg {
+ #[mt(utf16)]
+ msg: String,
+ } = 50,
+ FallDmg {
+ amount: u16,
+ } = 53,
+ SelectItem {
+ select_item: u16,
+ } = 55,
+ Respawn = 56,
+ Interact {
+ action: Interaction,
+ item_slot: u16,
+ #[mt(size32)]
+ pointed: PointedThing,
+ pos: PlayerPos,
+ } = 57,
+ RemovedSounds {
+ ids: Vec<i32>,
+ } = 58,
+ NodeMetaFields {
+ pos: [i16; 3],
+ formname: String,
+ fields: HashMap<String, String>,
+ } = 59,
+ InvFields {
+ formname: String,
+ fields: HashMap<String, String>,
+ } = 60,
+ ReqMedia {
+ filenames: Vec<String>,
+ } = 64,
+ CltReady {
+ major: u8,
+ minor: u8,
+ patch: u8,
+ reserved: u8,
+ version: String,
+ formspec: u16,
+ } = 67,
+ FirstSrp {
+ salt: Vec<u8>,
+ verifier: Vec<u8>,
+ empty_passwd: bool,
+ } = 80,
+ SrpBytesA {
+ a: Vec<u8>,
+ no_sha1: bool,
+ } = 81,
+ SrpBytesM {
+ m: Vec<u8>,
+ } = 82,
+ Disco = 0xffff,
+}