From 6cce33ff5b29616fb3d5caf9325729068d0631eb Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Wed, 25 Nov 2026 12:57:40 +0400 Subject: feat(ai): select free factories for scripted production Handler(13) UNIT_FREE_UNIT now selects the first live clan object of the requested exact class. Reserved objects, assigned runtime workers and busy factories are skipped. Coverage records each selected logical ID. Campaign mission 8 can execute PBM_ROBOT_NEEDED and replenish its guards. Original GOG ai.dll RVA 0x86fb confirmed roster order, exact class matching, exclusion of busy and reserved entries, and ERROR when none are free. Validated with matching Rust roster cases, a licensed stock mission 8 production test, fmt/check/test workspace, and 900-second simulations of missions 8 and 28. Mission 8 also ran in the window with Vulkan validation. Occupancy is inferred from runtime jobs; native problem-slot ownership, other selection modes and mission chronology beside the original remain open. --- crates/fparkan-runtime/src/lib.rs | 5 +++++ 1 file changed, 5 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 a4f3fdb8..1a878d75 100644 --- a/crates/fparkan-runtime/src/lib.rs +++ b/crates/fparkan-runtime/src/lib.rs @@ -2972,6 +2972,7 @@ pub struct SimulationReport { pub script_group_orders: Vec<(usize, u32, u64)>, pub script_point_group_orders: Vec<(usize, u32, u32, u64)>, pub script_point_patrol_continues: Vec<(usize, u32, u32, u64)>, + pub script_free_unit_queries: Vec<(usize, u32, u32, u64)>, pub script_problem_waits: Vec<(usize, u32, u64)>, pub script_factory_patrol_continues: Vec<(usize, u32, u64)>, pub script_ore_transport_orders: Vec<(usize, u32, u64)>, @@ -3030,6 +3031,7 @@ pub fn simulate_mission_report( script_group_orders: Vec::new(), script_point_group_orders: Vec::new(), script_point_patrol_continues: Vec::new(), + script_free_unit_queries: Vec::new(), script_problem_waits: Vec::new(), script_factory_patrol_continues: Vec::new(), script_ore_transport_orders: Vec::new(), @@ -3143,6 +3145,9 @@ pub fn simulate_mission_report( report .script_point_patrol_continues .extend(loaded.clan_ai_events.point_patrol_continues()); + report + .script_free_unit_queries + .extend(loaded.clan_ai_events.free_unit_queries()); report .script_problem_waits .extend(loaded.clan_ai_events.wait_starts()); -- cgit v1.2.3