From 1d92ac712c970cce8cea3eacd34d4033f80c543b Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Sat, 14 Nov 2026 22:03:00 +0400 Subject: fix(ai): wait for the factory before restarting robot jobs Track the factory assigned by ST_SOLVING and the ACTION_NOTHING_DOING expression. Stock Single.01 completes the first robot at 27 seconds without duplicate busy-factory rejections. Keep other expression variants explicitly uncovered. --- crates/fparkan-runtime/src/production.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'crates/fparkan-runtime/src/production.rs') diff --git a/crates/fparkan-runtime/src/production.rs b/crates/fparkan-runtime/src/production.rs index 315dbb5a..ab6b38e7 100644 --- a/crates/fparkan-runtime/src/production.rs +++ b/crates/fparkan-runtime/src/production.rs @@ -133,6 +133,12 @@ impl PaidOrder { } impl Production { + pub(super) fn is_building_at(&self, plant: ObjectHandle, owner: OwnerId) -> bool { + self.pending + .iter() + .any(|order| order.plant == plant && order.owner == owner) + } + pub(super) fn new( reserve_start: usize, schemes: Vec, @@ -730,6 +736,7 @@ mod tests { "{report:?}" ); assert!(!report.first_factory_completion_ms.contains_key(&0)); + assert!(report.script_factory_rejections.is_empty(), "{report:?}"); let cockpit = super::super::starting_cockpit(&engine).unwrap(); let factory = handle_by_original_id(&engine.world, OriginalObjectId(5)).unwrap(); let duration = order_clan_factory_scheme(&mut engine, cockpit, factory, 0, 40_000).unwrap(); -- cgit v1.2.3