Keep unfinished retarget routes in a bounded job queue (#127)
A mass retarget used to clear every selected drone's route before the planner's per-tick work ran out: the rest flew straight for ever. Route jobs now carry the drone id, new aim, target unit, knowledge version and the intel snapshot, stay in a FIFO across ticks and are drained under the same WORK_PER_TICK. An old safe route is kept until its replacement is ready; a cancelled job falls back to a straight run. Jobs are replaced in place per drone, cancelled when the drone or unit is gone, and retarget routes reuse the original plan's known relief. An in-flight drone no longer turns to a unit behind its turning circle. Core release tests, adapter tests and the real WASM contract pass.
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
//! (`DroneKind::spec`, `MissileKind::spec`, `SamKind::spec`) plus how its
|
||||
//! parts are drawn (`Sim::draw_sam`).
|
||||
use glam::{DQuat, DVec3};
|
||||
use std::collections::HashMap;
|
||||
use std::collections::{HashMap, VecDeque};
|
||||
|
||||
pub mod battery;
|
||||
pub mod launch;
|
||||
@@ -1302,6 +1302,12 @@ pub struct Sim {
|
||||
pub strikes: strike::Strikes,
|
||||
/// A raid being planned.
|
||||
plan: Option<raid::Plan>,
|
||||
/// Routes still to work out after a mass retarget (#127): the drones were given a new aim, but the
|
||||
/// planner's share of a tick ran out. They keep their old route until a new one is ready.
|
||||
retargets: VecDeque<ew::RouteJob>,
|
||||
/// The known land of the last smart raid's plan: its grid and cell heights (NaN unknown). A retarget
|
||||
/// is planned over the same knowledge, never over land mapped after it (#127).
|
||||
known_relief: Option<(raid::Grid, Vec<f32>)>,
|
||||
/// The vehicles' ground routes, and the jobs the trucks found out of reach (#94).
|
||||
routes: route::Routes,
|
||||
/// Each marked object's health, 0 to 100 (`targets`' order).
|
||||
@@ -1381,6 +1387,8 @@ impl Sim {
|
||||
sites: sites::Sites::default(),
|
||||
strikes: strike::Strikes::new(),
|
||||
plan: None,
|
||||
retargets: VecDeque::new(),
|
||||
known_relief: None,
|
||||
routes: Default::default(),
|
||||
target_health: Vec::new(),
|
||||
wave: None,
|
||||
@@ -1490,6 +1498,8 @@ impl Sim {
|
||||
self.queue.clear();
|
||||
self.sites.clear();
|
||||
self.plan = None;
|
||||
self.retargets.clear();
|
||||
self.known_relief = None;
|
||||
self.wave = None;
|
||||
// Ammunition still to cook off, flares in the sky.
|
||||
self.later.clear();
|
||||
|
||||
Reference in New Issue
Block a user