diff --git a/eos/saveddata/fit.py b/eos/saveddata/fit.py index eb4587b61..0f16527f3 100644 --- a/eos/saveddata/fit.py +++ b/eos/saveddata/fit.py @@ -19,6 +19,7 @@ import datetime import time +from contextlib import contextmanager from copy import deepcopy from itertools import chain from math import ceil, log, sqrt @@ -67,6 +68,22 @@ class Fit: PEAK_RECHARGE = 0.25 + # When > 0, __resetDependentCalcs does not mark projection victims stale. + # Sequential full recalcs for mutually-projected fits (e.g. graph) would + # otherwise set victim.calculated = False without clearing them; the next + # PROJECTED pass then runs clear() and wipes that fit after it was just + # calculated correctly. + _suspendVictimCalcResetDepth = 0 + + @classmethod + @contextmanager + def suspendVictimCalcReset(cls): + cls._suspendVictimCalcResetDepth += 1 + try: + yield + finally: + cls._suspendVictimCalcResetDepth -= 1 + def __init__(self, ship=None, name=""): """Initialize a fit from the program""" self.__ship = None @@ -973,6 +990,8 @@ def __runCommandBoosts(self, runTime="normal"): def __resetDependentCalcs(self): self.calculated = False + if Fit._suspendVictimCalcResetDepth > 0: + return for value in list(self.projectedOnto.values()): if value.victim_fit: # removing a self-projected fit causes victim fit to be None. @todo: look into why. :3 value.victim_fit.calculated = False @@ -1107,6 +1126,8 @@ def calculateModifiedAttributes(self, targetFit=None, type=CalcType.LOCAL): # tabs. See GH issue 1193 if type == CalcType.COMMAND and targetFit in self.commandFits: pyfalog.debug("{} is in the command listing for COMMAND ({}), do not mark self as calculated (recursive)".format(repr(targetFit), repr(self))) + elif type == CalcType.PROJECTED: + pyfalog.debug("{} is projecting onto {} (PROJECTED), do not mark self as calculated (not a full local calc)".format(repr(self), repr(targetFit))) else: self.__calculated = True diff --git a/eos/saveddata/module.py b/eos/saveddata/module.py index 99a9eaa61..a989df91b 100644 --- a/eos/saveddata/module.py +++ b/eos/saveddata/module.py @@ -970,8 +970,14 @@ def getCycleParameters(self, reloadOverride=None): # Determine if we'll take into account reload time or not if reloadOverride is not None: factorReload = reloadOverride + elif self.forceReload is not None: + factorReload = self.forceReload + elif self.owner is None: + # Owner can be temporarily unset during fit/tab transitions; default to + # no reload factoring until association is restored. + factorReload = False else: - factorReload = self.owner.factorReload if self.forceReload is None else self.forceReload + factorReload = self.owner.factorReload cycles_until_reload = self.numShots if cycles_until_reload == 0: