diff options
| author | Valentin Popov <valentin@popov.link> | 2026-11-14 05:06:04 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-11-14 05:06:04 +0300 |
| commit | db3f404b3d6d24144c49ae5248262ab1d8d55e21 (patch) | |
| tree | 1c23b1d4bb101460c1c1a601fa232c00d2ec0c60 /crates/fparkan-runtime/src/lib.rs | |
| parent | badbf2e74fceecadba1487b0863825e180e61c85 (diff) | |
| download | fparkan-db3f404b3d6d24144c49ae5248262ab1d8d55e21.tar.xz fparkan-db3f404b3d6d24144c49ae5248262ab1d8d55e21.zip | |
feat(runtime): count live clan objects in mission scripts
Diffstat (limited to 'crates/fparkan-runtime/src/lib.rs')
| -rw-r--r-- | crates/fparkan-runtime/src/lib.rs | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/crates/fparkan-runtime/src/lib.rs b/crates/fparkan-runtime/src/lib.rs index 55a1f324..f3dae1fe 100644 --- a/crates/fparkan-runtime/src/lib.rs +++ b/crates/fparkan-runtime/src/lib.rs @@ -2186,6 +2186,11 @@ fn load_mission_with_options( script_varset_state_count: loaded_scripts.varset_states.len(), }; + let mission_events = if options.asset_scope == MissionAssetScope::Full { + MissionEvents::with_placed_objects(&object_drafts, &handles, summary.clan_count) + } else { + MissionEvents::default() + }; engine.world = new_runtime_world; engine.behavior_rng_state = next_behavior_rng_state; engine.loaded = Some(LoadedMissionState { @@ -2209,7 +2214,7 @@ fn load_mission_with_options( script_varset: loaded_scripts.varset, script_init_states: loaded_scripts.init_states, script_varset_states: loaded_scripts.varset_states, - mission_events: MissionEvents::default(), + mission_events, script_host_mode: request.mode, // Fresh IGame construction seeds this field with 5; this is not the // later status-4 transition performed after native game initialization. @@ -2275,7 +2280,7 @@ pub fn frame(engine: &mut Engine, queue_time_ms: u32) -> Result<FrameResult, Eng /// 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 render_object_lifecycle_stub=1 render_winding_change_stub=1 mission_event_clock_approx=1 mission_tactical_ids_stub=1 mission_message_ui_stub=1"; + "sim_coverage research_startup_gate_stub=1 mission_handlers_stub=1 unit_behavior_stub=1 render_object_lifecycle_stub=1 render_winding_change_stub=1 mission_event_clock_approx=1 mission_tactical_ids_stub=1 mission_clan_roster_stub=1 mission_message_ui_stub=1"; /// Totals from a headless mission coverage run. #[derive(Clone, Debug, Eq, PartialEq)] @@ -17061,7 +17066,7 @@ mod tests { #[test] #[ignore = "requires licensed corpus"] - fn licensed_firing_range_voices_spawn_area_messages_once() { + fn licensed_firing_range_voices_spawn_and_first_target_loss_once() { let vfs: Arc<dyn Vfs> = Arc::new(DirectoryVfs::new(licensed_root("IS"))); let mut engine = create(EngineServices::new(vfs)).unwrap(); load_mission_with_init_stubs( @@ -17078,16 +17083,15 @@ mod tests { .unwrap(); let first = frame(&mut engine, 5).unwrap().mission_event.unwrap(); assert_eq!(first.messages, [11, 14]); - let stop = first.stop.unwrap(); - assert_eq!( - (stop.clan_index, stop.event_index, stop.instruction_index), - (0, 2, 49) - ); - assert_eq!(stop.reason, "Handler(31)"); + assert!(first.stop.is_none()); assert!(frame(&mut engine, 2_004).unwrap().mission_event.is_none()); + let first_target = mission_object_handle(&engine, OriginalObjectId(1)).unwrap(); + fparkan_world::request_delete(&mut engine.world, first_target).unwrap(); let next = frame(&mut engine, 2_005).unwrap().mission_event.unwrap(); assert!(next.stop.is_none()); - assert!(next.messages.is_empty()); + assert_eq!(next.messages, [17]); + let later = frame(&mut engine, 4_005).unwrap().mission_event.unwrap(); + assert!(later.messages.is_empty()); } #[test] |
