From 6b48c7130acbaa8eb72335e6736913b7838e19b3 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Sat, 14 Nov 2026 10:19:30 +0400 Subject: feat(runtime): expose live clan ownership to mission scripts --- crates/fparkan-runtime/src/lib.rs | 57 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'crates/fparkan-runtime/src/lib.rs') diff --git a/crates/fparkan-runtime/src/lib.rs b/crates/fparkan-runtime/src/lib.rs index 845afa57..8f396629 100644 --- a/crates/fparkan-runtime/src/lib.rs +++ b/crates/fparkan-runtime/src/lib.rs @@ -17628,6 +17628,63 @@ mod tests { assert_eq!(idle.player_pitch_bits, blocked.player_pitch_bits); } + #[test] + #[ignore = "requires licensed corpus"] + fn licensed_constructor_checks_current_factory_and_hangar_owners() { + use fparkan_world::{identity_metadata, set_owner, OwnerId}; + + let vfs: Arc = Arc::new(DirectoryVfs::new(licensed_root("IS"))); + let mut engine = create(EngineServices::new(vfs)).unwrap(); + load_mission_with_init_stubs( + &mut engine, + MissionRequest { + key: "MISSIONS/CAMPAIGN/CAMPAIGN.00/Mission.02/data.tma".into(), + mode: MissionMode::SingleMission, + }, + MissionStartupInput { + queue_time_ms: 0, + research_creation_gate: false, + }, + ) + .unwrap(); + let initial = frame(&mut engine, 1).unwrap().mission_event.unwrap(); + assert!(initial.stop.is_none(), "{:?}", initial.stop); + assert!(!initial + .notices + .iter() + .any(|notice| matches!(notice, MissionNotice::ObjectiveComplete(0 | 2)))); + for (time, logic_id, objective_index) in [(2001, 0x8000_0001, 0), (4001, 0x8000_0003, 2)] { + let slot = engine + .loaded + .as_ref() + .unwrap() + .mission + .objects + .iter() + .position(|object| object.identity_or_clan_raw == logic_id) + .unwrap(); + let handle = mission_object_handle(&engine, OriginalObjectId(slot as u32)).unwrap(); + assert_eq!( + identity_metadata(&engine.world, handle).unwrap().owner_id, + Some(OwnerId(2)) + ); + set_owner(&mut engine.world, handle, Some(OwnerId(0))).unwrap(); + let event = frame(&mut engine, time).unwrap().mission_event.unwrap(); + assert!(event.stop.is_none(), "{:?}", event.stop); + assert!( + event + .notices + .contains(&MissionNotice::ObjectiveComplete(objective_index)), + "{:?}", + event.notices + ); + } + assert_eq!( + loaded_mission_script_outcome(&engine), + Some(MissionScriptOutcome::Active) + ); + } + #[test] #[ignore = "requires licensed corpus"] fn licensed_firing_range_reports_target_loss_and_completes_all_objectives() { -- cgit v1.2.3