Finish AirDef catalog, route, stock and observation fixes
build / mod (push) Successful in 30m46s

Refs #91, #114, #118, #135. Show the latest recorded unit decision in the native card (#153).
This commit is contained in:
2026-12-02 18:22:22 +03:00
parent 9e0cec13f2
commit 7612d15963
38 changed files with 942 additions and 737 deletions
+16 -14
View File
@@ -241,7 +241,7 @@ impl Sam {
}
/// Change the physical configuration. Invalid combinations leave the unit untouched.
pub fn set_mode(&mut self, mode: SamMode) -> bool {
if mode == SamMode::LauncherOnly && !matches!(self.kind, SamKind::S400 | SamKind::S500) { return false; }
if mode == SamMode::LauncherOnly && !catalog::has_separate_launcher(self.kind) { return false; }
if self.mode != mode {
self.mode = mode;
self.tracks.clear();
@@ -269,7 +269,7 @@ impl Sim {
self.sams.iter().enumerate().filter_map(|(index, sam)| {
if sam.kind == SamKind::Radar {
Some(BatteryStatus::Radar { index, role: sam.radar_role, emitting: sam.radar_on, operational: sam.radar_up() && sam.link_range() > 0.0 })
} else if matches!(sam.kind, SamKind::S400 | SamKind::S500) {
} else if catalog::has_separate_launcher(sam.kind) {
let linked = self.sams.iter().any(|r| r.kind == SamKind::Radar && r.radar_role.authorizes() && r.radar_up() && r.link_range() > 0.0 && sam.link_range() > 0.0 && r.pos.distance(sam.pos) <= r.link_range().min(sam.link_range()));
Some(BatteryStatus::Launcher { index, kind: sam.kind, mode: sam.mode, linked })
} else { None }
@@ -540,30 +540,32 @@ mod emission_tests {
assert_eq!(sim.sams[1].track(id).unwrap().own_tick, 0);
assert_eq!(sim.sams[1].track(id).unwrap().tick, 20);
assert!(!sim.sams[1].radar_up());
// The emitting source is fixed by the drone; the silent receiver is not.
let picture = sim.picture_of_defences();
// The emitting source gives the drone a coarse area. The silent receiver stays hidden.
let picture = sim.knowledge_now().observations();
assert_eq!(picture.len(), 1);
assert_eq!((picture[0].id, picture[0].at), (1, DVec3::ZERO));
assert_eq!(picture[0].seen, ew::Seen::Emission);
let signal = picture[0];
assert!(recon::is_mark(signal.id) && !signal.exact());
assert_eq!((signal.channel, signal.kind), (recon::Source::Emission, None));
sim.sams[0].radar_on = false;
// The truth moving is not an observation: the contact keeps the observed place.
sim.sams[0].pos = DVec3::new(400.0, 0.0, 0.0);
sim.tick = 40;
sim.update_sight(&mut ground);
assert_eq!(sim.sams[1].track(id).unwrap().tick, 20);
let picture = sim.picture_of_defences();
assert_eq!(picture.len(), 1);
assert_eq!(picture[0].at, DVec3::ZERO, "a hidden move changed the picture");
// A fresh emission fix re-places it where seen then.
assert_eq!(sim.knowledge_now().observations(), picture, "a hidden move changed the picture");
// A fresh witnessed emission moves the estimated area.
sim.sams[0].radar_on = true;
sim.tick = 60;
sim.update_sight(&mut ground);
assert_eq!(sim.picture_of_defences()[0].at, DVec3::new(400.0, 0.0, 0.0));
let moved = sim.knowledge_now().observations()[0];
assert_eq!(moved.id, signal.id);
assert!(moved.at != signal.at && moved.at != sim.sams[0].pos);
assert!(moved.at.distance(sim.sams[0].pos) < moved.radius);
sim.sams[0].radar_on = false;
// Other disclosure channels still reveal a silent unit.
sim.intel.observe(&sim.sams[1], 60, ew::Seen::Launch);
assert!(sim.known_live(2));
sim.recon.signal(&sim.sams[1], 60, recon::Source::Launch);
assert!(sim.knowledge_now().observations().iter().any(|o| o.channel == recon::Source::Launch && !o.exact()));
sim.tick = 6060;
assert!(sim.picture_of_defences().is_empty(), "an unrefreshed contact never ages out");
assert!(sim.knowledge_now().observations().is_empty(), "an unrefreshed contact never ages out");
}
}