From 1776dd8007169ef4f04969f0a5edcc423b6d67bc Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Thu, 3 Dec 2026 18:14:49 +0400 Subject: feat(ui): restore cockpit status indicators --- crates/fparkan-runtime/src/repair_system.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'crates/fparkan-runtime/src/repair_system.rs') diff --git a/crates/fparkan-runtime/src/repair_system.rs b/crates/fparkan-runtime/src/repair_system.rs index 8fa6c09a..6d94a093 100644 --- a/crates/fparkan-runtime/src/repair_system.rs +++ b/crates/fparkan-runtime/src/repair_system.rs @@ -1,6 +1,10 @@ //! State switch for the controlled unit's Control repair device. -use crate::{Engine, MissionControlDeviceTableStatus, StartingCockpit}; +use crate::{EffectiveControlDevice, Engine, MissionControlDeviceTableStatus, StartingCockpit}; + +pub(super) fn is_self_repair_device(device: &EffectiveControlDevice) -> bool { + device.key == 0 && device.descriptor.tag == 15 && device.factory_tag == 15 +} /// Switches the selected unit's self-repair device when it is present. pub fn toggle_self_repair(engine: &mut Engine, cockpit: StartingCockpit) -> Option { @@ -12,9 +16,9 @@ pub fn toggle_self_repair(engine: &mut Engine, cockpit: StartingCockpit) -> Opti let MissionControlDeviceTableStatus::Available(devices) = &mut table.status else { return None; }; - let device = devices.iter_mut().find(|device| { - device.key == 0 && device.descriptor.tag == 15 && device.factory_tag == 15 - })?; + let device = devices + .iter_mut() + .find(|device| is_self_repair_device(device))?; // Control+0x22c90 handles the inverse switch command 0x40. let enabled = device.native_word_50_bits? != 0x20; device.native_word_50_bits = Some(if enabled { 0x20 } else { 0 }); -- cgit v1.2.3