aboutsummaryrefslogtreecommitdiff
path: root/crates/fparkan-runtime/src/lib.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-11-14 03:00:29 +0300
committerValentin Popov <valentin@popov.link>2026-11-14 03:00:29 +0300
commit470f10f93a1818e0293c045e5309ab4a60e73caf (patch)
tree68ef7fd96b92b0f6d177cc3c316607ec993860c3 /crates/fparkan-runtime/src/lib.rs
parent7945a65cb1fe12d5249f5db6a3d051ccd5e6e9b4 (diff)
downloadfparkan-470f10f93a1818e0293c045e5309ab4a60e73caf.tar.xz
fparkan-470f10f93a1818e0293c045e5309ab4a60e73caf.zip
feat(game): list missions and report headless coverage
Diffstat (limited to 'crates/fparkan-runtime/src/lib.rs')
-rw-r--r--crates/fparkan-runtime/src/lib.rs42
1 files changed, 42 insertions, 0 deletions
diff --git a/crates/fparkan-runtime/src/lib.rs b/crates/fparkan-runtime/src/lib.rs
index 5cc2d862..b9b624d2 100644
--- a/crates/fparkan-runtime/src/lib.rs
+++ b/crates/fparkan-runtime/src/lib.rs
@@ -2220,6 +2220,48 @@ pub fn frame(engine: &mut Engine, queue_time_ms: u32) -> Result<FrameResult, Eng
step_headless(engine, InputSnapshot, queue_time_ms)
}
+/// Coverage entries for the subsystems still absent from the mission loop.
+pub const SIMULATION_COVERAGE: &str =
+ "sim_coverage research_startup_gate_stub=1 mission_handlers_stub=1 unit_behavior_stub=1";
+
+/// Totals from a headless mission coverage run.
+#[derive(Clone, Copy, Debug, Eq, PartialEq)]
+pub struct SimulationReport {
+ /// Number of completed steps.
+ pub ticks: u64,
+ /// Live objects after the last step.
+ pub live_objects: usize,
+ /// World events processed over the run.
+ pub world_events: u64,
+}
+
+/// Steps a freshly loaded mission from queue time zero at 60 Hz for coverage.
+///
+/// The sampling rate makes reports reproducible. The window uses elapsed time.
+///
+/// # Errors
+///
+/// Returns the first world or resource update error encountered during the run.
+pub fn simulate_mission_report(
+ engine: &mut Engine,
+ duration_ms: u32,
+) -> Result<SimulationReport, EngineError> {
+ let mut report = SimulationReport {
+ ticks: 0,
+ live_objects: loaded_mission(engine).map_or(0, |mission| mission.registered_objects),
+ world_events: 0,
+ };
+ let steps = (u64::from(duration_ms) * 60).div_ceil(1000);
+ for tick in 1..=steps {
+ let clock_ms = (tick * 1000 / 60).min(u64::from(duration_ms)) as u32;
+ let frame = frame(engine, clock_ms)?;
+ report.ticks = tick;
+ report.live_objects = frame.snapshot.objects.len();
+ report.world_events += frame.snapshot.events.len() as u64;
+ }
+ Ok(report)
+}
+
/// Returns the loaded mission summary.
#[must_use]
pub fn loaded_mission(engine: &Engine) -> Option<&LoadedMission> {