diff options
author | Lizzy Fleckenstein <eliasfleckenstein@web.de> | 2023-02-13 17:13:25 +0100 |
---|---|---|
committer | Lizzy Fleckenstein <eliasfleckenstein@web.de> | 2023-02-13 17:13:25 +0100 |
commit | 9e4a1f1be0685e0ba761bf7d851ff7489789d3d3 (patch) | |
tree | 13b9c3d13954aae78ef4fddbc00690c233276729 /src/to_clt/env.rs | |
parent | 1ae0a6af22559236d2d97a4aaa1e17dbc4da733c (diff) | |
download | mt_net-9e4a1f1be0685e0ba761bf7d851ff7489789d3d3.tar.xz |
Use improved attributes
Diffstat (limited to 'src/to_clt/env.rs')
-rw-r--r-- | src/to_clt/env.rs | 36 |
1 files changed, 13 insertions, 23 deletions
diff --git a/src/to_clt/env.rs b/src/to_clt/env.rs index cce7696..031ee96 100644 --- a/src/to_clt/env.rs +++ b/src/to_clt/env.rs @@ -2,7 +2,7 @@ use super::*; #[mt_derive(to = "clt")] pub struct ObjProps { - #[mt(const8 = 4)] // version + #[mt(const_before = "4u8")] // version pub max_hp: u16, // player only pub collide_with_nodes: bool, pub weight: f32, // deprecated @@ -93,6 +93,8 @@ pub struct ObjPhysicsOverride { pub old_sneak: bool, } +const GENERIC_CAO: u8 = 101; + #[mt_derive(to = "clt", repr = "u8", tag = "type", content = "data")] pub enum ObjMsg { Props(ObjProps) = 0, @@ -116,9 +118,8 @@ pub enum ObjMsg { Attach(ObjAttach), PhysicsOverride(ObjPhysicsOverride), SpawnInfant { + #[mt(const_after = "GENERIC_CAO")] id: u16, - #[mt(const8 = 101)] // GenericCAO - infant_type: (), } = 11, AnimSpeed { speed: f32, @@ -128,31 +129,31 @@ pub enum ObjMsg { #[mt_derive(to = "clt")] pub struct ObjIdMsg { pub id: u16, - #[mt(size16)] + #[mt(size = "u16")] pub msg: ObjMsg, } #[mt_derive(to = "clt")] -pub struct ObjInitMsg(#[mt(size32)] ObjMsg); +pub struct ObjInitMsg(#[mt(size = "u32")] pub ObjMsg); #[mt_derive(to = "clt")] pub struct ObjInitData { - #[mt(const8 = 1)] // version + #[mt(const_before = "1u8")] // version pub name: String, pub is_player: bool, pub id: u16, pub pos: [f32; 3], pub rot: [f32; 3], pub hp: u16, - #[mt(len8)] + #[mt(len = "u8")] pub msgs: Vec<ObjInitMsg>, } #[mt_derive(to = "clt")] pub struct ObjAdd { pub id: u16, - #[mt(const8 = 101)] // GenericCAO - #[mt(size32)] + #[mt(const_before = "GENERIC_CAO")] + #[mt(size = "u32")] pub init_data: ObjInitData, } @@ -174,25 +175,14 @@ pub const CONTENT_IGNORE: u16 = 127; pub struct MapBlock { pub flags: EnumSet<MapBlockFlag>, pub lit_from: u16, - - #[mt(const8 = 2)] - #[serde(skip)] - pub param0_size: (), - - #[mt(const8 = 2)] - #[serde(skip)] - pub param12_size: (), - + #[mt(const_before = "2u8")] // param0 size + #[mt(const_before = "2u8")] // param1 size + param2 size #[serde(with = "serde_arrays")] pub param_0: [u16; 4096], #[serde(with = "serde_arrays")] pub param_1: [u8; 4096], #[serde(with = "serde_arrays")] pub param_2: [u8; 4096], - + #[mt(const_after = "2u8")] // version pub node_metas: HashMap<u16, NodeMeta>, - - #[mt(const8 = 2)] - #[serde(skip)] - pub version: (), } |