From cd45231dd2a4fd9f970d9c7e06004cedd5c9add6 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Wed, 2 Dec 2026 05:27:02 +0400 Subject: fix(ui): preserve native recent factory project order --- crates/fparkan-runtime/src/production.rs | 65 +------------------------------- 1 file changed, 1 insertion(+), 64 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 c0db14ab..3d3eb159 100644 --- a/crates/fparkan-runtime/src/production.rs +++ b/crates/fparkan-runtime/src/production.rs @@ -3,7 +3,7 @@ use super::{ behavior_ore_index_for_handle, factory_release::FactoryDeparture, mission_events::on_communicator, - normalize_engine_path, query_behavior_profile_ore_rate, + query_behavior_profile_ore_rate, research::{load_clan_table, RESEARCHED}, route_obstacles::BuildingFootprints, set_control_device_table_selector, @@ -27,46 +27,6 @@ pub(super) const RESERVE_SLOTS: usize = 8; const PAID_MINIMUM_MS: u32 = 5_000; const RESOURCE_EPSILON: f32 = 0.01; -pub(super) fn mission_prebuilds(config: &[u8]) -> Result, EngineError> { - let mut schemes = Vec::new(); - let mut in_prebuild = false; - for line in config.split(|&byte| byte == b'\n') { - let line = line.trim_ascii(); - let mut words = line - .split(u8::is_ascii_whitespace) - .filter(|word| !word.is_empty()); - match words.next() { - Some(word) if word.eq_ignore_ascii_case(b"object") => { - in_prebuild = words - .next() - .is_some_and(|name| name.eq_ignore_ascii_case(b"prebuild")); - } - Some(word) if word.eq_ignore_ascii_case(b"end") => in_prebuild = false, - Some(word) if in_prebuild && !word.starts_with(b"#") && !word.starts_with(b"//") => { - let mut fields = line.splitn(3, |&byte| byte == b'"'); - let key = fields.next().unwrap_or_default(); - let name = fields.next().filter(|name| !name.is_empty()); - if key.trim_ascii_end().ends_with(b"=") && fields.next().is_some() { - if let Some(name) = name { - let name = std::str::from_utf8(name).map_err(production_error)?; - let path = normalize_engine_path( - "mission prebuild", - &format!("UNITS/UNITS/PREBLD/{name}"), - )?; - if !schemes.iter().any(|entry: &NormalizedPath| { - entry.as_bytes().eq_ignore_ascii_case(path.as_bytes()) - }) { - schemes.push(path); - } - } - } - } - _ => {} - } - } - Ok(schemes) -} - pub(super) struct Production { reserve_start: usize, schemes: Vec, @@ -944,29 +904,6 @@ mod tests { panic!("stock AI did not release a combat design in the opening"); } - #[test] - fn mission_prebuilds_preserve_order_and_skip_duplicates() { - let config = b"object other\n model1 = \"ignored.dat\"\nend\r\n\ - OBJECT PreBuild\r\n # model1 = \"comment.dat\"\r\n\ - model2=\"first.dat\"\r\n model1 = \"second.dat\"\r\n model3=\"FIRST.DAT\"\r\nend\n"; - assert_eq!( - mission_prebuilds(config) - .unwrap() - .iter() - .map(NormalizedPath::as_str) - .collect::>(), - [ - "UNITS/UNITS/PREBLD/first.dat", - "UNITS/UNITS/PREBLD/second.dat" - ] - ); - assert!(mission_prebuilds( - b"object prebuild\nend\nobject other\nmodel1 = \"ignored.dat\"\nend" - ) - .unwrap() - .is_empty()); - } - #[test] #[ignore = "requires licensed corpus"] fn licensed_scripted_factory_builds_a_usable_builder() { -- cgit v1.2.3