Exercise strike delivery across movement and save restore
build / mod (push) Failing after 18s

Co-authored-by: Codex <codex@openai.com>
This commit is contained in:
2026-11-02 23:53:14 +03:00
parent c775f31544
commit 952a10f360
3 changed files with 185 additions and 0 deletions
+76
View File
@@ -2540,6 +2540,82 @@ mod tests {
use super::*;
fn test_mod() -> AirDef {
AirDef {
sim: Sim::new(1),
ground: Ground::default(),
dirty: false,
next_save: 0,
hud_shown: false,
monitor: None,
monitor_shown: false,
grid: false,
grid_ids: Vec::new(),
wave: wave::WaveConfig::default(),
presentation: presentation::Session::default(),
block_log: None,
time_view: false,
film_prev: None,
smoke: Default::default(),
far: true,
acoustics: None,
moving: None,
hd: false,
world: None,
health_mark: 0,
menu: None,
listener: DVec3::ZERO,
punch: 0.0,
pending: Vec::new(),
engines: engines::Engines::default(),
engine_gen: u32::MAX,
engines_replay: false,
model_ids: std::collections::HashMap::new(),
model_generation: u32::MAX,
by_id: Vec::new(),
map: map::MapUi::default(),
}
}
#[test]
fn delivery_request_and_cargo_survive_full_state_round_trip() {
struct Flat;
impl sim::world::WorldSource for Flat {
fn solid(&self, _: i32, y: i32, _: i32) -> Option<bool> { Some(y < 64) }
}
let mut before = test_mod();
for (kind, x) in [(SamKind::Depot, 0.0), (SamKind::S400, 160.0), (SamKind::Tzm, 30.0)] {
let id = before.sim.id();
before.sim.sams.push(Sam::new(id, kind, DVec3::new(x, 64.0, 0.0), 0.0));
}
before.sim.sams[1].ground_request = true;
before.sim.sams[1].ground_rounds = 1;
before.sim.sams[1].missiles = 3;
before.sim.sams[2].ground_stock = 1;
before.sim.order_move(2, DVec3::new(100.0, 64.0, 0.0));
let text = before.state_text(false, false);
let mut after = test_mod();
after.apply_state(&text).unwrap();
assert_eq!((after.sim.sams[0].ground_stock, after.sim.sams[1].ground_rounds, after.sim.sams[1].missiles), (0, 1, 3));
assert!(after.sim.sams[1].ground_request);
assert_eq!(after.sim.sams[2].ground_stock, 1);
assert!(after.sim.sams[2].moving());
let mut out = Out::default();
for _ in 0..6000 {
let now = after.sim.tick;
let cols = after.ground.take_wanted().into_iter().map(|(x, z)| (x, z, 64)).collect();
after.ground.answer(cols, now);
let sections = after.ground.world.take_wanted(now);
after.ground.world.serve(&Flat, sections, now);
after.sim.step(&mut after.ground, None, &mut out);
if after.sim.sams[0].air_48n6_stock == 1 { break; }
out = Out::default();
}
assert_eq!((after.sim.sams[1].ground_rounds, after.sim.sams[1].missiles), (2, 2));
assert!(!after.sim.sams[1].ground_request);
assert_eq!((after.sim.sams[0].air_48n6_stock, after.sim.sams[2].ground_stock, after.sim.sams[2].air_48n6_stock), (1, 0, 0));
}
/// #83: while an export records no other replay or film replaces it; after it, they may.
#[test]
fn typed_ammunition_changes_mark_the_state_dirty() {