diff options
| author | Valentin Popov <valentin@popov.link> | 2026-12-01 17:52:41 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-12-01 17:52:41 +0300 |
| commit | f7c5c3bffd565bb6b0995a220ecb7788471b7848 (patch) | |
| tree | 09c33ae6a42b491035c3f0cf53bdefb604da72ff /crates/fparkan-assets/src/lib.rs | |
| parent | 5f4850555ac2fd62009cffd5e98ea04c081bbaf7 (diff) | |
| download | fparkan-f7c5c3bffd565bb6b0995a220ecb7788471b7848.tar.xz fparkan-f7c5c3bffd565bb6b0995a220ecb7788471b7848.zip | |
fix(control): select authored drive states for mobile power demand
Diffstat (limited to 'crates/fparkan-assets/src/lib.rs')
| -rw-r--r-- | crates/fparkan-assets/src/lib.rs | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/crates/fparkan-assets/src/lib.rs b/crates/fparkan-assets/src/lib.rs index 4d2f7366..53f58568 100644 --- a/crates/fparkan-assets/src/lib.rs +++ b/crates/fparkan-assets/src/lib.rs @@ -32,6 +32,7 @@ pub use fparkan_texm::{PageRect, RgbaImage}; use fparkan_vfs::DirectoryVfs; mod behavior_profile_values; mod chassis_profile; +mod control_drive; mod control_weapon_sound; mod explosion_profile; mod turret_elevation; @@ -39,6 +40,7 @@ pub use behavior_profile_values::{ decode_behavior_go_speed_percent, decode_behavior_work_rates, BehaviorWorkRates, }; pub use chassis_profile::{decode_chassis_can_fly, decode_chassis_flags, ChassisFlags}; +pub use control_drive::{ControlDriveStates, PreparedControlDrive}; pub use explosion_profile::decode_explosion_effect; pub use turret_elevation::{apply_manual_turret_elevation, turret_elevation_row}; mod research; @@ -1040,8 +1042,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>, + /// Authored drive demand multipliers and their supported selection rules. + pub drive: PreparedControlDrive, /// 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. @@ -4383,19 +4385,18 @@ 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)); + let state_end = state_start + section_bytes; + let drive = control_drive::decode( + &payload[state_start..state_end], + section_stride, + &payload[state_end..row_start], + ); Ok(( PreparedComponentControl { source, native_profile_words, - uniform_drive_factor_bits, + drive, model_node_count, bindings, timeline_rows, |
