aboutsummaryrefslogtreecommitdiff
path: root/crates/fparkan-runtime/src/repair_system.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-12-03 17:14:49 +0300
committerValentin Popov <valentin@popov.link>2026-12-03 17:14:49 +0300
commit1776dd8007169ef4f04969f0a5edcc423b6d67bc (patch)
treed6bf261f4ecf07ddb79026130448f5aa937d49a1 /crates/fparkan-runtime/src/repair_system.rs
parentca66e64b3995229ca7c8771b75ca26a60c3e344f (diff)
downloadfparkan-1776dd8007169ef4f04969f0a5edcc423b6d67bc.tar.xz
fparkan-1776dd8007169ef4f04969f0a5edcc423b6d67bc.zip
feat(ui): restore cockpit status indicators
Diffstat (limited to 'crates/fparkan-runtime/src/repair_system.rs')
-rw-r--r--crates/fparkan-runtime/src/repair_system.rs12
1 files changed, 8 insertions, 4 deletions
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<bool> {
@@ -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 });