From a09bc5526cb8f5a38099c5c0bc2b6bb4b47ddfda Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Wed, 25 Nov 2026 18:21:40 +0400 Subject: feat(research): unlock dependent and zero-cost technologies Apply MisLoad's enabled/available/learned flag transitions after laboratory completion. Scan every enabled unavailable row against all prerequisites, then follow Behavior's ordered zero-cost child completion. Publish learned descendants to construction and production and replace the unlock stub with per-clan availability counters. Direct calls to original MisLoad.dll 0x2c10 and Behavior.dll 0x23aa0 confirm flag preservation, disabled prerequisites, positive/negative cost exclusion, and free child recursion. Licensed table checks cover the stock first AI project and a project with two automatic child technologies. The first stock AI project opens no additional rows in either implementation. Workspace fmt/check/tests, licensed laboratory regression, 29 stock missions at 900 seconds and a stock Vulkan window check pass. This removes the completion coverage gap needed by the next research-policy task; it does not establish full project chaining or live AI chronology. Handlers 65/69 remain explicit stubs. --- crates/fparkan-assets/src/research.rs | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) (limited to 'crates/fparkan-assets/src/research.rs') diff --git a/crates/fparkan-assets/src/research.rs b/crates/fparkan-assets/src/research.rs index cba41c95..a32ebc01 100644 --- a/crates/fparkan-assets/src/research.rs +++ b/crates/fparkan-assets/src/research.rs @@ -10,6 +10,9 @@ use fparkan_vfs::Vfs; use std::collections::HashMap; use std::fmt; use std::sync::Arc; +#[path = "research_completion.rs"] +mod completion; +pub use completion::ResearchCompletion; const TRF0: u32 = u32::from_le_bytes(*b"TRF0"); const TRF1: u32 = u32::from_le_bytes(*b"TRF1"); @@ -193,6 +196,8 @@ pub enum ResearchError { }, /// A required non-empty relation stream is absent. MissingRelationStream { type_id: u32, required_ids: u64 }, + /// An unfinished free descendant leads back to an active completion. + CyclicResearchCompletion { index: usize }, /// A candidate Unit DAT resource field is not NUL-terminated. MissingCandidateKeyTerminator { component_index: usize }, /// No TRFB key matches an enabled candidate component. @@ -216,6 +221,7 @@ pub enum ResearchError { impl fmt::Display for ResearchError { fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { match self { + Self::CyclicResearchCompletion { index } => write!(formatter, "cyclic free research completion at row {index}"), Self::Nres(source) => write!(formatter, "{source}"), Self::Binary(source) => write!(formatter, "{source}"), Self::MissingChunk { type_id } => { @@ -326,6 +332,7 @@ impl std::error::Error for ResearchError { | Self::UnsupportedNonAsciiLookup { .. } | Self::EmptyResearchTable | Self::EmptyCandidateTree => None, + Self::CyclicResearchCompletion { .. } => None, } } } @@ -492,24 +499,6 @@ impl ResearchTrfDocument { self.flags.get(index).copied() } - /// Sets the researched bit without propagating availability to related rows. - /// - /// # Errors - /// Rejects a row outside the decoded table. - pub fn mark_researched_flag(&mut self, index: usize) -> Result<(), ResearchError> { - let count = self.flags.len(); - let flag = self - .flags - .get_mut(index) - .ok_or(ResearchError::InvalidResearchIndex { - type_id: TRF1, - index: u32::try_from(index).unwrap_or(u32::MAX), - row_count: count, - })?; - *flag |= 2; - Ok(()) - } - /// Returns the raw name bytes selected by a row's low-16-bit TRFB link. /// /// # Errors -- cgit v1.2.3