diff options
Diffstat (limited to 'crates/fparkan-runtime/src/robot_designer.rs')
| -rw-r--r-- | crates/fparkan-runtime/src/robot_designer.rs | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/crates/fparkan-runtime/src/robot_designer.rs b/crates/fparkan-runtime/src/robot_designer.rs index 289881f0..f196f9c1 100644 --- a/crates/fparkan-runtime/src/robot_designer.rs +++ b/crates/fparkan-runtime/src/robot_designer.rs @@ -110,7 +110,7 @@ pub fn restore_factory_design( }) } -fn restore_mounts( +pub(super) fn restore_mounts( base: &[UnitComponentRecord], project: &[UnitComponentRecord], ) -> Option<Vec<FactoryPartChange>> { @@ -429,15 +429,7 @@ pub(super) fn starting_designs( vfs: Arc<dyn Vfs>, mission: &MissionDocument, ) -> (Arc<dyn Vfs>, Vec<NormalizedPath>) { - let mut players = mission - .clans - .iter() - .enumerate() - .filter(|(_, clan)| clan.mode == 1); - let Some(owner) = players.next().filter(|_| players.next().is_none()) else { - return (vfs, Vec::new()); - }; - let Ok(owner) = u16::try_from(owner.0).map(OwnerId) else { + let Some(owner) = mission_player(mission) else { return (vfs, Vec::new()); }; let Ok(research) = crate::research::load_technology_table(vfs.as_ref(), mission, owner) else { @@ -495,6 +487,16 @@ pub(super) fn starting_designs( ) } +pub(super) fn mission_player(mission: &MissionDocument) -> Option<OwnerId> { + let mut players = mission + .clans + .iter() + .enumerate() + .filter(|(_, clan)| clan.mode == 1); + let (index, _) = players.next().filter(|_| players.next().is_none())?; + u16::try_from(index).ok().map(OwnerId) +} + fn adapt_template( mut bytes: Vec<u8>, research: &ResearchTrfDocument, |
