aboutsummaryrefslogtreecommitdiff
path: root/crates/fparkan-assets/src/lib.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-12-01 07:33:51 +0300
committerValentin Popov <valentin@popov.link>2026-12-01 07:33:51 +0300
commit777f48345c7faf891ac105fc4a831114914aff5d (patch)
treea9e550c582aa976d87e6c0ae4297e7c29e6e5526 /crates/fparkan-assets/src/lib.rs
parent352026c1ce039443efc779876b27654d992bfff1 (diff)
downloadfparkan-777f48345c7faf891ac105fc4a831114914aff5d.tar.xz
fparkan-777f48345c7faf891ac105fc4a831114914aff5d.zip
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.
Diffstat (limited to 'crates/fparkan-assets/src/lib.rs')
-rw-r--r--crates/fparkan-assets/src/lib.rs20
1 files changed, 15 insertions, 5 deletions
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<u32>,
/// 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,