Files
airdef/airdef-mod/src/sim/voices.rs
T
chexit 0937ac9e05 fix: keep the P1-SUN motor voice at its played 1.6 pitch
The old engine_voice returned early for flame == 0 with
(DRONE_LANCET, 0.8, 1.6), so the later `P1sun => 1.7` match arm was
unreachable. The catalog migration mistook that arm for the played value
and stored 1.7, which changed the interceptor drone's flight sound.
specs.json is back to 1.6 and specs_generated.rs is regenerated.

Adds missile_engine_voices_keep_their_played_values, pinning P1-SUN to
(DRONE_LANCET, 0.8, 1.6) and M48N6 to (MISSILE_FLIGHT, 1.0, 0.88).

The continuation and handoff text now describe the early return instead
of the dead arm, and tools/airdef_assets/catalog.py gets its final
newline back.

Verified: gen_catalog --check and test_gen_assets, core release
195 passed + 8 scenarios (7 ignored), adapter 64 unit + 1 boundary +
5 scenarios, WASM contract 27 steps.
2026-11-04 21:00:35 +03:00

42 lines
1.6 KiB
Rust

//! What the simulation tells the engine sources (`crate::engines`): which sound an entity's
//! engine makes, from the specs the rest of the simulation owns.
use super::{DroneKind, MissileKind};
impl DroneKind {
/// The sound of its engine and its pitch; none for the ballistic ones, which fall with a
/// scream played once (and the Oreshnik's blocks and submunitions, which have no engine).
pub fn engine_voice(self) -> Option<(&'static str, f32)> {
let spec = self.spec();
if spec.ballistic.is_some() || matches!(self, DroneKind::OreshnikBlock | DroneKind::OreshnikSub) {
return None;
}
Some((spec.sound.0, spec.sound.1))
}
}
impl MissileKind {
/// The sound of its motor, its gain and its pitch: a rocket's roar, or the electric whine of
/// a motor without a flame.
pub fn engine_voice(self) -> (&'static str, f32, f32) {
self.spec().voice
}
/// Ticks from the launch until the motor lights (a cold launch throws it out of the tube first).
pub fn lit_after(self) -> u32 {
self.spec().cold
}
}
#[cfg(test)]
mod tests {
use super::*;
use super::super::catalog::sound;
/// The catalog holds the voice that is actually played. P1-SUN has no flame, so it uses the
/// Lancet voice at 1.6; its old `P1sun => 1.7` match arm was unreachable behind `flame == 0`.
#[test]
fn missile_engine_voices_keep_their_played_values() {
assert_eq!(MissileKind::P1sun.engine_voice(), (sound::DRONE_LANCET, 0.8, 1.6));
assert_eq!(MissileKind::M48n6.engine_voice(), (sound::MISSILE_FLIGHT, 1.0, 0.88));
}
}