From b0c3a064c29c2bf97981f45806696c2dd0d4dd90 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Wed, 2 Dec 2026 07:24:01 +0400 Subject: feat(ui): preview new warbot geometry during a mission On stock Field Camp, open a compatible Unit DAT created after start, resize the preview, switch to a resident project, reopen the new project, and return to the mission with Vulkan validation clean. The factory reserve for new geometry is still prepared at mission load. --- crates/fparkan-runtime/src/production.rs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'crates/fparkan-runtime/src/production.rs') diff --git a/crates/fparkan-runtime/src/production.rs b/crates/fparkan-runtime/src/production.rs index 3502c45d..0817cfb8 100644 --- a/crates/fparkan-runtime/src/production.rs +++ b/crates/fparkan-runtime/src/production.rs @@ -467,7 +467,19 @@ pub fn factory_saved_schemes( plant: Option, ) -> Result, EngineError> { let (mission, production) = loaded_production(engine)?; - let index = match plant { + let index = player_factory_index(engine, cockpit, plant)?; + Ok(schemes_for_plant(mission, production, index) + .filter_map(|(scheme, _)| production.saved_schemes.contains(&scheme).then_some(scheme)) + .collect()) +} + +pub(super) fn player_factory_index( + engine: &Engine, + cockpit: StartingCockpit, + plant: Option, +) -> Result { + let (mission, production) = loaded_production(engine)?; + Ok(match plant { Some(plant) => { let owner = player_owner(&engine.world, cockpit)?; owned_factories(&engine.world, mission, production, owner) @@ -478,10 +490,7 @@ pub fn factory_saved_schemes( })? } None => factory_at_communicator(&engine.world, mission, production, cockpit)?.0, - }; - Ok(schemes_for_plant(mission, production, index) - .filter_map(|(scheme, _)| production.saved_schemes.contains(&scheme).then_some(scheme)) - .collect()) + }) } fn recent_schemes_for_plant<'a>( @@ -929,7 +938,7 @@ fn set_factory_power( Ok(()) } -fn free_duration_ms(plant: &[u8; 32], robot: &[u8; 32]) -> Option { +pub(super) fn free_duration_ms(plant: &[u8; 32], robot: &[u8; 32]) -> Option { // shortcut: stock chassis and factory keys supply sizes until the // calculated capacity and assembled-scheme descriptors are wired. let plant = plant.split(|&byte| byte == 0).next()?; -- cgit v1.2.3