From 777f48345c7faf891ac105fc4a831114914aff5d Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Tue, 1 Dec 2026 08:33:51 +0400 Subject: fix(combat): charge the drive before refilling weapons Read the resource multiplier from CTL when all authored states agree and price the latest local motion in the existing Control budget. A licensed AutoDemo flyer charges its weapons more slowly when the drive is drawing from the same supply. Control.dll oracle vectors, the AutoDemo window, and all 29 mission startup sweeps pass. --- crates/fparkan-assets/src/lib.rs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'crates/fparkan-assets/src/lib.rs') diff --git a/crates/fparkan-assets/src/lib.rs b/crates/fparkan-assets/src/lib.rs index 4738f175..88c3b193 100644 --- a/crates/fparkan-assets/src/lib.rs +++ b/crates/fparkan-assets/src/lib.rs @@ -1039,6 +1039,8 @@ pub struct PreparedComponentControl { pub source: ResourceKey, /// The 27 raw native owner-profile words at CTLD bytes 20..128. pub native_profile_words: [u32; 27], + /// Drive demand multiplier when all authored CTL states agree. + pub uniform_drive_factor_bits: Option, /// Number of nodes in the component model this control targets. pub model_node_count: usize, /// Enabled source rows in their original order, including duplicate nodes. @@ -4281,12 +4283,11 @@ fn decode_component_control_payload_with_opcodes( let per_section_node_bytes = SECTION_NODE_BYTES .checked_mul(per_section_nodes) .ok_or_else(|| invalid("section node bytes overflow"))?; + let section_stride = SECTION_FIXED_BYTES + .checked_add(per_section_node_bytes) + .ok_or_else(|| invalid("section size overflows"))?; let section_bytes = section_count - .checked_mul( - SECTION_FIXED_BYTES - .checked_add(per_section_node_bytes) - .ok_or_else(|| invalid("section size overflows"))?, - ) + .checked_mul(section_stride) .ok_or_else(|| invalid("section table bytes overflow"))?; let matrix_bytes = section_count .checked_mul(section_count) @@ -4381,10 +4382,19 @@ fn decode_component_control_payload_with_opcodes( )?; let initial_group_opcodes = decoded_effect.initial_group_opcodes; + // Control copies CTL state +0x54 into the active owner field +0x154. + let state_start = HEADER_BYTES + FIXED_SECTION_BYTES; + let mut factors = payload[state_start..state_start + section_bytes] + .chunks_exact(section_stride) + .map(|state| control_u32_at(state, 0x54).expect("complete CTL state")); + let uniform_drive_factor_bits = factors + .next() + .filter(|&first| factors.all(|next| next == first)); Ok(( PreparedComponentControl { source, native_profile_words, + uniform_drive_factor_bits, model_node_count, bindings, timeline_rows, -- cgit v1.2.3