Tie a radar's refine/fire channel to its own plot's freshness (#140)
build / mod (push) Failing after 28s
build / mod (push) Failing after 28s
A station counted any own plot, however old, as a busy refine/fire channel: a network heartbeat kept a stale contact's track fresh, so two long-expired own fire plots still held both channels of the engagement radar and a new contact nearby got only a coarse search plot, even with the search radar running. Channel occupancy now follows the station's own tracking. Track::holds_channel requires an own (never relayed) refine/fire plot no older than the station's track_ttl — three missed turns, the same value that already bounds a contact without a fresh measurement. The planner counts channels with the same Sam::own_channels_used(now) the panel, monitor, map and "why" views read, so the UI and the allocation cannot disagree about a stale channel. A stale channel frees for a new contact without the network's survey track being removed; the hard per-profile limit and the own measurement's provenance are unchanged, and a relayed plot still never holds a channel. Test: two contacts take both channels at the station, then leave its reach while the search radar beside them keeps relaying them; a third contact arrives nearby and gets its own fire channel (the test fails on the old counting), and the relayed survey tracks of the old contacts stay. Co-Authored-By: Kimi Code <noreply@moonshot.ai>
This commit is contained in:
@@ -423,7 +423,7 @@ impl Sim {
|
||||
let spec = sam.kind.spec();
|
||||
let now = self.tick;
|
||||
let channels = (spec.sensor > 0.0 && sam.mode != battery::SamMode::LauncherOnly && sam.radar_profile().channels > 0)
|
||||
.then(|| (sam.own_channels_used(), sam.radar_profile().channels));
|
||||
.then(|| (sam.own_channels_used(now), sam.radar_profile().channels));
|
||||
let reason = |kind, block, target, mark| BattleReason {
|
||||
kind,
|
||||
block,
|
||||
@@ -554,7 +554,7 @@ impl Sim {
|
||||
});
|
||||
if let Some((radar, tr)) = support {
|
||||
let profile = radar.radar_profile();
|
||||
let used = radar.own_channels_used();
|
||||
let used = radar.own_channels_used(now);
|
||||
if profile.channels > 0 && used >= profile.channels as usize && !tr.own_authorizes(now) {
|
||||
let mut busy = reason(BattleKind::ChannelsBusy, None, Some(t.id), mark);
|
||||
busy.channels = Some((used, profile.channels));
|
||||
@@ -667,8 +667,8 @@ impl Sim {
|
||||
if profile.local >= 1.0 { "во всей дальности".to_string() } else { format!("{:.0}% дальности", profile.local * 100.0) },
|
||||
)));
|
||||
v.push(check(true, format!("ограничение: {}", profile.limit)));
|
||||
v.push(check(true, format!("свои треки: {}, каналы {}/{}", sam.own.len(), sam.own_channels_used(), profile.channels)));
|
||||
let now = self.tick;
|
||||
v.push(check(true, format!("свои треки: {}, каналы {}/{}", sam.own.len(), sam.own_channels_used(now), profile.channels)));
|
||||
let mut tracks: Vec<&Track> = sam.tracks.iter().filter(|t| t.own_tick > 0).collect();
|
||||
tracks.sort_by_key(|t| std::cmp::Reverse(t.quality));
|
||||
for t in tracks.into_iter().take(4) {
|
||||
|
||||
Reference in New Issue
Block a user