From 804dddbad2b235dc738c9648ad01b0f5864f2406 Mon Sep 17 00:00:00 2001 From: Patric Stout Date: Thu, 18 Jul 2024 15:38:58 +0200 Subject: [PATCH] fix: crash if capacitor-peak-delta attribute value is absent (#52) --- 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