From 7dd027fd5130daf532cd2214a6d9689293bb2c86 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Wed, 2 Dec 2026 13:07:11 +0400 Subject: feat(ui): assign search and destroy from the warbot panel Show the native search status immediately without opening the map. Verify from the stock Two Fortresses start that the selected marker moves with the internal route hidden and that Stand cancels the search. --- crates/fparkan-runtime/src/unit_patrol/orders.rs | 35 ++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) (limited to 'crates/fparkan-runtime/src/unit_patrol/orders.rs') diff --git a/crates/fparkan-runtime/src/unit_patrol/orders.rs b/crates/fparkan-runtime/src/unit_patrol/orders.rs index 48a849f3..b956c599 100644 --- a/crates/fparkan-runtime/src/unit_patrol/orders.rs +++ b/crates/fparkan-runtime/src/unit_patrol/orders.rs @@ -15,6 +15,7 @@ pub(crate) enum UnitOrder { Stand, Route(Vec<[f32; 2]>), StrategicPatrol(PatrolTarget), + SearchAndDestroy, Shutdown, Resume(Box), } @@ -25,6 +26,7 @@ impl UnitOrder { Self::Move(_) | Self::Route(_) => 2, Self::Attack(..) => 3, Self::Patrol(..) | Self::StrategicPatrol(_) => 4, + Self::SearchAndDestroy => 5, Self::Shutdown => 0x13, Self::Stand => 0x15, Self::Resume(_) => unreachable!("a suspended order has already started"), @@ -82,6 +84,8 @@ impl UnitPatrol { }; if unit.capture_target.is_some() { 0x11 + } else if unit.search.is_some() { + UnitOrder::SearchAndDestroy.opcode() } else if unit.attack_target.is_some() || unit.raid_factory.is_some() { 3 } else if unit @@ -99,8 +103,9 @@ impl UnitPatrol { pub(crate) fn satellite_route(&self, actor: ObjectHandle) -> Vec<[f32; 2]> { let active = self.units.iter().find(|unit| unit.handle == actor); - // iron3d+0x77ae0 prefers the path whenever there are unvisited points. - if let Some(unit) = active.filter(|unit| !unit.points.is_empty()) { + // iron3d+0x77ae0 draws published waypoints. Search does not publish its + // internal navigation path to the satellite map. + if let Some(unit) = active.filter(|unit| unit.search.is_none() && !unit.points.is_empty()) { return unit.points.iter().copied().collect(); } let mut points = Vec::new(); @@ -119,7 +124,10 @@ impl UnitPatrol { UnitOrder::Route(route) => points.extend(route), UnitOrder::StrategicPatrol(PatrolTarget::Point(point)) => points.push(*point), UnitOrder::StrategicPatrol(PatrolTarget::Object(_)) => {} - UnitOrder::Attack(..) | UnitOrder::Shutdown | UnitOrder::Stand => {} + UnitOrder::Attack(..) + | UnitOrder::Shutdown + | UnitOrder::Stand + | UnitOrder::SearchAndDestroy => {} } } } @@ -299,6 +307,7 @@ impl UnitPatrol { self.standing.insert(actor); return true; } + UnitOrder::SearchAndDestroy => return self.start_search(world, actor), UnitOrder::Route(route) => { for (index, &point) in route.iter().enumerate() { self.move_to(world, actor, point, index != 0); @@ -493,6 +502,26 @@ mod tests { assert_eq!(patrol.satellite_route(actor), points); } + #[test] + fn command_panel_search_replaces_the_route_without_a_target_click() { + let mut world = fparkan_world::new(Default::default()); + let actor = object(&mut world); + let mut patrol = UnitPatrol::scripted(); + patrol.command_order(&world, actor, UnitOrder::Route(vec![[45.0, 60.0]])); + + patrol.command_order(&world, actor, UnitOrder::SearchAndDestroy); + assert_eq!(patrol.active_order_code(actor), 5); + assert!(patrol.satellite_route(actor).is_empty()); + patrol.units[0].points = VecDeque::from([[25.0, 35.0]]); + assert!(patrol.satellite_route(actor).is_empty()); + assert_eq!(patrol.search_target(actor), Some(None)); + assert!(patrol.attack_limit(&world, actor).is_none()); + + patrol.command_order(&world, actor, UnitOrder::Stand); + assert_eq!(patrol.active_order_code(actor), 0x15); + assert_eq!(patrol.search_target(actor), None); + } + #[test] fn command_panel_patrol_replaces_the_route_and_tracks_an_object_center() { let mut world = fparkan_world::new(Default::default()); -- cgit v1.2.3