From 2f63dd9e7476ec79aaec67c0b8bbc455b2af7fe4 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Wed, 7 Jun 2023 00:19:33 +0800 Subject: [PATCH] Add none ship compat #24 fixed --- configs/none_ship.xml | 10 ++++++++++ docs/src/change_log/dr_game.md | 13 ++++++++++++- .../Difficult_Rocket_rs/src/src/sr1_data.rs | 2 +- .../Difficult_Rocket_rs/src/src/types.rs | 19 ++++++++++++------- 4 files changed, 35 insertions(+), 9 deletions(-) create mode 100644 configs/none_ship.xml diff --git a/configs/none_ship.xml b/configs/none_ship.xml new file mode 100644 index 0000000..7427eec --- /dev/null +++ b/configs/none_ship.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/docs/src/change_log/dr_game.md b/docs/src/change_log/dr_game.md index 3aeb592..22a0d79 100644 --- a/docs/src/change_log/dr_game.md +++ b/docs/src/change_log/dr_game.md @@ -18,9 +18,20 @@ - 基于 `PyConsole` - 用于替换 `DR sdk` 的默认控制台方法 +## DR rs 0.2.10.1 + +### `types.rs` + +- 兼容了 `Option>` 的 `sr1_data.rs` + - `Vec` -> `Option>` + +### Bug 修复 + +- [#24](https://github.com/shenjackyuanjie/Difficult-Rocket/issues/24) `无法解析 带 staging 不带 steps的飞船` + ## DR rs 0.2.10.0 -## `python::PySR1PartType` +### `python::PySR1PartType` - 添加可从 Python 端获取的部件信息 - `get_descriptiton -> String` diff --git a/mods/dr_game/Difficult_Rocket_rs/src/src/sr1_data.rs b/mods/dr_game/Difficult_Rocket_rs/src/src/sr1_data.rs index d47e212..b4c6794 100644 --- a/mods/dr_game/Difficult_Rocket_rs/src/src/sr1_data.rs +++ b/mods/dr_game/Difficult_Rocket_rs/src/src/sr1_data.rs @@ -472,7 +472,7 @@ pub mod ship { #[serde(rename = "currentStage")] pub current_stage: i32, #[serde(rename = "Step")] - pub steps: Vec, + pub steps: Option>, } #[derive(Debug, Serialize, Deserialize, Clone)] diff --git a/mods/dr_game/Difficult_Rocket_rs/src/src/types.rs b/mods/dr_game/Difficult_Rocket_rs/src/src/types.rs index 42d8f38..ca77063 100644 --- a/mods/dr_game/Difficult_Rocket_rs/src/src/types.rs +++ b/mods/dr_game/Difficult_Rocket_rs/src/src/types.rs @@ -439,7 +439,7 @@ pub mod sr1 { } let stages = RawStaging { current_stage: current_stage.to_owned(), - steps: actives, + steps: Some(actives), }; RawPod { name: name.clone(), @@ -629,14 +629,19 @@ pub mod sr1 { Some(pod.stages.current_stage), Some({ let mut steps = Vec::new(); - for step in &pod.stages.steps { - let mut step_vec = Vec::new(); - if let Some(active) = &step.activates { - for act in active { - step_vec.push((act.id, i8_to_bool(act.moved))); + match &pod.stages.steps { + Some(step_vec) => { + for step in step_vec { + let mut step_vec = Vec::new(); + if let Some(active) = &step.activates { + for act in active { + step_vec.push((act.id, i8_to_bool(act.moved))); + } + } + steps.push(step_vec); } } - steps.push(step_vec); + None => {} } steps }),