aboutsummaryrefslogtreecommitdiff
path: root/crates/fparkan-runtime/src/production.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-12-02 04:27:02 +0300
committerValentin Popov <valentin@popov.link>2026-12-02 04:27:02 +0300
commitcd45231dd2a4fd9f970d9c7e06004cedd5c9add6 (patch)
treee8baeb51c2cc808fbb843ef12366298ce188888f /crates/fparkan-runtime/src/production.rs
parentd26da0a21ce2e0e08257a5c545d935acd0ef3bd7 (diff)
downloadfparkan-cd45231dd2a4fd9f970d9c7e06004cedd5c9add6.tar.xz
fparkan-cd45231dd2a4fd9f970d9c7e06004cedd5c9add6.zip
fix(ui): preserve native recent factory project order
Diffstat (limited to 'crates/fparkan-runtime/src/production.rs')
-rw-r--r--crates/fparkan-runtime/src/production.rs65
1 files changed, 1 insertions, 64 deletions
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<Vec<NormalizedPath>, 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<NormalizedPath>,
@@ -945,29 +905,6 @@ mod tests {
}
#[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::<Vec<_>>(),
- [
- "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() {
let root = std::env::var_os("FPARKAN_CORPUS_PART1_ROOT").expect("licensed corpus");