From b9fdc76e339524dfd8ca362228f5b2ebb2cc3e5b Mon Sep 17 00:00:00 2001
From: Patric Stout <github@truebrain.nl>
Date: Thu, 18 Jul 2024 15:36:59 +0200
Subject: [PATCH] fix: crash if capacitor-peak-delta attribute value is absent

---
 src/calculate/pass_4/capacitor.rs | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/calculate/pass_4/capacitor.rs b/src/calculate/pass_4/capacitor.rs
index 65a8747..c13e7d4 100644
--- a/src/calculate/pass_4/capacitor.rs
+++ b/src/calculate/pass_4/capacitor.rs
@@ -10,6 +10,14 @@ struct Module {
 pub fn attribute_capacitor_depletes_in(ship: &mut Ship) {
     /* Amount of seconds it takes for the capacitor to deplete; or negative if it is stable. */
 
+    if !ship
+        .hull
+        .attributes
+        .contains_key(&(AttributeId::capacitorDepletesIn as i32))
+    {
+        return;
+    }
+
     let mut depletes_in = -1.0;
 
     let attr_capacitor_peak_delta = ship