diff --git a/protocol-generator/src/backend.rs b/protocol-generator/src/backend.rs index d8b3ced..316d929 100644 --- a/protocol-generator/src/backend.rs +++ b/protocol-generator/src/backend.rs @@ -55,10 +55,6 @@ pub enum Container { #[derive(Debug, Deserialize, PartialEq, Eq)] #[serde(untagged)] pub enum Switch { - Empty { - #[serde(rename = "compareTo")] - compare_to: String, - }, Value { #[serde(rename = "compareTo")] compare_to: String, @@ -69,15 +65,15 @@ pub enum Switch { compare_to: String, fields: LinkedHashMap>, }, + Empty { + #[serde(rename = "compareTo")] + compare_to: String, + }, } #[derive(Debug, Deserialize, PartialEq, Eq)] #[serde(untagged)] pub enum List { - Empty { - #[serde(rename = "countType")] - count_type: String, - }, Value { #[serde(rename = "countType")] count_type: String, @@ -90,6 +86,10 @@ pub enum List { #[serde(rename = "type")] list_type: Vec, }, + Empty { + #[serde(rename = "countType")] + count_type: String, + }, } #[derive(Debug, Deserialize, PartialEq, Eq)] diff --git a/protocol-generator/src/main.rs b/protocol-generator/src/main.rs index cd6f1cc..ecc1d61 100644 --- a/protocol-generator/src/main.rs +++ b/protocol-generator/src/main.rs @@ -28,7 +28,7 @@ pub fn main() { let protocol_data_file = File::open(protocol_data_file_name).expect("Failed to open protocol data file"); - let protocol_input: backend::ProtocolHandler = + let protocol_handler: backend::ProtocolHandler = serde_json::from_reader(protocol_data_file).expect("Failed to parse protocol data"); let mappings = CodeMappings {}; @@ -38,7 +38,7 @@ pub fn main() { transformers::transform_protocol( &mappings, frontend::State::Handshake, - &protocol_input.handshaking, + &protocol_handler.handshaking, ), frontend::State::Handshake, ), @@ -46,7 +46,7 @@ pub fn main() { transformers::transform_protocol( &mappings, frontend::State::Status, - &protocol_input.status, + &protocol_handler.status, ), frontend::State::Status, ), @@ -54,7 +54,7 @@ pub fn main() { transformers::transform_protocol( &mappings, frontend::State::Login, - &protocol_input.login, + &protocol_handler.login, ), frontend::State::Login, ), @@ -62,7 +62,7 @@ pub fn main() { transformers::transform_protocol( &mappings, frontend::State::Game, - &protocol_input.game, + &protocol_handler.game, ), frontend::State::Game, ), @@ -73,6 +73,7 @@ pub fn main() { "protocol/src/packet/{}.rs", state.to_string().to_lowercase() ); + let file = File::create(file_name).expect("Failed to create file"); frontend::generate_rust_file(&protocol, &template_engine, &file)