feat: consume scoped engine capabilities and preserve safe fallbacks
build / mod (push) Failing after 19s
build / mod (push) Failing after 19s
Pin API27, diagnose prepared states, gate capture ownership and keep far-sound fallback until acoustics is prepared. Retain engine changes in build provenance and cancel invalid return reservations after cell loss. Co-authored-by: Codex <codex@openai.com>
This commit is contained in:
+37
-3
@@ -13,6 +13,7 @@ use horizon_mod_sdk::{
|
||||
};
|
||||
|
||||
mod cinema;
|
||||
mod capabilities;
|
||||
mod engines;
|
||||
mod commands;
|
||||
mod layout;
|
||||
@@ -810,7 +811,7 @@ impl AirDef {
|
||||
let mut booms: Vec<(f64, usize, DVec3, f32, f32)> = Vec::new();
|
||||
// The game muffles by walls and distance itself (#96): the near variants play out to the
|
||||
// reach of its tracing, so nothing is muffled twice; past it the far ones still do.
|
||||
let far = if render::acoustics() { ACOUSTIC_FAR } else { FAR };
|
||||
let far = if capabilities::ready(&capabilities::acoustics()) { ACOUSTIC_FAR } else { FAR };
|
||||
for (event, at, volume, pitch) in out.sounds {
|
||||
let dist = at.distance(ctx.listener);
|
||||
if let Some(power) = cinema::blast_power(event) {
|
||||
@@ -1356,6 +1357,21 @@ impl AirDef {
|
||||
}
|
||||
ex.ticks += 1;
|
||||
let st = render::capture_status();
|
||||
let owner = render::capture_owner_status();
|
||||
if ex.stage != Stage::Planning {
|
||||
if let Some(problem) = capabilities::capture_problem(&owner) {
|
||||
let message = if st.message.is_empty() { problem.to_string() } else { format!("{problem}: {}", st.message) };
|
||||
say(&format!("Экспорт не удался: {message}"));
|
||||
r.done = true;
|
||||
return Some(Err(message));
|
||||
}
|
||||
if ex.stage == Stage::Arming && ex.ticks > 600 {
|
||||
let message = "Движок не подтвердил подготовку захвата за 600 тиков".to_string();
|
||||
say(&message);
|
||||
r.done = true;
|
||||
return Some(Err(message));
|
||||
}
|
||||
}
|
||||
let failed = |s: &render::CaptureState| s.phase == render::CapturePhase::Failed;
|
||||
let mut finish: Option<Result<String, String>> = None;
|
||||
match ex.stage {
|
||||
@@ -1375,12 +1391,13 @@ impl AirDef {
|
||||
Ok(()) => {
|
||||
say(&format!("Кадры готовы ({}); запись…", r.film_summary()));
|
||||
ex.stage = Stage::Arming;
|
||||
ex.ticks = 0;
|
||||
}
|
||||
Err(e) => finish = Some(Err(e)),
|
||||
}
|
||||
}
|
||||
Stage::Arming => {
|
||||
if st.phase == render::CapturePhase::Recording {
|
||||
if st.phase == render::CapturePhase::Recording && capabilities::ready(&owner) {
|
||||
r.wait = false;
|
||||
ex.stage = Stage::Recording;
|
||||
ex.ticks = 0;
|
||||
@@ -1400,7 +1417,7 @@ impl AirDef {
|
||||
}
|
||||
}
|
||||
Stage::Finishing => match st.phase {
|
||||
render::CapturePhase::Done => {
|
||||
render::CapturePhase::Done if capabilities::ready(&owner) => {
|
||||
let note = if st.message.is_empty() { String::new() } else { format!(" ({})", st.message) };
|
||||
finish = Some(Ok(format!("{}x{}, {} кадров: {}{note}", st.width, st.height, st.frames, st.file)));
|
||||
}
|
||||
@@ -2268,6 +2285,7 @@ impl Mod for AirDef {
|
||||
self.open_menu(Page::Main);
|
||||
None
|
||||
}
|
||||
["capabilities"] => Some(capabilities::diagnostics()),
|
||||
["monitor"] => {
|
||||
self.cycle_monitor();
|
||||
None
|
||||
@@ -2597,6 +2615,22 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_return_reservation_lost_with_the_launcher_keeps_a_loadable_save() {
|
||||
let mut game = test_mod();
|
||||
let mut sam = Sam::new(100, SamKind::S400, DVec3::ZERO, 0.0);
|
||||
sam.ground_rounds = 1;
|
||||
sam.missiles = 3;
|
||||
sam.ground_return = true;
|
||||
sam.comps.0[sim::Part::Launcher as usize] = 0.0;
|
||||
sam.fit_cells();
|
||||
game.sim.sams.push(sam);
|
||||
let mut restored = test_mod();
|
||||
restored.apply_state(&game.state_text(false, false)).unwrap();
|
||||
assert_eq!(restored.sim.sams[0].ground_rounds, 0);
|
||||
assert!(!restored.sim.sams[0].ground_return);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn return_round_drives_and_survives_both_state_round_trips() {
|
||||
struct Flat;
|
||||
|
||||
Reference in New Issue
Block a user