Avoid fit recalc when setting state has no effect

This commit is contained in:
blitzman
2017-02-11 23:55:19 -05:00
parent 2527fe2e1e
commit c9c29da803

View File

@@ -940,21 +940,27 @@ class Fit(object):
self.recalc(fit)
def toggleModulesState(self, fitID, base, modules, click):
changed = False
proposedState = self.__getProposedState(base, click)
if proposedState != base.state:
changed = True
base.state = proposedState
for mod in modules:
if mod != base:
mod.state = self.__getProposedState(mod, click,
proposedState)
p = self.__getProposedState(mod, click, proposedState)
mod.state = p
if p != mod.state:
changed = True
eos.db.commit()
fit = eos.db.getFit(fitID)
if changed:
eos.db.commit()
fit = eos.db.getFit(fitID)
# As some items may affect state-limiting attributes of the ship, calculate new attributes first
self.recalc(fit)
# Then, check states of all modules and change where needed. This will recalc if needed
self.checkStates(fit, base)
# As some items may affect state-limiting attributes of the ship, calculate new attributes first
self.recalc(fit)
# Then, check states of all modules and change where needed. This will recalc if needed
self.checkStates(fit, base)
# Old state : New State
localMap = {