From 27d6ea19b0206b71ef6c309142e0875275882bf0 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Wed, 25 Nov 2026 15:20:46 +0400 Subject: fix(ai): account for pending construction in class limits Implement Handler(11) limits for the original class set, including hangar and laboratory counters. Keep owned-object caps separate from pending thresholds; medium and large towers allow three and one active builds. Record the ordered class on construction tasks and count queries by clan, class and result. Execute ai.dll RVA 0xc5e7 with the GOG hash guard and compare owned counts, maxima, pending counts and unknown classes. Preserve these native vectors in a Rust test. Extend the licensed construction test to require pending count before registration, owner isolation and reset after completion. Validate fmt, workspace check/tests, licensed construction, release build and stock mission 29 in simulation and its window. This removes the Handler(11) coverage blocker for the following construction work; generic building orders and Handler(40) are still open. Pending counter sources and lifecycle beyond active FParkan Construction tasks remain approximate. --- crates/fparkan-runtime/src/construction.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'crates/fparkan-runtime/src/construction.rs') diff --git a/crates/fparkan-runtime/src/construction.rs b/crates/fparkan-runtime/src/construction.rs index afeff2e5..f85d53d1 100644 --- a/crates/fparkan-runtime/src/construction.rs +++ b/crates/fparkan-runtime/src/construction.rs @@ -44,6 +44,7 @@ struct Task { builder: ObjectHandle, owner: OwnerId, slot: usize, + class: u32, position: [f32; 3], cost: f32, arrived_at: Option, @@ -65,6 +66,13 @@ impl Construction { self.tasks.iter().any(|task| task.builder == builder) } + pub(super) fn pending_count(&self, owner: OwnerId, class: u32) -> usize { + self.tasks + .iter() + .filter(|task| task.owner == owner && task.class == class) + .count() + } + fn available_slot( &self, world: &World, @@ -86,6 +94,7 @@ impl Construction { builder: ObjectHandle, owner: OwnerId, slot: usize, + class: u32, position: [f32; 3], cost: f32, ) { @@ -93,6 +102,7 @@ impl Construction { builder, owner, slot, + class, position, cost, arrived_at: None, @@ -156,7 +166,7 @@ pub(super) fn order( patrol .get_or_insert_with(crate::unit_patrol::UnitPatrol::scripted) .move_to(world, builder, [position[0], position[1]], false); - construction.start(builder, owner, slot, position, cost); + construction.start(builder, owner, slot, class, position, cost); Ok(()) } @@ -390,6 +400,8 @@ mod tests { mission.behavior_ore_states[builder_ore].current_ore_bits = stock_before.to_bits(); order_for(mission, &engine.world).unwrap(); assert!(mission.construction.active(builder)); + assert_eq!(mission.construction.pending_count(owner, class), 1); + assert_eq!(mission.construction.pending_count(OwnerId(0), class), 0); assert!(handle_by_original_id(&engine.world, id).is_none()); let cost = mission.construction.tasks[0].cost; assert_eq!(cost, 1100.0); @@ -416,5 +428,6 @@ mod tests { stock_before - cost ); assert!(!mission.construction.active(builder)); + assert_eq!(mission.construction.pending_count(owner, class), 0); } } -- cgit v1.2.3