[fix] Не считать остовы и отключённые передатчики активными в донесении #151
@@ -439,7 +439,7 @@ pub(super) fn area_of(at: DVec3, cell: f64, salt: u32) -> DVec3 {
|
||||
pub(super) fn look(sams: &[Sam], state: &Recon, intel: &ew::Intel, zone: &Zone, now: u64) -> Vec<Look> {
|
||||
let mut out = Vec::new();
|
||||
for s in sams {
|
||||
if horizontal(s.pos - zone.center).length() > zone.radius {
|
||||
if !s.alive() || horizontal(s.pos - zone.center).length() > zone.radius {
|
||||
continue;
|
||||
}
|
||||
if out.len() >= MAX_OBSERVED {
|
||||
@@ -454,8 +454,8 @@ pub(super) fn look(sams: &[Sam], state: &Recon, intel: &ew::Intel, zone: &Zone,
|
||||
// passes just after one can name that source too. Health, magazine and link never are.
|
||||
let launched = intel.contacts().get(&s.id).is_some_and(|c| c.seen == ew::Seen::Launch && now.saturating_sub(c.tick) < 200);
|
||||
let source = match s.kind {
|
||||
SamKind::Ew if s.ew_on => Source::Jamming,
|
||||
SamKind::Radar if s.radar_on => Source::Emission,
|
||||
SamKind::Ew if s.ew_on && !s.moving() && !s.ew_lock => Source::Jamming,
|
||||
SamKind::Radar if s.radar_up() => Source::Emission,
|
||||
_ if launched => Source::Launch,
|
||||
_ => Source::Flyby,
|
||||
};
|
||||
@@ -845,9 +845,13 @@ mod tests {
|
||||
assert_eq!(source(&sim, radar), Source::Flyby, "a silent radar was read as emitting");
|
||||
sim.sams.iter_mut().find(|s| s.id == radar).unwrap().radar_on = true;
|
||||
assert_eq!(source(&sim, radar), Source::Emission);
|
||||
sim.sams.iter_mut().find(|s| s.id == radar).unwrap().state = super::super::SamState::Moving;
|
||||
assert_eq!(source(&sim, radar), Source::Flyby, "a moving radar is not emitting");
|
||||
assert_eq!(source(&sim, ew), Source::Flyby, "a silent jammer was read as transmitting");
|
||||
sim.sams.iter_mut().find(|s| s.id == ew).unwrap().ew_on = true;
|
||||
assert_eq!(source(&sim, ew), Source::Jamming);
|
||||
sim.sams.iter_mut().find(|s| s.id == ew).unwrap().ew_lock = true;
|
||||
assert_eq!(source(&sim, ew), Source::Flyby, "an overheated jammer is not transmitting");
|
||||
sim.intel.observe(sim.sams.iter().find(|s| s.id == s400).unwrap(), sim.tick, ew::Seen::Launch);
|
||||
assert_eq!(source(&sim, s400), Source::Launch);
|
||||
// A hidden empty magazine does not change the source.
|
||||
@@ -855,6 +859,27 @@ mod tests {
|
||||
assert_eq!(source(&sim, s400), Source::Launch);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn wrecks_do_not_create_targets_in_a_new_flyby_report() {
|
||||
let mut sim = Sim::new(8);
|
||||
let object = DVec3::new(0.0, 70.0, 0.0);
|
||||
sam(&mut sim, SamKind::Radar, object);
|
||||
sam(&mut sim, SamKind::Ew, object + DVec3::X * 10.0);
|
||||
sim.sams[0].radar_on = true;
|
||||
sim.sams[1].ew_on = true;
|
||||
for s in &mut sim.sams { s.health = 0.0; }
|
||||
sam(&mut sim, SamKind::Gepard, object + DVec3::X * 20.0);
|
||||
|
||||
sim.start_recon(&[object], 0.0, 300.0, &mut Out::default());
|
||||
let (_, seen) = look_once(&mut sim);
|
||||
sim.tick = seen + REPORT_DELAY;
|
||||
sim.step_recon(&mut Out::default());
|
||||
|
||||
let leads = sim.recon.leads(sim.tick);
|
||||
assert_eq!(leads.len(), 1);
|
||||
assert_eq!(leads[0].category, Category::of(SamKind::Gepard));
|
||||
}
|
||||
|
||||
// #135: the planner's order is the observed public role, freshness and quality, not the
|
||||
// unit id or its true importance. A fresh modest mark outranks an old doubtful big one;
|
||||
// the synthetic ids are only the last deterministic tie.
|
||||
|
||||
Reference in New Issue
Block a user