Add none ship compat #24 fixed

This commit is contained in:
shenjack 2023-06-07 00:19:33 +08:00
parent 38cbae7c9d
commit 2f63dd9e74
4 changed files with 35 additions and 9 deletions

10
configs/none_ship.xml Normal file
View File

@ -0,0 +1,10 @@
<Ship version="1" liftedOff="0" touchingGround="0">
<Parts>
<Part partType="pod-1" id="1" x="0.000000" y="0.750000" angle="0.000000" angleV="0.000000" editorAngle="0">
<Pod throttle="0.000000" name="">
<Staging currentStage="0"/>
</Pod>
</Part>
</Parts>
<Connections/>
</Ship>

View File

@ -18,9 +18,20 @@
- 基于 `PyConsole` - 基于 `PyConsole`
- 用于替换 `DR sdk` 的默认控制台方法 - 用于替换 `DR sdk` 的默认控制台方法
## DR rs 0.2.10.1
### `types.rs`
- 兼容了 `Option<Vec<Step>>``sr1_data.rs`
- `Vec<Step>` -> `Option<Vec<Step>>`
### Bug 修复
- [#24](https://github.com/shenjackyuanjie/Difficult-Rocket/issues/24) `无法解析 带 staging 不带 steps的飞船`
## DR rs 0.2.10.0 ## DR rs 0.2.10.0
## `python::PySR1PartType` ### `python::PySR1PartType`
- 添加可从 Python 端获取的部件信息 - 添加可从 Python 端获取的部件信息
- `get_descriptiton -> String` - `get_descriptiton -> String`

View File

@ -472,7 +472,7 @@ pub mod ship {
#[serde(rename = "currentStage")] #[serde(rename = "currentStage")]
pub current_stage: i32, pub current_stage: i32,
#[serde(rename = "Step")] #[serde(rename = "Step")]
pub steps: Vec<Step>, pub steps: Option<Vec<Step>>,
} }
#[derive(Debug, Serialize, Deserialize, Clone)] #[derive(Debug, Serialize, Deserialize, Clone)]

View File

@ -439,7 +439,7 @@ pub mod sr1 {
} }
let stages = RawStaging { let stages = RawStaging {
current_stage: current_stage.to_owned(), current_stage: current_stage.to_owned(),
steps: actives, steps: Some(actives),
}; };
RawPod { RawPod {
name: name.clone(), name: name.clone(),
@ -629,7 +629,9 @@ pub mod sr1 {
Some(pod.stages.current_stage), Some(pod.stages.current_stage),
Some({ Some({
let mut steps = Vec::new(); let mut steps = Vec::new();
for step in &pod.stages.steps { match &pod.stages.steps {
Some(step_vec) => {
for step in step_vec {
let mut step_vec = Vec::new(); let mut step_vec = Vec::new();
if let Some(active) = &step.activates { if let Some(active) = &step.activates {
for act in active { for act in active {
@ -638,6 +640,9 @@ pub mod sr1 {
} }
steps.push(step_vec); steps.push(step_vec);
} }
}
None => {}
}
steps steps
}), }),
) )