From b469fa520e45a1e983f8bf3e96e6db098ce39a74 Mon Sep 17 00:00:00 2001 From: DarkPhoenix Date: Mon, 26 Aug 2019 09:02:55 +0300 Subject: [PATCH] Do not crash on cap boosters only in fit --- eos/capSim.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/eos/capSim.py b/eos/capSim.py index 06737b58b..c4a106437 100644 --- a/eos/capSim.py +++ b/eos/capSim.py @@ -148,6 +148,7 @@ class CapSimulator: stability_precision = self.stability_precision period = self.period + activation = None iterations = 0 capCapacity = self.capacitorCapacity @@ -162,7 +163,12 @@ class CapSimulator: t_max = self.t_max while 1: - activation = pop(state) + # Nothing to pop - might happen when no mods are activated, or when + # only cap injectors are active (and are postponed by code below) + try: + activation = pop(state) + except IndexError: + break t_now, duration, capNeed, shot, clipSize, reloadTime, isInjector = activation # Max time reached, stop simulation - we're stable @@ -275,7 +281,8 @@ class CapSimulator: activation[3] = shot push(state, activation) - push(state, activation) + if activation is not None: + push(state, activation) # update instance with relevant results. self.t = t_last