From c83b6fcdc97a193184552b436086a76679d024ba Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Tue, 1 Dec 2026 07:18:14 +0400 Subject: fix(audio): play engine loops for autonomous missiles Keep one spatial Op2 source per flight while it moves, with separate identities from manual and scene emitters. Confirm the original mode 5 phase and verify launch, overlap and teardown on the GOG AutoDemo. Flight-speed changes and a listening comparison with the original remain open. --- crates/fparkan-runtime/src/lib.rs | 7 +++++++ crates/fparkan-runtime/src/unit_combat.rs | 9 +++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'crates') diff --git a/crates/fparkan-runtime/src/lib.rs b/crates/fparkan-runtime/src/lib.rs index 1a9eb405..cdd8d35a 100644 --- a/crates/fparkan-runtime/src/lib.rs +++ b/crates/fparkan-runtime/src/lib.rs @@ -3459,6 +3459,13 @@ pub fn autonomous_weapon_effects(engine: &Engine) -> &[(String, String)] { pub fn autodemo_projectiles( engine: &Engine, ) -> impl Iterator + '_ { + autonomous_projectile_flights(engine).map(|(_, projectile, pose)| (projectile, pose)) +} + +/// Active autonomous flights with IDs stable across combat steps and pool reuse. +pub fn autonomous_projectile_flights( + engine: &Engine, +) -> impl Iterator + '_ { engine .autodemo_combat .iter() diff --git a/crates/fparkan-runtime/src/unit_combat.rs b/crates/fparkan-runtime/src/unit_combat.rs index 2d6a3715..1ebbac2a 100644 --- a/crates/fparkan-runtime/src/unit_combat.rs +++ b/crates/fparkan-runtime/src/unit_combat.rs @@ -95,6 +95,7 @@ pub(super) struct AutoDemoCombat { projectiles: Vec, weapon_effects: Vec<(String, String)>, flights: Vec, + next_flight_id: u64, finished_segments: Vec<(usize, [[f32; 3]; 2])>, pose_failures: super::WeaponPoseReport, pub(super) report: CombatReport, @@ -130,6 +131,7 @@ impl Unit { } struct Flight { + id: u64, shooter: ObjectHandle, shooter_identity: CombatObject, projectile: usize, @@ -171,6 +173,7 @@ impl AutoDemoCombat { projectiles: Vec::new(), weapon_effects: Vec::new(), flights: Vec::new(), + next_flight_id: 0, finished_segments: Vec::new(), pose_failures: super::WeaponPoseReport::default(), report: CombatReport::default(), @@ -320,10 +323,10 @@ impl AutoDemoCombat { .aim(component) } - pub(super) fn flights(&self) -> impl Iterator + '_ { + pub(super) fn flights(&self) -> impl Iterator + '_ { self.flights .iter() - .map(|flight| (flight.projectile, flight.pose)) + .map(|flight| (flight.id, flight.projectile, flight.pose)) } pub(super) fn segments(&self) -> impl Iterator + '_ { @@ -701,12 +704,14 @@ impl AutoDemoCombat { PlayerProjectile::new(from, direction, data.speed, data.lifetime_ms, now) { self.flights.push(Flight { + id: self.next_flight_id, shooter: unit.handle, shooter_identity: shooter, projectile, pose, segment: None, }); + self.next_flight_id += 1; self.report .shot(shooter, CombatObject::read(&engine.world, target), now); events.push(AutoDemoCombatEvent::Shot { -- cgit v1.2.3