aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-11-26 07:14:18 +0300
committerValentin Popov <valentin@popov.link>2026-11-26 07:14:18 +0300
commit00e8ddb1ca169e0bf38bde14eaa73969b9177d1a (patch)
tree0b36f51ce6a56c588135d1170eaa10be9210904c /crates
parent161c3fad038c5fae15d49ba614bee37cbcdde6f6 (diff)
downloadfparkan-00e8ddb1ca169e0bf38bde14eaa73969b9177d1a.tar.xz
fparkan-00e8ddb1ca169e0bf38bde14eaa73969b9177d1a.zip
feat(audio): drive chassis engine loops from actual movement
Prepare the authored root-node CTL attachments and feed Control speed limits plus observed motion into FX modes 5 and 15. The stock AutoDemo window queues ground and flight engine loops from the starting scene.
Diffstat (limited to 'crates')
-rw-r--r--crates/fparkan-assets/src/lib.rs30
-rw-r--r--crates/fparkan-runtime/src/lib.rs3
-rw-r--r--crates/fparkan-runtime/src/player_weapon.rs5
3 files changed, 29 insertions, 9 deletions
diff --git a/crates/fparkan-assets/src/lib.rs b/crates/fparkan-assets/src/lib.rs
index 9647b260..73baa707 100644
--- a/crates/fparkan-assets/src/lib.rs
+++ b/crates/fparkan-assets/src/lib.rs
@@ -1196,17 +1196,18 @@ pub enum PreparedControlEffectSection {
Parsed(Vec<PreparedControlEffectRow>),
}
-/// One native type-4 effect row, with point indices kept relative to the
-/// component-local CPT list selected by its control message.
+/// One native effect row. Type 4 uses CPT offsets. Type 3 attaches to a node.
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct PreparedControlEffectRow {
/// Index of the enclosing fixed-size row table.
pub table_index: usize,
/// Index within the enclosing fixed-size row table.
pub row_index: usize,
+ /// Native row opcode. Supported placements are type 3 and type 4.
+ pub opcode: u32,
/// The first three raw condition words consumed by the native checker.
pub raw_condition: [u32; 3],
- /// Component-local offsets into the selected point list.
+ /// Component-local CPT offsets for type 4. Type 3 uses the first word as a node offset.
pub point_offsets: [u32; 3],
/// The raw native effect selector, including `u32::MAX` auto-selector.
pub selector: u32,
@@ -3666,7 +3667,7 @@ fn prepare_component_control_from_resource<R: ResourceRepository>(
resolve_control_gate_providers(&mut control, node_data_source.as_ref());
let has_effect_rows = matches!(
&control.effect_section,
- PreparedControlEffectSection::Parsed(rows) if !rows.is_empty()
+ PreparedControlEffectSection::Parsed(rows) if rows.iter().any(|row| row.opcode == 4)
);
let Some(point_source) = point_source.filter(|_| has_effect_rows) else {
return Ok(Some(control));
@@ -4110,7 +4111,7 @@ where
.expect("valid initial group has an opcode list")
.push(opcode);
}
- if opcode != 4 {
+ if !matches!(opcode, 3 | 4) {
continue;
}
let raw_condition = [
@@ -4126,6 +4127,7 @@ where
effect_rows.push(PreparedControlEffectRow {
table_index,
row_index,
+ opcode,
raw_condition,
point_offsets,
selector: control_u32_at(row, 0x1C).expect("fixed effect row has selector"),
@@ -6738,6 +6740,7 @@ mod tests {
PreparedControlEffectSection::Parsed(vec![PreparedControlEffectRow {
table_index: 0,
row_index: 0,
+ opcode: 4,
raw_condition: [4, 5, 6],
point_offsets: [12, 13, 14],
selector: 15,
@@ -6805,7 +6808,7 @@ mod tests {
}
#[test]
- fn component_control_type4_rows_preserve_fields_and_skip_other_types() {
+ fn component_control_keeps_node_and_point_effect_placements() {
let source = ResourceKey {
archive: parse_path("controls.rlb").expect("archive"),
name: resource_name(b"parts.ctl"),
@@ -6857,7 +6860,20 @@ mod tests {
PreparedControlEffectSection::Parsed(vec![
PreparedControlEffectRow {
table_index: 0,
+ row_index: 0,
+ opcode: 3,
+ raw_condition: [1, 2, 3],
+ point_offsets: [10, 0, 0],
+ selector: 8000,
+ resource: PreparedControlResourcePair {
+ archive: fixed_name("effects.rlb"),
+ name: fixed_name("door_open_02"),
+ },
+ },
+ PreparedControlEffectRow {
+ table_index: 0,
row_index: 1,
+ opcode: 4,
raw_condition: [0, 7, 9],
point_offsets: [104, 105, 106],
selector: 17,
@@ -6869,6 +6885,7 @@ mod tests {
PreparedControlEffectRow {
table_index: 1,
row_index: 0,
+ opcode: 4,
raw_condition: [13, 14, 15],
point_offsets: [85, 85, 85],
selector: 26,
@@ -8854,6 +8871,7 @@ mod tests {
PreparedControlEffectRow {
table_index: 0,
row_index,
+ opcode: 4,
raw_condition: [0; 3],
point_offsets: [0, 1, 2],
selector: u32::try_from(row_index + 1).expect("small effect selector"),
diff --git a/crates/fparkan-runtime/src/lib.rs b/crates/fparkan-runtime/src/lib.rs
index 4895135a..4efbc365 100644
--- a/crates/fparkan-runtime/src/lib.rs
+++ b/crates/fparkan-runtime/src/lib.rs
@@ -451,7 +451,7 @@ fn factory2_selected_fx_resources_are_representable<R: ResourceRepository>(
};
let selected_rows = rows
.iter()
- .filter(|row| Some(row.table_index) == control.initial_effect_group)
+ .filter(|row| row.opcode == 4 && Some(row.table_index) == control.initial_effect_group)
.collect::<Vec<_>>();
if selected_rows.len() != selected_opcode4_count {
return Ok(false);
@@ -8741,6 +8741,7 @@ mod tests {
PreparedControlEffectRow {
table_index,
row_index,
+ opcode: 4,
raw_condition: [0; 3],
point_offsets,
selector: 0,
diff --git a/crates/fparkan-runtime/src/player_weapon.rs b/crates/fparkan-runtime/src/player_weapon.rs
index 00ead0db..2ced63cd 100644
--- a/crates/fparkan-runtime/src/player_weapon.rs
+++ b/crates/fparkan-runtime/src/player_weapon.rs
@@ -345,7 +345,7 @@ fn firing_effect_row<'a>(
.find(|&&(table, node, _)| table == group && node as usize == muzzle.node_index)
{
rows.iter()
- .find(|row| row.table_index == group && row.selector == selector)
+ .find(|row| row.opcode == 4 && row.table_index == group && row.selector == selector)
} else {
// Separate gun meshes can have one firing record and an effect whose
// first control point is the same muzzle. Ambiguous rows stay unresolved.
@@ -359,7 +359,8 @@ fn firing_effect_row<'a>(
return None;
}
let mut candidates = rows.iter().filter(|row| {
- row.table_index == group
+ row.opcode == 4
+ && row.table_index == group
&& row.raw_condition == [0; 3]
&& row.point_offsets[0] == muzzle.raw_parameters[1]
});