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