From eed5a7460c35aaa7f7af94a52c79f9c8c1d23689 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Sat, 25 Feb 2023 15:03:11 +0800 Subject: [PATCH] WARNING WITH BUG [build skip] [page skip] --- Difficult_Rocket/__init__.py | 2 +- libs/Difficult_Rocket_rs/src/Cargo.lock | 66 +++++-------------- libs/Difficult_Rocket_rs/src/Cargo.toml | 16 ++--- libs/Difficult_Rocket_rs/src/src/lib.rs | 2 +- libs/Difficult_Rocket_rs/src/src/sr1_data.rs | 68 +++++++++++++++----- 5 files changed, 80 insertions(+), 74 deletions(-) diff --git a/Difficult_Rocket/__init__.py b/Difficult_Rocket/__init__.py index 960864d..e76a890 100644 --- a/Difficult_Rocket/__init__.py +++ b/Difficult_Rocket/__init__.py @@ -24,7 +24,7 @@ from libs.MCDR.version import Version game_version = Version("0.7.1.1") # 游戏版本 build_version = Version("1.1.0.0") # 编译文件版本(与游戏本体无关) -DR_rust_version = Version("0.2.5.1") # DR 的 Rust 编写部分的版本 +DR_rust_version = Version("0.2.5.2") # DR 的 Rust 编写部分的版本 __version__ = game_version long_version: int = 12 diff --git a/libs/Difficult_Rocket_rs/src/Cargo.lock b/libs/Difficult_Rocket_rs/src/Cargo.lock index dc189db..947be75 100644 --- a/libs/Difficult_Rocket_rs/src/Cargo.lock +++ b/libs/Difficult_Rocket_rs/src/Cargo.lock @@ -119,10 +119,9 @@ name = "difficult_rocket_rs" version = "0.2.5" dependencies = [ "pyo3", + "quick-xml", "rapier2d-f64", "serde", - "serde-xml-rs", - "xml-rs", ] [[package]] @@ -165,15 +164,6 @@ dependencies = [ "scopeguard", ] -[[package]] -name = "log" -version = "0.4.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] - [[package]] name = "matrixmultiply" version = "0.3.2" @@ -183,6 +173,12 @@ dependencies = [ "rawpointer", ] +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + [[package]] name = "memoffset" version = "0.7.1" @@ -410,6 +406,16 @@ dependencies = [ "syn", ] +[[package]] +name = "quick-xml" +version = "0.27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffc053f057dd768a56f62cd7e434c42c831d296968997e9ac1f76ea7c2d14c41" +dependencies = [ + "memchr", + "serde", +] + [[package]] name = "quote" version = "1.0.23" @@ -491,18 +497,6 @@ dependencies = [ "serde_derive", ] -[[package]] -name = "serde-xml-rs" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb3aa78ecda1ebc9ec9847d5d3aba7d618823446a049ba2491940506da6e2782" -dependencies = [ - "log", - "serde", - "thiserror", - "xml-rs", -] - [[package]] name = "serde_derive" version = "1.0.152" @@ -571,26 +565,6 @@ version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ae9980cab1db3fceee2f6c6f643d5d8de2997c58ee8d25fb0cc8a9e9e7348e5" -[[package]] -name = "thiserror" -version = "1.0.38" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.38" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "typenum" version = "1.16.0" @@ -690,9 +664,3 @@ name = "windows_x86_64_msvc" version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" - -[[package]] -name = "xml-rs" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2d7d3948613f75c98fd9328cfdcc45acc4d360655289d0a7d4ec931392200a3" diff --git a/libs/Difficult_Rocket_rs/src/Cargo.toml b/libs/Difficult_Rocket_rs/src/Cargo.toml index 7f1cbcd..d1ac159 100644 --- a/libs/Difficult_Rocket_rs/src/Cargo.toml +++ b/libs/Difficult_Rocket_rs/src/Cargo.toml @@ -17,19 +17,19 @@ opt-level = 3 [profile.release] codegen-units = 1 -#[dependencies.quick-xml] -#version = "0.27.1" -#features = ["serialize"] +[dependencies.quick-xml] +version = "0.27.1" +features = ["serialize"] [dependencies.serde] version = "1.0.152" features = ["derive"] -[dependencies.xml-rs] -version = "0.8.4" - -[dependencies.serde-xml-rs] -version = "0.6.0" +#[dependencies.xml-rs] +#version = "0.8.4" +# +#[dependencies.serde-xml-rs] +#version = "0.6.0" [dependencies.rapier2d-f64] version = "0.17.1" diff --git a/libs/Difficult_Rocket_rs/src/src/lib.rs b/libs/Difficult_Rocket_rs/src/src/lib.rs index 570d4dc..cce5092 100644 --- a/libs/Difficult_Rocket_rs/src/src/lib.rs +++ b/libs/Difficult_Rocket_rs/src/src/lib.rs @@ -16,7 +16,7 @@ use pyo3::prelude::*; #[pyfunction] fn get_version_str() -> String { - return String::from("0.2.5.1"); + return String::from("0.2.5.2"); } #[pyfunction] diff --git a/libs/Difficult_Rocket_rs/src/src/sr1_data.rs b/libs/Difficult_Rocket_rs/src/src/sr1_data.rs index e780177..d71e2e4 100644 --- a/libs/Difficult_Rocket_rs/src/src/sr1_data.rs +++ b/libs/Difficult_Rocket_rs/src/src/sr1_data.rs @@ -10,8 +10,11 @@ pub mod part_list { use std::fs; use pyo3::prelude::*; + use serde::{Serialize, Deserialize}; - use serde_xml_rs::{from_str}; + + use quick_xml::de::from_str; + // use serde_xml_rs::{from_str}; #[derive(Debug, Serialize, Deserialize, Clone)] pub struct PartList { @@ -64,64 +67,99 @@ pub mod part_list { #[derive(Debug, Serialize, Deserialize, Copy, Clone)] pub struct Vertex { - pub x: f64, - pub y: f64 + #[serde(rename = "@x")] + pub x: Option, + #[serde(rename = "@y")] + pub y: Option, } #[derive(Debug, Serialize, Deserialize, Clone)] pub struct Shape { - #[serde(rename = "Vertex")] - pub vertex: Vec, + // #[serde(rename = "Vertex")] + // pub vertex: Vec, + #[serde(rename = "@sensor")] pub sensor: Option } - #[derive(Debug, Serialize, Deserialize, Clone)] + #[derive(Debug, Serialize, Deserialize, Copy, Clone)] pub struct AttachPoint { pub location: Option, + #[serde(rename = "@x")] pub x: Option, + #[serde(rename = "@y")] pub y: Option, - #[serde(rename = "breakAngle")] + #[serde(rename = "@breakAngle")] pub break_angle: Option, - #[serde(rename = "breakForce")] + #[serde(rename = "@breakForce")] pub break_force: Option, - #[serde(rename = "fuelLine")] + #[serde(rename = "@fuelLine")] pub fuel_line: Option, + #[serde(rename = "@group")] pub group: Option, + #[serde(rename = "@order")] pub order: Option, } #[derive(Debug, Serialize, Deserialize, Clone)] pub struct AttachPoints { + #[serde(rename = "AttachPoint")] + pub points: Vec + } + #[derive(Debug, Serialize, Deserialize, Clone)] + pub struct PartAttr { + // 单独类型节点 + // pub part_attr: Option>, } #[derive(Debug, Serialize, Deserialize, Clone)] pub struct PartType { + // https://docs.rs/quick-xml/latest/quick_xml/de/index.html + // 基本属性 + #[serde(rename = "@id")] pub id: String, + #[serde(rename = "@name")] pub name: String, + #[serde(rename = "@description")] pub description: String, + #[serde(rename = "@sprite")] pub sprite: String, + #[serde(rename = "@type")] pub r#type: PartTypes, + #[serde(rename = "@mass")] pub mass: f64, + #[serde(rename = "@width")] pub width: u32, + #[serde(rename = "@height")] pub height: u32, + // 可选属性 + #[serde(rename = "@friction")] pub friction: Option, + #[serde(rename = "@category")] pub category: Option, - #[serde(rename = "ignoreEditorIntersections")] + #[serde(rename = "@ignoreEditorIntersections")] pub ignore_editor_intersections: Option, - #[serde(rename = "disableEditorRotation")] + #[serde(rename = "@disableEditorRotation")] pub disable_editor_rotation: Option, - #[serde(rename = "canExplode")] + #[serde(rename = "@canExplode")] pub can_explode: Option, - #[serde(rename = "coverHeight")] + #[serde(rename = "@coverHeight")] pub cover_height: Option, - #[serde(rename = "sandboxOnly")] + #[serde(rename = "@sandboxOnly")] pub sandbox_only: Option, + #[serde(rename = "@drag")] pub drag: Option, + #[serde(rename = "@hidden")] pub hidden: Option, + #[serde(rename = "@buoyancy")] pub buoyancy: Option, + // 通用属性子节点 #[serde(rename = "Shape")] - pub shapes: Option> + pub shape: Option>, + #[serde(rename = "AttachPoints")] + attach_points: Option, + // #[serde(rename = "$value")] + // pub value: PartAttr, } #[inline]